1. Field of the Invention
The present invention relates to the design of user interface for a graphical programming language. More specifically, the present invention relates to a method and an apparatus that facilitates visually comparing the difference between two program graphs in a graphical programming language interface.
2. Related Art
A graphical programming language (GPL) enables a programmer to interact with programs by graphically manipulating program components through a graphical user interface (GUI). Specifically, a program within a GPL is typically comprised of multiple base processing units, such as subroutines, or functions, and these base processing units are represented graphically as “boxes” or “patches” within the GUI. Each “patch” can have a number of input ports for receiving input variables/parameters, and a number of output ports for outputting results when the patch is executed. The relationships between patches can be understood by viewing their spatial arrangements and associated connectivity information within the GUI. This connectivity information is typically illustrated using lines, arrows, or arcs that connect the output ports of upstream patches to the input ports of downstream patches. The collection of the patches and the connections between the patches form a “graph” structure for a corresponding program.
Note that when editing text-based documents, changes from one version to another can be easily detected, for example, by using a text-document-comparison tool. However, in graph-based programming, it is significantly more difficult to quickly identify the structural differences between two versions of the same program graph. This problem is inherent to the fact that program graphs are two-dimensional (2D) objects, and therefore the layout of a program graph is not necessarily correlated with the structure of the graph. For example, a programmer can move a patch in a graph to a very different location in the editor window without changing any connections to the patch. As a result, the graph structure does not change even though the visual representation has changed.
The above problem becomes even more prominent when the programmer works on a complex graph structure comprising a large number of patches and associated interconnections. For example, when working in collaboration mode on a large program, a program graph may have been modified by another programmer since the last time a primary programmer edited the graph. The primary programmer would ideally like to be able to identify all the changes made to the graph. Unfortunately, by observing two versions of the graph next to each other, it can be extremely hard to distinguish all the differences between the graphs.
Hence, what is needed is a method and an apparatus that facilitates visualizing differences between two 2D program graphs without the above problems.
One embodiment of the present invention provides a system that highlights differences between two graphs that represent programs in a graphical programming language. During operation, the system identifies unique nodes in the two graphs which are not identical to any other node in the other graph. Note that each of the two graphs comprises a set of interconnected nodes which represent functions in the graphical programming language. The system then displays the two graphs within the same editor window, and while doing so highlights nodes which do not have identical counterparts in the other graph.
In a variation on this embodiment, the system identifies the unique nodes by: identifying a first node in the first graph and a second node in the second graph which have the same identifier; determining that the first and second nodes are different if: (1) the first and second nodes have at least one connection which is different; or (2) the first and second nodes have at least one internal parameter setting which is different; and if the first node second nodes are different, determining the first node and the second node are unique nodes.
In a further variation, the system identifies the unique nodes by: determining if a node in the first graph has an identifier which does not match an identifier for a node in the second graph or if a node in the second graph has an identifier which does not match an identifier for a node in the first graph; and if so, determining that the non-matching node is a unique node.
In a variation on this embodiment, the system highlights the unique nodes by displaying the unique nodes in a color that indicates that the nodes are unique.
In a variation on this embodiment, the two graphs represent two versions of the same program.
In a further variation on this embodiment, the two graphs represent programs that perform image-conversion operations on images.
In a further variation, the system displays the execution results of the two graphs simultaneously to facilitate a side-by-side comparison.
In a further variation, the system displays the execution results of the two graphs in an overlaid manner to facilitate an overlay comparison.
The following description is presented to enable any person skilled in the art to make and use the invention, and is provided in the context of a particular application and its requirements. Various modifications to the disclosed embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other embodiments and applications without departing from the spirit and scope of the present invention. Thus, the present invention is not limited to the embodiments shown, but is to be accorded the widest scope consistent with the claims.
The data structures and code described in this detailed description are typically stored on a computer-readable storage medium, which may be any device or medium that can store code and/or data for use by a computer system. This includes, but is not limited to, magnetic and optical storage devices such as disk drives, magnetic tape, CDs (compact discs), DVDs (digital versatile discs or digital video discs), or any device capable of storing data usable by a computer system.
Processor 102 can include any type of processor, including, but not limited to, a microprocessor, a mainframe computer, a digital signal processor, a personal organizer, a device controller and a computational engine within an appliance. Processor 102 includes a cache 104 that stores code and data for execution by processor 102.
Processor 102 communicates with storage device 108 through bridge 106 and peripheral bus 110. Storage device 108 can include any type of non-volatile storage device that can be coupled to a computer system. This includes, but is not limited to, magnetic, optical, and magneto-optical storage devices, as well as storage devices based on flash memory and/or battery-backed up memory.
Processor 102 communicates with memory 112 through bridge 106. Memory 112 can include any type of memory that can store code and data for execution by processor 102.
As illustrated in
Note that although the present invention is described in the context of computer system 100 as illustrated in
In a node-based GPL, a “node” refers to a base processing unit in a GPL, such as a subroutine or a function. A set of interconnected nodes in a GPL forms a “program graph” (or simply a “graph”) that represents a program. During a graphical programming operation, a programmer typically creates a graph by dragging nodes associated with different functions into a workspace and making connections between the nodes. Note that generally both nodes and graphs are executable programs.
Note that the value on an input port of a node can be set directly by connecting the output of an upstream node to the input port. Connections between input and output ports of different nodes establish a data flow in the graph structure. Note that a connection is made between ports that have compatible data types. Hence, if two ports are of different types, a type conversion operation is needed between the two ports before they can be connected.
Note that the value of an input/output port of a node in the specification is broadly defined to include different types of data objects, which can include, but are not limited to a number, a string or a bitmap. In one embodiment of the present invention, an input port value is an image.
Note that if a node in graph 200 is moved around within the two-dimensional (2D) space of editor window 208 without changing any of the connections associated with the node, both the structure and the function of graph 200 do not change.
Displaying Two Program Graphs within the Same Editor Window
Embodiments of the present invention facilitate displaying two program graphs within the same editor window for comparison purposes. In one embodiment of the present invention, the two graphs represent two versions of the same program. By displaying the two versions of the program side by side within the same editor window, it becomes easier to distinguish the differences between the two graphs.
Specifically,
Note that displaying two graphs in the same editor window enables the user to interact with both graphs for comparison purposes. For example, the user can remove node 214 in both graphs and can then compare the effects on the outputs.
Identifying and Highlighting Differences between the Two Graphs
As mentioned previously, two graphs having different (2D) layouts may not be structurally different. Hence, when comparing two graphs having complex structures, it is desirable to highlight all the differences between the two graphs.
In one embodiment of the present invention, the system identifies “unique nodes” in each of the two graphs that are being compared in the same editor window. A unique node refers to a node in one graph that is not identical to any other node in the other graph. Specifically, the system identifies a first node in the first graph and a second node in the second graph which have the same identifier. In one embodiment, this identifier is a unique key assigned to the node when the node is first created. If the first and second nodes have the same identifier, the system next determines if the two nodes are different by determining if: (1) the first and second nodes have at least one connection which is different; or (2) the first and second nodes have at least one internal parameter setting which is different.
Note that during step (1) the connectivity difference is examined from both the input port side and the output port side of a node. For example, in
If either step (1) or step (2) is determined to be true, the system determines that the first node and second nodes are different, and subsequently identifies both nodes as unique nodes.
In a further embodiment of the present invention, the system identifies unique nodes in each of the two graphs by determining if a node in the first graph has an identifier (e.g., a key) which does not match an identifier for a node in the second graph or vice versa. If so, the system determines that the node is a unique node.
Note that the process of identifying unique nodes in each of the two graphs being compared is not limited to the techniques described above. Any other technique that can identify nodes in one graph that do not have identical counterparts in the other graph is applicable herein.
In one embodiment of the present invention, the identified unique nodes in the two compared graphs are highlighted with the corresponding graph. This facilitates visualizing all the differences between the two graphs. In one embodiment, the system highlights the unique nodes by displaying these unique nodes in a color that indicates they are different from other node.
Note that in addition to displaying the rendering results of the two graphs simultaneously to facilitate a side-by-side comparison, embodiments of the present invention also provide an option to display the rendering results of the two graphs in an overlaid manner to facilitate an overlay comparison. This option is illustrated in
The foregoing descriptions of embodiments of the present invention have been presented only for purposes of illustration and description. They are not intended to be exhaustive or to limit the present invention to the forms disclosed. Accordingly, many modifications and variations will be apparent to practitioners skilled in the art. Additionally, the above disclosure is not intended to limit the present invention. The scope of the present invention is defined by the appended claims.