/* * bug_edge_range.cpp * * Created by Michael Olea on 4/2/09. * * (formatted with tabstops = 4) * */ #include #include #include #include "boost/graph/adjacency_list.hpp" #include template int count_parallel_edges(typename G::vertex_descriptor u, typename G::vertex_descriptor v, const G& g) { typedef typename G::out_edge_iterator iter; std::pair range = boost::edge_range(u, v, g); return std::distance(range.first, range.second); } int main() { using namespace boost; typedef adjacency_list bi_graph_t; typedef adjacency_list u_graph_t; typedef adjacency_list d_graph_t; enum { A, B, C, D, E, N }; const int num_vertices = N; const char* name = "ABCDE"; typedef std::pair Edge; Edge edge_array[] = { Edge(A,B), Edge(A,D), Edge(A, D), Edge(A, D), Edge(C,A), Edge(D,C), Edge(C,E), Edge(B,D), Edge(D,E) }; const int num_edges = sizeof(edge_array)/sizeof(edge_array[0]); bi_graph_t g1(edge_array, edge_array + num_edges, num_vertices); u_graph_t g2(edge_array, edge_array + num_edges, num_vertices); d_graph_t g3(edge_array, edge_array + num_edges, num_vertices); std::cout << "g1:\n"; print_graph(g1, name); std::cout << "\ng2:\n"; print_graph(g2, name); std::cout << "\ng3:\n"; print_graph(g3, name); std::cout << "\ng1 number of (A, D) edges: " << count_parallel_edges(A, D, g1) << '\n'; std::cout << "g2 number of (A, D) edges: " << count_parallel_edges(A, D, g2) << '\n'; // std::cout << "g3 number of (A, D) edges: " << count_parallel_edges(A, D, g3) << '\n'; // the line above does not compile. return 0; }