5

In the Lemon C++ Graph Library, given a node in an undirected graph say, how does one find other nodes that are edge connected?

rici
  • 234,347
  • 28
  • 237
  • 341
zenna
  • 9,006
  • 12
  • 73
  • 101

1 Answers1

7

I'll have a go at this even though I'm rusty with C++ and haven't used Lemon before:

for (ListDigraph::OutArcIt arcIt(graph, node); arcIt != INVALID; ++arcIt) {

    Arc arc(*arcIt); // Lemon iterators are supposed to be convertible to items
                     // without operator*, so arc(a) might work too.

    Node oppositeNode( g.oppositeNode(node, arc) );

    // Do something with the opposite node.
    ...
}

I used this: LEMON -- an Open Source C++ Graph Template Library

... and this: LEMON: Graph Class Reference

... and I've done a reasonable amount of work with graph theory over the years.

I hope it helps.

richj
  • 7,499
  • 3
  • 32
  • 50
  • 1
    Thanks, it was actually IncEdgeIt that I was looking for which is the equivalent for undirected graphs, but you put me on the right path and stopped some serious hair-pulling-out – zenna Aug 26 '10 at 13:51