Node and VisualNode Insertion

In this section, you will learn how to add two Node instances to a Graph instance and two VisualNode instances to a VisualGraphView instance.

Node Insertion

Example 3.4. Adding two Node instances to a Graph

// add nodes to graph
graphModel.addNode(nodeA);
graphModel.addNode(nodeB);
graphModel.addNode(nodeC);

The example above is quite trivial. All you do is tell the graph to add nodes using the addNode(Node) method, which is part of the more abstract interface GraphObjectContainer.

VisualNode Insertion

If you are using the ModelBasedGraphController class with your Graph model, VisualNode 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 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 VisualNode objects into your view.