How to get a node with index n in Lemon Graph Library?

1.4k Views Asked by At

When I build a graph g with this code:

ListDigraph g;

for (int i = 0; i < 7; ++i)
  g.addNode();

its nodes will have indexes {0..6}, which I tested by calling g.id() on them. How can I get a node by using its index? For example, I would like to add an arc to g by calling:

g.addArc(<node n>, <node m>);
1

There are 1 best solutions below

0
On

It can be done with nodeFromId member function, see Graph Class Reference:

g.addArc(g.nodeFromId(n), g.nodeFromId(m));