Connecting nodes with hyperedges

To connect multiple nodes by a hyperedge, you must create the nodes and add them to the hypergraph. This works in IlvHyperGrapher exactly in the same way as in IlvGrapher.
To add a node:
  • Call one of the following methods:
    • void addNode(IlvGraphic obj, boolean redraw)
To connect several nodes by a hyperedge:
  1. Create the hyperedge.
    The constructor of the hyperedge is:
    While the constructor of IlvLinkImage takes only one node as the from or the to node, the constructor of IlvHyperEdge takes a vector of nodes as from and to nodes.
  2. Add the hyperedge to the hypergraph with one of the following methods:
    • The layer parameter in the second method specifies the manager layer where the hyperedge is placed. If the layer parameter is missing, the link insertion layer, which is obtained by using the method getLinkInsertionLayer() , is used to place the hyperedge.
The following code example shows how to create a hypergraph, four nodes, and a hyperedge.
Creating a hypergraph with four nodes and a hyperedge
IlvHyperGrapher grapher = new IlvHyperGrapher();
IlvGraphicVector fromNodes = new IlvGraphicVector();
IlvGraphicVector toNodes = new IlvGraphicVector();
IlvGraphic node1 = new IlvLabel(new IlvPoint(0,0), "node 1");
IlvGraphic node2 = new IlvLabel(new IlvPoint(100,0), "node 2");
IlvGraphic node3 = new IlvLabel(new IlvPoint(100,30), "node 3");
IlvGraphic node4 = new IlvLabel(new IlvPoint(100,60), "node 4");
grapher.addNode(node1, false);
grapher.addNode(node2, false);
grapher.addNode(node3, false);
grapher.addNode(node4, false);
fromNodes.addElement(node1);
toNodes.addElement(node2);
toNodes.addElement(node3);
toNodes.addElement(node4);
IlvHyperEdge edge = new IlvHyperEdge(fromNodes, toNodes);
grapher.addHyperEdge(edge, false);