There are a couple of ways to do this.
1) Just check the out-edges for all that go to the desired target:
boost::graph_traits<Graph_t>::out_edge_iterator ei, ei_end;
boost::tie(ei, ei_end) = out_edges( node1, myGraph );
int parallel_count = 0;
for( ; ei != ei_end; ++ei) {
if( target(*ei, myGraph) == node2 ) {
cout << "Found edge (node1, node2) with property: " << myGraph[*ei] << endl;
++parallel_count;
};
};
cout << "There are a total of " << parallel_count << " parallel edges." << endl;
2) Specify boost::multisetS
as the OutEdgeListS
template argument to adjacency_list
, this will enable an extra function called edge_range
which returns a range of iterators for all the "parallel" edges coming out of u
and going into v
, as the documentation page states:
std::pair<out_edge_iterator, out_edge_iterator> edge_range(vertex_descriptor u, vertex_descriptor v, const adjacency_list& g)
Returns a pair of out-edge iterators that give the range for all the parallel edges from u to v. This function only works when the OutEdgeList for the adjacency_list is a container that sorts the out edges according to target vertex, and allows for parallel edges. The multisetS selector chooses such a container.
The reason why this function is only available for multisetS
is because in order to provide (easily) a range of iterators to parallel edges, you need the edges to be grouped together, which is the case for multisetS
because they are sorted by vertex-descriptor, and therefore, all parallel out-edges are grouped together. That's the only container choice that will give you this, otherwise, you have to use option (1) (note: creating a filter_iterator
(see docs) could come in handy if you really use this a lot).