Get specific edge with boost::graph
-
12-10-2019 - |
Pergunta
I'm using boost::graph
and I have two vertex_descriptor
s. What is the quickest way to get the edge between them, without iterating over all the edges?
Solução
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
Outras dicas
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.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow