]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/test/dag_longest_paths.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / graph / test / dag_longest_paths.cpp
1 // Copyright (C) 2002 Trustees of Indiana University
2
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 #include <boost/graph/adjacency_list.hpp>
8 #include <boost/graph/dag_shortest_paths.hpp>
9 #include <boost/property_map/vector_property_map.hpp>
10 #include <boost/test/minimal.hpp>
11
12 using namespace boost;
13
14 #include <iostream>
15 using namespace std;
16
17 int test_main(int, char*[])
18 {
19 typedef adjacency_list<vecS, vecS, directedS, no_property,
20 property<edge_weight_t, int> > Graph;
21
22 Graph graph;
23
24 (void)add_vertex(graph);
25 (void)add_vertex(graph);
26 (void)add_vertex(graph);
27 (void)add_vertex(graph);
28
29 Graph::edge_descriptor e;
30
31 e = add_edge(0, 1, graph).first;
32 put(edge_weight, graph, e, 1);
33
34 e = add_edge(1, 2, graph).first;
35 put(edge_weight, graph, e, 1);
36
37 e = add_edge(3, 1, graph).first;
38 put(edge_weight, graph, e, 5);
39
40 vector_property_map<int> distance;
41
42 dag_shortest_paths(graph, 0,
43 distance_map(distance)
44 .distance_compare(std::greater<int>())
45 .distance_inf((std::numeric_limits<int>::min)())
46 .distance_zero(0));
47
48 cout << distance[2] << "\n";
49
50 BOOST_CHECK(distance[2] == 2);
51
52 return 0;
53 }
54
55
56