Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 argc, const char *argv[]) {
    boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS > g;

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

    return 0;
}
like image 989
Allan Avatar asked Apr 25 '11 17:04

Allan


1 Answers

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.

like image 71
Emile Cormier Avatar answered Oct 23 '22 18:10

Emile Cormier