]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/test/adj_list_loops.cpp
1 // (C) Copyright Andrew Sutton 2009
3 // Use, modification and distribution are subject to the
4 // Boost Software License, Version 1.0 (See accompanying file
5 // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
9 #include <boost/assert.hpp>
10 #include <boost/graph/adjacency_list.hpp>
12 using namespace boost
;
14 // TODO: Integrate this into a larger adj_list test suite.
16 template <typename Graph
>
17 void test_graph_nonloop()
19 typedef typename graph_traits
<Graph
>::vertex_descriptor Vertex
;
21 // Build a graph with 1 edge and turn it into a loop.
23 Vertex u
= *vertices(g
).first
;
24 Vertex v
= *next(vertices(g
).first
, 2);
26 BOOST_ASSERT(num_vertices(g
) == 5);
27 BOOST_ASSERT(num_edges(g
) == 1);
29 BOOST_ASSERT(num_edges(g
) == 0);
34 template <typename Graph
>
35 void test_multigraph_nonloop()
37 typedef typename graph_traits
<Graph
>::vertex_descriptor Vertex
;
39 // Build a graph with 1 edge and turn it into a loop.
41 Vertex u
= *vertices(g
).first
;
42 Vertex v
= *next(vertices(g
).first
, 2);
45 BOOST_ASSERT(num_vertices(g
) == 5);
46 BOOST_ASSERT(num_edges(g
) == 2);
48 BOOST_ASSERT(num_edges(g
) == 0);
52 template <typename Graph
>
53 void test_graph_loop()
55 typedef typename graph_traits
<Graph
>::vertex_descriptor Vertex
;
58 Vertex v
= *next(vertices(g
).first
, 2);
60 BOOST_ASSERT(num_vertices(g
) == 5);
61 BOOST_ASSERT(num_edges(g
) == 1);
63 BOOST_ASSERT(num_edges(g
) == 0);
66 template <typename Graph
>
67 void test_multigraph_loop()
69 typedef typename graph_traits
<Graph
>::vertex_descriptor Vertex
;
72 Vertex v
= *next(vertices(g
).first
, 2);
75 BOOST_ASSERT(num_vertices(g
) == 5);
76 BOOST_ASSERT(num_edges(g
) == 2);
78 BOOST_ASSERT(num_edges(g
) == 0);
81 template <typename Kind
>
84 typedef no_property na
;
85 typedef adjacency_list
<vecS
, vecS
, Kind
, na
, na
, na
, listS
> VVL
;
86 typedef adjacency_list
<listS
, vecS
, Kind
, na
, na
, na
, listS
> LVL
;
87 typedef adjacency_list
<setS
, vecS
, Kind
, na
, na
, na
, listS
> SVL
;
88 typedef adjacency_list
<multisetS
, vecS
, Kind
, na
, na
, na
, listS
> MVL
;
90 test_graph_nonloop
<VVL
>();
91 test_graph_nonloop
<LVL
>();
92 test_graph_nonloop
<SVL
>();
93 test_graph_nonloop
<MVL
>();
94 test_multigraph_nonloop
<VVL
>();
95 test_multigraph_nonloop
<LVL
>();
96 test_multigraph_nonloop
<MVL
>();
97 test_graph_loop
<VVL
>();
98 test_graph_loop
<LVL
>();
99 test_graph_loop
<SVL
>();
100 test_graph_loop
<MVL
>();
101 test_multigraph_loop
<VVL
>();
102 test_multigraph_loop
<LVL
>();
103 test_multigraph_loop
<MVL
>();
111 test
<bidirectionalS
>();