Edge_index zero for all edges?

By defining my boost::graph as shown below, I get edge indices for all edges. What for? What am I doing wrong?

 #include <iostream> #include <boost/graph/adjacency_list.hpp> int main() { typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, boost::no_property, boost::property<boost::edge_index_t, std::size_t> > Graph; typedef boost::graph_traits<Graph>::edge_descriptor Edge; Graph g(3); Edge e1 = boost::add_edge(0, 1, g).first; Edge e2 = boost::add_edge(1, 2, g).first; Edge e3 = boost::add_edge(2, 0, g).first; boost::property_map<Graph, boost::edge_index_t>::type eim = boost::get(boost::edge_index, g); size_t e1n = eim[e1], e2n = eim[e2], e3n = eim[e3]; return 0; } 

As far as I can tell from the docs and examples, this should work.

+2
source share
1 answer

The adjacency_list does not have an edge index associated with it, but only the vertex index. Which is logical when you think about how the graph is stored.

To have an edge index, you need to manually add it to the description of the graph, and then manually process it.

+4
source

All Articles