]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/example/make_connected.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / graph / example / make_connected.cpp
1 //=======================================================================
2 // Copyright 2007 Aaron Windsor
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //=======================================================================
8 #include <iostream>
9 #include <boost/graph/adjacency_list.hpp>
10 #include <boost/graph/properties.hpp>
11 #include <boost/graph/graph_traits.hpp>
12 #include <boost/property_map/property_map.hpp>
13 #include <vector>
14
15 #include <boost/graph/connected_components.hpp>
16 #include <boost/graph/make_connected.hpp>
17
18
19
20 using namespace boost;
21
22 int main(int argc, char** argv)
23 {
24
25 typedef adjacency_list
26 < vecS,
27 vecS,
28 undirectedS,
29 property<vertex_index_t, int>
30 >
31 graph;
32
33 graph g(11);
34 add_edge(0,1,g);
35 add_edge(2,3,g);
36 add_edge(3,4,g);
37 add_edge(5,6,g);
38 add_edge(6,7,g);
39 add_edge(8,9,g);
40 add_edge(9,10,g);
41 add_edge(10,8,g);
42
43 std::vector< graph_traits<graph>::vertices_size_type >
44 component(num_vertices(g));
45
46 std::cout << "Before calling make_connected, the graph has "
47 << connected_components(g, &component[0])
48 << " connected components" << std::endl;
49
50 make_connected(g);
51
52 std::cout << "After calling make_connected, the graph has "
53 << connected_components(g, &component[0])
54 << " connected components" << std::endl;
55
56 return 0;
57 }