|
Last change
on this file since 30 was
29,
checked in by landauf, 17 years ago
|
|
updated boost from 1_33_1 to 1_34_1
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | //======================================================================= |
|---|
| 2 | // Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee, |
|---|
| 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 | |
|---|
| 14 | int |
|---|
| 15 | main() |
|---|
| 16 | { |
|---|
| 17 | using namespace boost; |
|---|
| 18 | typedef adjacency_list < vecS, vecS, directedS > Graph; |
|---|
| 19 | const int N = 6; |
|---|
| 20 | Graph G(N); |
|---|
| 21 | add_edge(0, 1, G); |
|---|
| 22 | add_edge(1, 1, G); |
|---|
| 23 | add_edge(1, 3, G); |
|---|
| 24 | add_edge(1, 4, G); |
|---|
| 25 | add_edge(3, 4, G); |
|---|
| 26 | add_edge(3, 0, G); |
|---|
| 27 | add_edge(4, 3, G); |
|---|
| 28 | add_edge(5, 2, G); |
|---|
| 29 | |
|---|
| 30 | std::vector<int> c(N); |
|---|
| 31 | int num = strong_components |
|---|
| 32 | (G, make_iterator_property_map(c.begin(), get(vertex_index, G), c[0])); |
|---|
| 33 | |
|---|
| 34 | std::cout << "Total number of components: " << num << std::endl; |
|---|
| 35 | std::vector < int >::iterator i; |
|---|
| 36 | for (i = c.begin(); i != c.end(); ++i) |
|---|
| 37 | std::cout << "Vertex " << i - c.begin() |
|---|
| 38 | << " is in component " << *i << std::endl; |
|---|
| 39 | return EXIT_SUCCESS; |
|---|
| 40 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.