]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | //======================================================================= | |
92f5a8d4 TL |
8 | |
9 | /* | |
10 | IMPORTANT!!! | |
11 | ~~~~~~~~~~~~ | |
12 | This example uses interfaces that have been deprecated and removed from Boost.Grpah. | |
13 | Someone needs to update it, as it does NOT compile. | |
14 | */ | |
15 | ||
7c673cae FG |
16 | #include <boost/config.hpp> |
17 | #include <fstream> | |
18 | #include <vector> | |
19 | #include <string> | |
20 | #include <boost/graph/connected_components.hpp> | |
21 | #include <boost/graph/graphviz.hpp> | |
22 | ||
23 | int | |
24 | main() | |
25 | { | |
26 | using namespace boost; | |
27 | GraphvizGraph g; | |
28 | read_graphviz("figs/cc-internet.dot", g); | |
29 | ||
30 | std::vector<int> component(num_vertices(g)); | |
31 | ||
32 | connected_components | |
33 | (g, make_iterator_property_map(component.begin(), | |
34 | get(vertex_index, g), component[0])); | |
35 | ||
36 | property_map < GraphvizGraph, vertex_attribute_t >::type | |
37 | vertex_attr_map = get(vertex_attribute, g); | |
38 | std::string color[] = { | |
39 | "white", "gray", "black", "lightgray"}; | |
40 | graph_traits < GraphvizGraph >::vertex_iterator vi, vi_end; | |
41 | for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { | |
42 | vertex_attr_map[*vi]["color"] = color[component[*vi]]; | |
43 | vertex_attr_map[*vi]["style"] = "filled"; | |
44 | if (vertex_attr_map[*vi]["color"] == "black") | |
45 | vertex_attr_map[*vi]["fontcolor"] = "white"; | |
46 | } | |
47 | write_graphviz("figs/cc-internet-out.dot", g); | |
48 | ||
49 | } |