]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/example/transpose-example.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / graph / example / transpose-example.cpp
1 //=======================================================================
2 // Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee,
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //=======================================================================
8 #include <boost/config.hpp>
9 #include <iostream>
10 #include <boost/graph/transpose_graph.hpp>
11 #include <boost/graph/adjacency_list.hpp>
12 #include <boost/graph/graph_utility.hpp>
13
14 int
15 main()
16 {
17 using namespace boost;
18 typedef adjacency_list < vecS, vecS, bidirectionalS,
19 property < vertex_name_t, char > > graph_t;
20
21 enum { a, b, c, d, e, f, g, N };
22 graph_t G(N);
23 property_map < graph_t, vertex_name_t >::type
24 name_map = get(vertex_name, G);
25 char name = 'a';
26 graph_traits < graph_t >::vertex_iterator v, v_end;
27 for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name)
28 name_map[*v] = name;
29
30 typedef std::pair < int, int >E;
31 E edge_array[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f),
32 E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g)
33 };
34 for (int i = 0; i < 12; ++i)
35 add_edge(edge_array[i].first, edge_array[i].second, G);
36
37 print_graph(G, name_map);
38 std::cout << std::endl;
39
40 graph_t G_T;
41 transpose_graph(G, G_T);
42
43 print_graph(G_T, name_map);
44
45 graph_traits < graph_t >::edge_iterator ei, ei_end;
46 for (boost::tie(ei, ei_end) = edges(G); ei != ei_end; ++ei)
47 assert(edge(target(*ei, G), source(*ei, G), G_T).second == true);
48 return 0;
49 }