Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/graph/example/reverse-graph-eg.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 1.3 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
10#include <algorithm>
11#include <vector>
12#include <utility>
13#include <iostream>
14
15#include <boost/graph/adjacency_list.hpp>
16#include <boost/graph/reverse_graph.hpp>
17#include <boost/graph/graph_utility.hpp>
18
19int
20main()
21{
22  using namespace boost;
23  typedef adjacency_list < vecS, vecS, bidirectionalS > Graph;
24
25  Graph G(5);
26  add_edge(0, 2, G);
27  add_edge(1, 1, G);
28  add_edge(1, 3, G);
29  add_edge(1, 4, G);
30  add_edge(2, 1, G);
31  add_edge(2, 3, G);
32  add_edge(2, 4, G);
33  add_edge(3, 1, G);
34  add_edge(3, 4, G);
35  add_edge(4, 0, G);
36  add_edge(4, 1, G);
37
38  std::cout << "original graph:" << std::endl;
39  print_graph(G, get(vertex_index, G));
40
41
42  std::cout << std::endl << "reversed graph:" << std::endl;
43#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300  // avoid VC++ bug...
44  reverse_graph<Graph> R(G);
45  print_graph(R, get(vertex_index, G));
46#else
47  print_graph(make_reverse_graph(G), get(vertex_index, G));
48#endif
49
50  return EXIT_SUCCESS;
51}
Note: See TracBrowser for help on using the repository browser.