• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
9 /*
10    IMPORTANT!!!
11    ~~~~~~~~~~~~
12    This example uses interfaces that have been deprecated and removed from
13    Boost.Grpah. Someone needs to update it, as it does NOT compile.
14 */
15 
16 #include <boost/config.hpp>
17 #include <fstream>
18 #include <map>
19 #include <string>
20 #include <boost/graph/strong_components.hpp>
21 #include <boost/graph/graphviz.hpp>
22 
main()23 int main()
24 {
25     using namespace boost;
26     GraphvizDigraph g;
27     read_graphviz("figs/scc.dot", g);
28 
29     typedef graph_traits< GraphvizDigraph >::vertex_descriptor vertex_t;
30     std::map< vertex_t, int > component;
31 
32     strong_components(g, make_assoc_property_map(component));
33 
34     property_map< GraphvizDigraph, vertex_attribute_t >::type vertex_attr_map
35         = get(vertex_attribute, g);
36     std::string color[] = { "white", "gray", "black", "lightgray" };
37     graph_traits< GraphvizDigraph >::vertex_iterator vi, vi_end;
38     for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
39     {
40         vertex_attr_map[*vi]["color"] = color[component[*vi]];
41         vertex_attr_map[*vi]["style"] = "filled";
42         if (vertex_attr_map[*vi]["color"] == "black")
43             vertex_attr_map[*vi]["fontcolor"] = "white";
44     }
45     write_graphviz("figs/scc-out.dot", g);
46 
47     return EXIT_SUCCESS;
48 }
49