Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/graph/example/cc-internet.cpp @ 47

Last change on this file since 47 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.4 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 <fstream>
10#include <vector>
11#include <string>
12#include <boost/graph/connected_components.hpp>
13#include <boost/graph/graphviz.hpp>
14
15int
16main()
17{
18  using namespace boost;
19  GraphvizGraph g;
20  read_graphviz("figs/cc-internet.dot", g);
21
22  std::vector<int> component(num_vertices(g));
23
24  connected_components
25    (g, make_iterator_property_map(component.begin(),
26                                   get(vertex_index, g), component[0]));
27
28  property_map < GraphvizGraph, vertex_attribute_t >::type
29    vertex_attr_map = get(vertex_attribute, g);
30  std::string color[] = {
31  "white", "gray", "black", "lightgray"};
32  graph_traits < GraphvizGraph >::vertex_iterator vi, vi_end;
33  for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
34    vertex_attr_map[*vi]["color"] = color[component[*vi]];
35    vertex_attr_map[*vi]["style"] = "filled";
36    if (vertex_attr_map[*vi]["color"] == "black")
37      vertex_attr_map[*vi]["fontcolor"] = "white";
38  }
39  write_graphviz("figs/cc-internet-out.dot", g);
40
41}
Note: See TracBrowser for help on using the repository browser.