How to get an unique identifier for an edge

Hi, I tried to get an unique identifier for a node and an edge. The node is possible e.g.: adjacency_list<> someGraph; std::pair<adjacency_list<>::vertex_iterator,adjacency_list<>::vertex_iterator> p; ed = add_edge(0,1, someGraph); property_map< adjacency_list<> , vertex_index_t>::type in; in = get(vertex_index_t(), someGraph); for (p = vertices(processGraph); p.first != p.second ; ++p.first) { cout << *p.first << "\n"; cout << "index: " << in[*p.first] << " \n"; } However, the same idee does not work for an edge: std::pair<adjacency_list<>::edge_iterator,adjacency_list<>::edge_iterator> pe; property_map< adjacency_list<> , edge_index_t>::type inedge; inedge = get(edge_index_t(), processGraph); for (pe = edges(someGraph); pe.first != pe.second; ++pe.first) { cout << *pe.first << " "; cout << "index: " << inedge[*pe.first] << " \n"; } I can not figure out how to get an unique id for an edge and I can not understand how the property maps works from the documentation nor I can find how such a edge_index_t property is defined. Can somebody provide some help. With kind regards, Lodewijk __________________________________ Do you Yahoo!? Yahoo! Small Business $15K Web Design Giveaway http://promotions.yahoo.com/design_giveaway/

Hi Lodewijk,
I tried to get an unique identifier for a node and an edge. The node is possible e.g.:
However, the same idee does not work for an edge:
std::pair<adjacency_list<>::edge_iterator,adjacency_list<>::edge_iterator> pe; property_map< adjacency_list<> , edge_index_t>::type inedge; inedge = get(edge_index_t(), processGraph); for (pe = edges(someGraph); pe.first != pe.second; ++pe.first) { cout << *pe.first << " "; cout << "index: " << inedge[*pe.first] << " \n"; }
I can not figure out how to get an unique id for an edge and I can not understand how the property maps works from the documentation nor I can find how such a edge_index_t property is defined. Can somebody provide some help.
The reason is that vertex_index_t property is automatically defined for adjacency_list<>. It's not the case for edge_vertex_t. You'd have to: adjacency_list<vecS, vecS, directedS, no_property, property<edge_index_t, unsigned> > g; unsigned index(0); ...edge_iterator i, e; for(tie(i, e) = edges(i, e); i != e; ++i, ++index) put(edge_index, process_graph, *i, index); In other words, you have initialize and maintain edge_index property yourself. HTH, Volodya

Lodewijk Smit <lodewijk_smit@yahoo.com> writes:
Hi,
I tried to get an unique identifier for a node and an edge. The node is possible e.g.:
Hint: there are lots of boost libraries. You'll often get better response if you add some more context to your subject line, e.g.: Subject: [Graph] How to get an unique identifier for an edge -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (3)
-
David Abrahams
-
Lodewijk Smit
-
Vladimir Prus