- I am trying to use the boost graph library in C++* I want to create a topological sort for my graph. However the output I want on my graph is the actual names of the vertex, not the number positions. For example on the following example I get the following output: A topological ordering: 45 40 41 34 35 33 43 30 31 36 32 26 27 25 23 24 19 46 47 18 48 17 20 21 49 50 16 51 15 44 14 22 42 13 37 38 9 11 28 29 12 7 39 6 8 5 10 3 4 0 2 1
Those values are the positions of the vertex, but I would rather have the name of the vertex. Does anyone know how to do this? Here is a short version of my program:
typedef boost::adjacency_list<vecS, vecS, directedS,
property<vertex_name_t, std::string>,
property<edge_weight_t, int> > Graph;
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
typedef std::vector< Vertex > container;
Graph g;
BOOST_CHECK(read_graphviz(in, g, dp, "id"));
container c;
topological_sort(g, std::back_inserter(c));
std::cout << "A topological ordering: ";
for ( container::reverse_iterator ii=c.rbegin(); ii!=c.rend(); ++ii)
std::cout <<*ii<<" ";
std:: cout <<std::endl;