1 // Copyright (c) Jeremy Siek 2001
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 // NOTE: this final is generated by libs/graph/doc/transitive_closure.w
8 
9 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
10 #error The transitive closure algorithm uses partial specialization.
11 #endif
12 
13 #include <boost/graph/transitive_closure.hpp>
14 #include <boost/graph/graphviz.hpp>
15 #include <boost/graph/graph_utility.hpp>
16 
main(int,char * [])17 int main(int, char*[])
18 {
19     using namespace boost;
20     typedef property< vertex_name_t, char > Name;
21     typedef property< vertex_index_t, std::size_t, Name > Index;
22     typedef adjacency_list< listS, listS, directedS, Index > graph_t;
23     typedef graph_traits< graph_t >::vertex_descriptor vertex_t;
24     graph_t G;
25     std::vector< vertex_t > verts(4);
26     for (int i = 0; i < 4; ++i)
27         verts[i] = add_vertex(Index(i, Name('a' + i)), G);
28     add_edge(verts[1], verts[2], G);
29     add_edge(verts[1], verts[3], G);
30     add_edge(verts[2], verts[1], G);
31     add_edge(verts[3], verts[2], G);
32     add_edge(verts[3], verts[0], G);
33 
34     std::cout << "Graph G:" << std::endl;
35     print_graph(G, get(vertex_name, G));
36 
37     adjacency_list<> TC;
38     transitive_closure(G, TC);
39 
40     std::cout << std::endl << "Graph G+:" << std::endl;
41     char name[] = "abcd";
42     print_graph(TC, name);
43     std::cout << std::endl;
44 
45     std::ofstream out("tc-out.dot");
46     write_graphviz(out, TC, make_label_writer(name));
47 
48     return 0;
49 }
50