• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // (C) Copyright 2009 Andrew Sutton
2 //
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)
6 
7 #ifndef TEST_ITERATION_HPP
8 #define TEST_ITERATION_HPP
9 
10 #include <boost/concept/assert.hpp>
11 #include <algorithm>
12 
13 /** @name Test Vertex List
14  * Test the vertex list interface. Note that there are currently no graphs that
15  * do not expose this interface.
16  */
17 //@{
test_vertex_list_graph(Graph const & g)18 template < typename Graph > void test_vertex_list_graph(Graph const& g)
19 {
20     using namespace boost;
21     BOOST_CONCEPT_ASSERT((VertexListGraphConcept< Graph >));
22 
23     std::cout << "...test_vertex_list_graph\n";
24     typedef typename graph_traits< Graph >::vertex_iterator Iterator;
25     typedef std::pair< Iterator, Iterator > Range;
26 
27     Range rng = vertices(g);
28     BOOST_ASSERT(num_vertices(g) == N);
29     BOOST_ASSERT(rng.first != rng.second);
30     BOOST_ASSERT(std::distance(rng.first, rng.second) == int(N));
31 }
32 //@}
33 
34 /** @name Test Edge List
35  * Test the edge list interface. Note that there are currently no graphs that
36  * do not expose this interface.
37  */
38 //@{
test_edge_list_graph(Graph const & g)39 template < typename Graph > void test_edge_list_graph(Graph const& g)
40 {
41     using namespace boost;
42     BOOST_CONCEPT_ASSERT((EdgeListGraphConcept< Graph >));
43 
44     std::cout << "...test_edge_list_graph\n";
45     typedef typename graph_traits< Graph >::edge_iterator Iterator;
46     typedef std::pair< Iterator, Iterator > Range;
47 
48     Range rng = edges(g);
49     BOOST_ASSERT(num_edges(g) == M);
50     BOOST_ASSERT(rng.first != rng.second);
51     BOOST_ASSERT(std::distance(rng.first, rng.second) == int(M));
52 }
53 //@}
54 
55 #endif
56