Get specific edge with boost::graph

Amir Rachum picture Amir Rachum · Jan 19, 2011 · Viewed 11.5k times · Source

I'm using boost::graph and I have two vertex_descriptors. What is the quickest way to get the edge between them, without iterating over all the edges?

Answer

Amir Rachum picture Amir Rachum · Jan 19, 2011

Ok, I found it out. boost::edge(u,v,g) returns pair<edge_descriptor, bool> where the bool is whether the edge exists. So in my case I know it does, so I use the expression:

boost::edge(u,v,g).first