os/ossrv/stdcpp/tsrc/Boost_test/graph/src/transitive_closure.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 /*
    10  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
    11 */
    12 
    13 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
    14 #error The transitive closure algorithm uses partial specialization.
    15 #endif
    16 
    17 #include <boost/graph/transitive_closure.hpp>
    18 #include <boost/graph/graphviz.hpp>
    19 #include <boost/graph/graph_utility.hpp>
    20 
    21 #ifdef __SYMBIAN32__
    22 #include "std_log_result.h"
    23 #define LOG_FILENAME_LINE __FILE__, __LINE__
    24 #endif
    25 
    26 int
    27 main(int, char *[])
    28 {
    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;
    34   graph_t G;
    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);
    43 
    44   std::cout << "Graph G:" << std::endl;
    45   print_graph(G, get(vertex_name, G));
    46 
    47   adjacency_list <> TC;
    48   transitive_closure(G, TC);
    49 
    50   std::cout << std::endl << "Graph G+:" << std::endl;
    51   char name[] = "abcd";
    52   print_graph(TC, name);
    53   std::cout << std::endl;
    54 
    55   std::ofstream out("tc-out.dot");
    56   write_graphviz(out, TC, make_label_writer(name));
    57   #ifdef __SYMBIAN32__
    58 	testResultXml("transitive_closure");
    59 	close_log_file();
    60   #endif
    61 
    62   return 0;
    63 }