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/copy.hpp>
11 #include <boost/graph/adjacency_list.hpp>
12 #include <boost/graph/graph_utility.hpp>
13
main()14 int main()
15 {
16 using namespace boost;
17 typedef adjacency_list< vecS, vecS, directedS,
18 property< vertex_name_t, char > >
19 graph_t;
20
21 enum
22 {
23 a,
24 b,
25 c,
26 d,
27 e,
28 f,
29 g,
30 N
31 };
32 graph_t G(N);
33 property_map< graph_t, vertex_name_t >::type name_map = get(vertex_name, G);
34 char name = 'a';
35 graph_traits< graph_t >::vertex_iterator v, v_end;
36 for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name)
37 name_map[*v] = name;
38
39 typedef std::pair< int, int > E;
40 E edges[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), E(d, c), E(d, e),
41 E(d, f), E(e, b), E(e, g), E(f, e), E(f, g) };
42 for (int i = 0; i < 12; ++i)
43 add_edge(edges[i].first, edges[i].second, G);
44
45 print_graph(G, name_map);
46 std::cout << std::endl;
47
48 graph_t G_copy;
49 copy_graph(G, G_copy);
50
51 print_graph(G_copy, name_map);
52
53 return 0;
54 }
55