Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/graph/example/copy-example.cpp @ 45

Last change on this file since 45 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.4 KB
Line 
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
14int
15main()
16{
17  using namespace boost;
18  typedef int weight_t;
19  typedef adjacency_list < vecS, vecS, directedS,
20    property < vertex_name_t, char > > graph_t;
21
22  enum
23  { a, b, c, d, e, f, g, N };
24  graph_t G(N);
25  property_map < graph_t, vertex_name_t >::type
26    name_map = get(vertex_name, G);
27  char name = 'a';
28  graph_traits < graph_t >::vertex_iterator v, v_end;
29  for (tie(v, v_end) = vertices(G); v != v_end; ++v, ++name)
30    name_map[*v] = name;
31
32  typedef std::pair < int, int >E;
33  E edges[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f),
34    E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g)
35  };
36  for (int i = 0; i < 12; ++i)
37    add_edge(edges[i].first, edges[i].second, G);
38
39  print_graph(G, name_map);
40  std::cout << std::endl;
41
42  graph_t G_copy;
43  copy_graph(G, G_copy);
44
45  print_graph(G_copy, name_map);
46
47  return 0;
48}
Note: See TracBrowser for help on using the repository browser.