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 <fstream>
10 #include <boost/graph/adjacency_list.hpp>
11 #include <boost/graph/graph_utility.hpp>
12
13 using namespace boost;
14
15 template < typename T >
operator >>(std::istream & in,std::pair<T,T> & p)16 std::istream& operator>>(std::istream& in, std::pair< T, T >& p)
17 {
18 in >> p.first >> p.second;
19 return in;
20 }
21
main(int argc,const char ** argv)22 int main(int argc, const char** argv)
23 {
24 typedef adjacency_list< listS, // Store out-edges of each vertex in a
25 // std::list
26 vecS, // Store vertex set in a std::vector
27 directedS // The graph is directed
28 >
29 graph_type;
30
31 std::ifstream file_in(argc >= 2 ? argv[1] : "makefile-dependencies.dat");
32 typedef graph_traits< graph_type >::vertices_size_type size_type;
33 size_type n_vertices;
34 file_in >> n_vertices; // read in number of vertices
35
36 graph_type g(n_vertices); // create graph with n vertices
37
38 // Read in edges
39 graph_traits< graph_type >::vertices_size_type u, v;
40 while (file_in >> u)
41 if (file_in >> v)
42 add_edge(u, v, g);
43 else
44 break;
45
46 assert(num_vertices(g) == 15);
47 assert(num_edges(g) == 19);
48 return 0;
49 }
50