Edge and VisualEdge Insertion

In this section, you will learn how to add two Edge instances to a Graph instance and two VisualEdge instances to a VisualGraph instance.

Edge Insertion

A Graph instance understands the add method because it is derived from the GraphObjectContainer interface.

Example 3.6. Inserting an Edge instance

graphModel.addEdge(edgeAB);
graphModel.addEdge(edgeAC);

VisualEdge Insertion

If you are using the ModelBasedGraphController class with your Graph model, VisualEdge objects are created and inserted into your view the moment they are created in the model. For this reason, you are not required to create them explicitly, unless of course you are using another type of graph controller which does not support this behavior. Please read the MVC chapter for more details about other GraphController implementations which require you to explicitly insert VisualEdge objects into your view.