]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/example/topo-sort1.cpp
1 //=======================================================================
2 // Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee,
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 <deque> // to store the vertex ordering
12 #include <boost/graph/vector_as_graph.hpp>
13 #include <boost/graph/topological_sort.hpp>
18 using namespace boost
;
19 const char *tasks
[] = {
20 "pick up kids from school",
21 "buy groceries (and snacks)",
23 "drop off kids at soccer practice",
25 "pick up kids from soccer",
28 const int n_tasks
= sizeof(tasks
) / sizeof(char *);
30 std::vector
< std::list
< int > > g(n_tasks
);
39 std::deque
< int >topo_order
;
41 topological_sort(g
, std::front_inserter(topo_order
),
42 vertex_index_map(identity_property_map()));
45 for (std::deque
< int >::iterator i
= topo_order
.begin();
46 i
!= topo_order
.end(); ++i
, ++n
)
47 std::cout
<< tasks
[*i
] << std::endl
;