os/ossrv/stdcpp/tsrc/Boost_test/graph/src/subgraph.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 //=======================================================================
     2 // Copyright 2001 University of Notre Dame.
     3 // Author: Jeremy G. Siek
     4 //
     5 // Distributed under the Boost Software License, Version 1.0. (See
     6 // accompanying file LICENSE_1_0.txt or copy at
     7 // http://www.boost.org/LICENSE_1_0.txt)
     8 //=======================================================================
     9 
    10 /*
    11  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
    12 */
    13 
    14 /*
    15   Sample output:
    16 
    17   G0:
    18   0 --> 1 
    19   1 --> 2 3 
    20   2 --> 5 
    21   3 --> 
    22   4 --> 1 5 
    23   5 --> 3 
    24   0(0,1) 1(1,2) 2(1,3) 6(2,5) 3(4,1) 4(4,5) 5(5,3) 
    25 
    26   G1:
    27   2 --> 5 
    28   4 --> 5 
    29   5 --> 
    30   6(2,5) 4(4,5) 
    31 
    32   G2:
    33   0 --> 1 
    34   1 --> 
    35   0(0,1) 
    36 
    37  */
    38 
    39 #include <boost/config.hpp>
    40 #include <iostream>
    41 #include <boost/graph/subgraph.hpp>
    42 #include <boost/graph/adjacency_list.hpp>
    43 #include <boost/graph/graph_utility.hpp>
    44 
    45 #ifdef __SYMBIAN32__
    46 #include "std_log_result.h"
    47 #define LOG_FILENAME_LINE __FILE__, __LINE__
    48 #endif
    49 
    50 
    51 
    52 int main(int,char*[])
    53 {
    54   using namespace boost;
    55   typedef adjacency_list_traits<vecS, vecS, directedS> Traits;
    56   typedef subgraph< adjacency_list<vecS, vecS, directedS,
    57     property<vertex_color_t, int>, property<edge_index_t, int> > > Graph;
    58 
    59   const int N = 6;
    60   Graph G0(N);
    61   enum { A, B, C, D, E, F};     // for conveniently refering to vertices in G0
    62 
    63   Graph& G1 = G0.create_subgraph();
    64   Graph& G2 = G0.create_subgraph();
    65   enum { A1, B1, C1 };          // for conveniently refering to vertices in G1
    66   enum { A2, B2 };              // for conveniently refering to vertices in G2
    67 
    68   add_vertex(C, G1); // global vertex C becomes local A1 for G1
    69   add_vertex(E, G1); // global vertex E becomes local B1 for G1
    70   add_vertex(F, G1); // global vertex F becomes local C1 for G1
    71   
    72   add_vertex(A, G2); // global vertex A becomes local A1 for G2
    73   add_vertex(B, G2); // global vertex B becomes local B1 for G2
    74 
    75   add_edge(A, B, G0);
    76   add_edge(B, C, G0);
    77   add_edge(B, D, G0);
    78   add_edge(E, B, G0);
    79   add_edge(E, F, G0);
    80   add_edge(F, D, G0);
    81 
    82   add_edge(A1, C1, G1); // (A1,C1) is subgraph G1 local indices for (C,F).
    83 
    84   std::cout << "G0:" << std::endl;
    85   print_graph(G0, get(vertex_index, G0));
    86   print_edges2(G0, get(vertex_index, G0), get(edge_index, G0));
    87   std::cout << std::endl;
    88 
    89   Graph::children_iterator ci, ci_end;
    90   int num = 1;
    91   for (tie(ci, ci_end) = G0.children(); ci != ci_end; ++ci) {
    92     std::cout << "G" << num++ << ":" << std::endl;
    93     print_graph(*ci, get(vertex_index, *ci));
    94     print_edges2(*ci, get(vertex_index, *ci), get(edge_index, *ci));
    95     std::cout << std::endl;
    96   }
    97   
    98   #ifdef __SYMBIAN32__
    99 	std_log(LOG_FILENAME_LINE,"[End Test Case ]");
   100 	testResultXml("subgraph");
   101 	close_log_file();
   102   #endif
   103 
   104   return 0;
   105 }