]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/graph/example/default-constructor.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / graph / example / default-constructor.cpp
CommitLineData
7c673cae 1//=======================================================================
f67539c2 2// Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee,
7c673cae
FG
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
12using namespace boost;
13
f67539c2 14template < typename Graph > void read_graph_file(std::istream& in, Graph& g)
7c673cae 15{
f67539c2
TL
16 typedef typename graph_traits< Graph >::vertices_size_type size_type;
17 size_type n_vertices;
18 in >> n_vertices; // read in number of vertices
19 for (size_type i = 0; i < n_vertices; ++i) // Add n vertices to the graph
20 add_vertex(g);
21 size_type u, v;
22 while (in >> u) // Read in pairs of integers as edges
23 if (in >> v)
24 add_edge(u, v, g);
25 else
26 break;
7c673cae
FG
27}
28
f67539c2 29int main(int argc, const char** argv)
7c673cae 30{
f67539c2
TL
31 typedef adjacency_list< listS, // Store out-edges of each vertex in a
32 // std::list
33 vecS, // Store vertex set in a std::vector
34 directedS // The graph is directed
35 >
36 graph_type;
7c673cae 37
f67539c2
TL
38 graph_type g; // use default constructor to create empty graph
39 std::ifstream file_in(argc >= 2 ? argv[1] : "makefile-dependencies.dat");
40 read_graph_file(file_in, g);
7c673cae 41
f67539c2
TL
42 assert(num_vertices(g) == 15);
43 assert(num_edges(g) == 19);
44 return 0;
7c673cae 45}