Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/graph/example/in_edges.cpp @ 47

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

updated boost from 1_33_1 to 1_34_1

File size: 1.3 KB
Line 
1//=======================================================================
2// Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
3// Authors: Andrew Lumsdaine, Lie-Quan Lee, 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#include <boost/config.hpp>
10#include <iostream>
11#include <vector>
12#include <utility>
13
14#include <boost/graph/adjacency_list.hpp>
15
16/*
17  Sample Output
18
19  0 <--
20  1 <-- 0 
21  2 <-- 1 
22  3 <-- 1 
23  4 <-- 2  3 
24
25 */
26
27int main(int , char* [])
28{
29  using namespace boost;
30  using namespace std;
31  using namespace boost;
32
33  typedef adjacency_list<listS,vecS,bidirectionalS> Graph;
34  const int num_vertices = 5;
35  Graph g(num_vertices);
36
37  add_edge(0, 1, g);
38  add_edge(1, 2, g);
39  add_edge(1, 3, g);
40  add_edge(2, 4, g);
41  add_edge(3, 4, g);
42
43  boost::graph_traits<Graph>::vertex_iterator i, end;
44  boost::graph_traits<Graph>::in_edge_iterator ei, edge_end;
45
46  for(tie(i,end) = vertices(g); i != end; ++i) {
47    cout << *i << " <-- ";
48    for (tie(ei,edge_end) = in_edges(*i, g); ei != edge_end; ++ei)
49      cout << source(*ei, g) << "  ";
50    cout << endl;
51  }
52  return 0;
53}
Note: See TracBrowser for help on using the repository browser.