1 // Copyright 2007 Trustees of Indiana University
2
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 // A simple example of using write_graphviz to output a BGL adjacency_list
8 // graph in GraphViz Dot format.
9
10 // Author: Doug Gregor
11
12 #include <boost/graph/graphviz.hpp>
13
14 enum files_e
15 {
16 dax_h,
17 yow_h,
18 boz_h,
19 zow_h,
20 foo_cpp,
21 foo_o,
22 bar_cpp,
23 bar_o,
24 libfoobar_a,
25 zig_cpp,
26 zig_o,
27 zag_cpp,
28 zag_o,
29 libzigzag_a,
30 killerapp,
31 N
32 };
33 const char* name[] = { "dax.h", "yow.h", "boz.h", "zow.h", "foo.cpp", "foo.o",
34 "bar.cpp", "bar.o", "libfoobar.a", "zig.cpp", "zig.o", "zag.cpp", "zag.o",
35 "libzigzag.a", "killerapp" };
36
main(int,char * [])37 int main(int, char*[])
38 {
39
40 typedef std::pair< int, int > Edge;
41 Edge used_by[] = { Edge(dax_h, foo_cpp), Edge(dax_h, bar_cpp),
42 Edge(dax_h, yow_h), Edge(yow_h, bar_cpp), Edge(yow_h, zag_cpp),
43 Edge(boz_h, bar_cpp), Edge(boz_h, zig_cpp), Edge(boz_h, zag_cpp),
44 Edge(zow_h, foo_cpp), Edge(foo_cpp, foo_o), Edge(foo_o, libfoobar_a),
45 Edge(bar_cpp, bar_o), Edge(bar_o, libfoobar_a),
46 Edge(libfoobar_a, libzigzag_a), Edge(zig_cpp, zig_o),
47 Edge(zig_o, libzigzag_a), Edge(zag_cpp, zag_o),
48 Edge(zag_o, libzigzag_a), Edge(libzigzag_a, killerapp) };
49 const int nedges = sizeof(used_by) / sizeof(Edge);
50 int weights[nedges];
51 std::fill(weights, weights + nedges, 1);
52
53 using namespace boost;
54
55 typedef adjacency_list< vecS, vecS, directedS,
56 property< vertex_color_t, default_color_type >,
57 property< edge_weight_t, int > >
58 Graph;
59 Graph g(used_by, used_by + nedges, weights, N);
60
61 write_graphviz(std::cout, g, make_label_writer(name));
62 }
63