Edge and VisualEdge Creation

In this section, you will learn how to create an Edge instance and a VisualEdge instance.

Edge Creation

The word Edge comes from graph theory and is used to describe the association between two nodes. Link, connection, arc, transition and other domain-specific words are used to describe this association object as well.

In the true mathematical meaning, an edge must be connected to two nodes at all times. Isolated edges - those with one or no connected nodes - may exist in a visual graph only and are denoted as such. This means that isolated edges are not part of any graph model.

Example 3.5. Creating an Edge instance

// create edges and add them to the graph
edgeAB= modelFactory.newEdge(nodeA, nodeB);
edgeAC= modelFactory.newEdge(nodeA, nodeC);

In the example above, creating a new Edge instance is trivial yet consistent with all other creational methods in this framework - via factory.

VisualEdge Creation

VisualEdge instances do not have to be created explicitly. If you are using the ModelBasedGraphController class, visual edges are automatically created and inserted into a VisualGraphView the moment you create Edge instances in the model.