如何在柠檬中找到节点的邻居

zen*_*nna 5 c++ graph

在 Lemon C++ Graph Library 中,给定一个无向图中的节点,比如说,如何找到其他边连接的节点?

ric*_*chj 6

即使我对 C++ 生疏并且以前没有使用过 Lemon,我也会尝试一下:

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.
    ...
}
Run Code Online (Sandbox Code Playgroud)

我用过这个: LEMON——一个开源的 C++ 图形模板库

...还有这个: LEMON:图形类参考

...多年来,我在图论方面做了相当多的工作。

我希望它有帮助。