Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get specific edge with boost::graph

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?

like image 554
Amir Rachum Avatar asked Jan 19 '11 11:01

Amir Rachum


2 Answers

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
like image 107
Amir Rachum Avatar answered Nov 02 '22 22:11

Amir Rachum


There is also a function boost::lookup_edge() in boost/graph/lookup_edge.hpp; that function dispatches to either edge() or out_edges() and a search based on the particular graph type you are using.

like image 44
Jeremiah Willcock Avatar answered Nov 03 '22 00:11

Jeremiah Willcock