5

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;
}
Allan
  • 4,562
  • 8
  • 38
  • 59

1 Answers1

6

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.

Emile Cormier
  • 28,391
  • 15
  • 94
  • 122