开发者

Why can't I use boost graph write_graphviz with OutEdgeList=listS and VertexList=listS

Why can't I compile the following simple app. If I changes listS to vecS every thing works just fine. (I'am using boost 1.46.1 and gcc 4.4.5)

#include <iostream>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graphviz.hpp>

int main(int ar开发者_C百科gc, const char *argv[]) {
    boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS > g;

    boost::write_graphviz(std::cout, g);

    return 0;
}


write_graphviz needs the vertex_id property to display vertex identifier labels. An adjacency_list that uses listS as the vertex container does not automatically provide this vertex_id property. This behavior makes sense, because in a linked list, there is no such thing as a key or index that can be used to uniquely identify an element. Remember that a linked list is neither a random-access sequence, nor an associative container.

You'll either have to supply your own vertex_id property getter, or use a vertex container that has an inherent vertex_id property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜