// (C) Copyright Andrew Sutton 2009 // // Use, modification and distribution are subject to the // Boost Software License, Version 1.0 (See accompanying file // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) #include #include #include using namespace boost; // TODO: Integrate this into a larger adj_list test suite. template void test_graph_nonloop() { typedef typename graph_traits::vertex_descriptor Vertex; // Build a graph with 1 edge and turn it into a loop. Graph g(5); Vertex u = *vertices(g).first; Vertex v = *next(vertices(g).first, 2); add_edge(u, v, g); BOOST_ASSERT(num_vertices(g) == 5); BOOST_ASSERT(num_edges(g) == 1); remove_edge(u, v, g); BOOST_ASSERT(num_edges(g) == 0); } template void test_multigraph_nonloop() { typedef typename graph_traits::vertex_descriptor Vertex; // Build a graph with 1 edge and turn it into a loop. Graph g(5); Vertex u = *vertices(g).first; Vertex v = *next(vertices(g).first, 2); add_edge(u, v, g); add_edge(u, v, g); BOOST_ASSERT(num_vertices(g) == 5); BOOST_ASSERT(num_edges(g) == 2); remove_edge(u, v, g); BOOST_ASSERT(num_edges(g) == 0); } template void test_graph_loop() { typedef typename graph_traits::vertex_descriptor Vertex; Graph g(5); Vertex v = *next(vertices(g).first, 2); add_edge(v, v, g); BOOST_ASSERT(num_vertices(g) == 5); BOOST_ASSERT(num_edges(g) == 1); remove_edge(v, v, g); BOOST_ASSERT(num_edges(g) == 0); } template void test_multigraph_loop() { typedef typename graph_traits::vertex_descriptor Vertex; Graph g(5); Vertex v = *next(vertices(g).first, 2); add_edge(v, v, g); add_edge(v, v, g); BOOST_ASSERT(num_vertices(g) == 5); BOOST_ASSERT(num_edges(g) == 2); remove_edge(v, v, g); BOOST_ASSERT(num_edges(g) == 0); } template void test() { typedef no_property na; typedef adjacency_list VVL; typedef adjacency_list LVL; typedef adjacency_list SVL; typedef adjacency_list MVL; test_graph_nonloop(); test_graph_nonloop(); test_graph_nonloop(); test_graph_nonloop(); test_multigraph_nonloop(); test_multigraph_nonloop(); test_multigraph_nonloop(); test_graph_loop(); test_graph_loop(); test_graph_loop(); test_graph_loop(); test_multigraph_loop(); test_multigraph_loop(); test_multigraph_loop(); } int main() { test(); test(); test(); return 0; }