]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | //======================================================================= |
f67539c2 | 2 | // Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee, |
7c673cae FG |
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 <boost/config.hpp> | |
9 | #include <vector> | |
10 | #include <iostream> | |
11 | #include <boost/graph/strong_components.hpp> | |
12 | #include <boost/graph/adjacency_list.hpp> | |
13 | ||
f67539c2 | 14 | int main() |
7c673cae | 15 | { |
f67539c2 TL |
16 | using namespace boost; |
17 | typedef adjacency_list< vecS, vecS, directedS > Graph; | |
18 | const int N = 6; | |
19 | Graph G(N); | |
20 | add_edge(0, 1, G); | |
21 | add_edge(1, 1, G); | |
22 | add_edge(1, 3, G); | |
23 | add_edge(1, 4, G); | |
24 | add_edge(3, 4, G); | |
25 | add_edge(3, 0, G); | |
26 | add_edge(4, 3, G); | |
27 | add_edge(5, 2, G); | |
7c673cae | 28 | |
f67539c2 TL |
29 | std::vector< int > c(N); |
30 | int num = strong_components( | |
31 | G, make_iterator_property_map(c.begin(), get(vertex_index, G), c[0])); | |
7c673cae | 32 | |
f67539c2 TL |
33 | std::cout << "Total number of components: " << num << std::endl; |
34 | std::vector< int >::iterator i; | |
35 | for (i = c.begin(); i != c.end(); ++i) | |
36 | std::cout << "Vertex " << i - c.begin() << " is in component " << *i | |
37 | << std::endl; | |
38 | return EXIT_SUCCESS; | |
7c673cae | 39 | } |