#define BOOST_TEST_MODULE graph #include #include typedef boost::undirected_graph<> Graph; typedef Graph::edge_descriptor Edge; typedef Graph::vertex_descriptor Vertex; BOOST_AUTO_TEST_CASE(undirected_edge_test) { Graph g(2); Vertex a = *(vertices(g).first); Vertex b = *(++vertices(g).first); Edge e1, e2; bool r1, r2; // Create the edge. This is an undirected edge. add_edge(a, b, g); tie(e1, r1) = boost::edge(a, b, g); tie(e2, r2) = boost::edge(b, a, g); BOOST_CHECK(r1); BOOST_CHECK(r2); BOOST_CHECK(num_edges(g) == 1); // Edges e1 and e2 are the same. BOOST_CHECK(e1 == e2); // Yet, BGL can tell what the source and target nodes are are, and // they are different for e1 and e2. BOOST_CHECK(boost::source(e1, g) == a); BOOST_CHECK(boost::target(e1, g) == b); BOOST_CHECK(boost::source(e2, g) == b); BOOST_CHECK(boost::target(e2, g) == a); }