c++ - boost graph library directed multigraph edge_range bug -


i have directed multigraph vertices a..c , edges e1..e4

a ---e1--> b ---e2--> b ---e3--> b b ---e4--> c 

i wanted iterate on edges connect , b.

in bgl, expressed as:

#include <boost/graph/adjacency_list.hpp>  struct vertex {   std::string code; };  struct edge {   double distance;   std::string code; };  int main() {   using namespace boost;   typedef adjacency_list<lists, vecs, directeds, vertex, edge> graph;   graph g;   auto a= add_vertex(vertex{ "a" }, g);   auto b= add_vertex(vertex{ "b" }, g);   auto c= add_vertex(vertex{ "c" }, g);   add_edge(a, b, edge{ 10, "e1" }, g);   add_edge(a, b, edge{ 10, "e2" }, g);   add_edge(a, b, edge{ 10, "e3" }, g);   add_edge(a, c, edge{ 10, "e4" }, g);    // checking number of edges   std::cout<< num_edges(g)<< std::endl;    // printing edges branching   auto erange= out_edges(a, g);   for(auto i= erange.first; i!= erange.second; ++ i)     std::cout<< g[*i].code<< std::endl;    // want iterate on edges connect , b   auto wtf= boost::edge_range(a, b, g); } 

which results in compilation error:

in file included /usr/include/boost/graph/adjacency_list.hpp:246: /usr/include/boost/graph/detail/adjacency_list.hpp:1617:25: error: no matching constructor initialization of 'storededge' (aka       'boost::detail::stored_edge_property<unsigned long, edge>')         equal_range(el, storededge(v, fake_edge_container.end(),                     ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

i've read documentation:

std::pair<out_edge_iterator, out_edge_iterator> edge_range(vertex_descriptor u, vertex_descriptor v, const adjacency_list& g) returns pair of out-edge iterators give range parallel edges u v. function works when outedgelist adjacency_list container sorts out edges according target vertex, , allows parallel edges. multisets selector chooses such container.

( http://www.boost.org/doc/libs/1_54_0/libs/graph/doc/adjacency_list.html )

modified graph:

typedef adjacency_list<multisets, vecs, directeds, vertex, edge> graph; 

but error did not change.

so how list edges between 2 vertices (from-> to) in directed multigraph using bgl ?

i found quick , dirty way:

auto erange= out_edges(a, g);$ for(auto i= erange.first; i!= erange.second; ++ i)$   std::cout<< g[*i].code<< " -> "<< g[target(*i, g)].code<< std::endl;$ 

which let me filter edge target vertex. how use boost::edge_range ?

this bug has been reported before on boost mailinglist.

it fails compile when directed selector template argument adjacency_list set directeds, work if argument either undirecteds, or bidirectionals. attached below short program illustrating problem. problem edge_range() instantiates storededge via constructor taking 3 arguments, when directed selector directeds storededge typedef'ed stored_edge_property, has no such constructor. 1 solution might create overloaded edge_range_dispatch() functions, , dispatch on
config::on_edge_storage.

changing directeds undirecteds in program works. live example. might not need application, simple filter mentioned before might better. repost on boost mailinglist more attention it.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -