File: write_graphviz.cpp

package info (click to toggle)
boost1.83 1.83.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 545,632 kB
  • sloc: cpp: 3,857,086; xml: 125,552; ansic: 34,414; python: 25,887; asm: 5,276; sh: 4,799; ada: 1,681; makefile: 1,629; perl: 1,212; pascal: 1,139; sql: 810; yacc: 478; ruby: 102; lisp: 24; csh: 6
file content (62 lines) | stat: -rw-r--r-- 1,842 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2007 Trustees of Indiana University

// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

// A simple example of using write_graphviz to output a BGL adjacency_list
// graph in GraphViz Dot format.

// Author: Doug Gregor

#include <boost/graph/graphviz.hpp>

enum files_e
{
    dax_h,
    yow_h,
    boz_h,
    zow_h,
    foo_cpp,
    foo_o,
    bar_cpp,
    bar_o,
    libfoobar_a,
    zig_cpp,
    zig_o,
    zag_cpp,
    zag_o,
    libzigzag_a,
    killerapp,
    N
};
const char* name[] = { "dax.h", "yow.h", "boz.h", "zow.h", "foo.cpp", "foo.o",
    "bar.cpp", "bar.o", "libfoobar.a", "zig.cpp", "zig.o", "zag.cpp", "zag.o",
    "libzigzag.a", "killerapp" };

int main(int, char*[])
{

    typedef std::pair< int, int > Edge;
    Edge used_by[] = { Edge(dax_h, foo_cpp), Edge(dax_h, bar_cpp),
        Edge(dax_h, yow_h), Edge(yow_h, bar_cpp), Edge(yow_h, zag_cpp),
        Edge(boz_h, bar_cpp), Edge(boz_h, zig_cpp), Edge(boz_h, zag_cpp),
        Edge(zow_h, foo_cpp), Edge(foo_cpp, foo_o), Edge(foo_o, libfoobar_a),
        Edge(bar_cpp, bar_o), Edge(bar_o, libfoobar_a),
        Edge(libfoobar_a, libzigzag_a), Edge(zig_cpp, zig_o),
        Edge(zig_o, libzigzag_a), Edge(zag_cpp, zag_o),
        Edge(zag_o, libzigzag_a), Edge(libzigzag_a, killerapp) };
    const int nedges = sizeof(used_by) / sizeof(Edge);
    int weights[nedges];
    std::fill(weights, weights + nedges, 1);

    using namespace boost;

    typedef adjacency_list< vecS, vecS, directedS,
        property< vertex_color_t, default_color_type >,
        property< edge_weight_t, int > >
        Graph;
    Graph g(used_by, used_by + nedges, weights, N);

    write_graphviz(std::cout, g, make_label_writer(name));
}