First public contribution.
1 // Copyright (c) Jeremy Siek 2001
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)
7 // NOTE: this final is generated by libs/graph/doc/transitive_closure.w
10 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
13 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
14 #error The transitive closure algorithm uses partial specialization.
17 #include <boost/graph/transitive_closure.hpp>
18 #include <boost/graph/graphviz.hpp>
19 #include <boost/graph/graph_utility.hpp>
22 #include "std_log_result.h"
23 #define LOG_FILENAME_LINE __FILE__, __LINE__
29 using namespace boost;
30 typedef property < vertex_name_t, char >Name;
31 typedef property < vertex_index_t, std::size_t, Name > Index;
32 typedef adjacency_list < listS, listS, directedS, Index > graph_t;
33 typedef graph_traits < graph_t >::vertex_descriptor vertex_t;
35 std::vector < vertex_t > verts(4);
36 for (int i = 0; i < 4; ++i)
37 verts[i] = add_vertex(Index(i, Name('a' + i)), G);
38 add_edge(verts[1], verts[2], G);
39 add_edge(verts[1], verts[3], G);
40 add_edge(verts[2], verts[1], G);
41 add_edge(verts[3], verts[2], G);
42 add_edge(verts[3], verts[0], G);
44 std::cout << "Graph G:" << std::endl;
45 print_graph(G, get(vertex_name, G));
48 transitive_closure(G, TC);
50 std::cout << std::endl << "Graph G+:" << std::endl;
52 print_graph(TC, name);
53 std::cout << std::endl;
55 std::ofstream out("tc-out.dot");
56 write_graphviz(out, TC, make_label_writer(name));
58 testResultXml("transitive_closure");