1 //=======================================================================
2 // Copyright 2013 University of Warsaw.
3 // Authors: Piotr Wygocki
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
10 #define BOOST_TEST_MODULE successive_shortest_path_nonnegative_weights_test
11
12 #include <boost/test/unit_test.hpp>
13
14 #include <boost/graph/successive_shortest_path_nonnegative_weights.hpp>
15 #include <boost/graph/find_flow_cost.hpp>
16
17 #include "min_cost_max_flow_utils.hpp"
18
BOOST_AUTO_TEST_CASE(path_augmentation_def_test)19 BOOST_AUTO_TEST_CASE(path_augmentation_def_test)
20 {
21 boost::SampleGraph::vertex_descriptor s, t;
22 boost::SampleGraph::Graph g;
23 boost::SampleGraph::getSampleGraph(g, s, t);
24
25 boost::successive_shortest_path_nonnegative_weights(g, s, t);
26
27 int cost = boost::find_flow_cost(g);
28 BOOST_CHECK_EQUAL(cost, 29);
29 }
30
BOOST_AUTO_TEST_CASE(path_augmentation_def_test2)31 BOOST_AUTO_TEST_CASE(path_augmentation_def_test2)
32 {
33 boost::SampleGraph::vertex_descriptor s, t;
34 boost::SampleGraph::Graph g;
35 boost::SampleGraph::getSampleGraph2(g, s, t);
36
37 boost::successive_shortest_path_nonnegative_weights(g, s, t);
38
39 int cost = boost::find_flow_cost(g);
40 BOOST_CHECK_EQUAL(cost, 7);
41 }
42
BOOST_AUTO_TEST_CASE(path_augmentation_test)43 BOOST_AUTO_TEST_CASE(path_augmentation_test)
44 {
45 boost::SampleGraph::vertex_descriptor s, t;
46 typedef boost::SampleGraph::Graph Graph;
47 Graph g;
48 boost::SampleGraph::getSampleGraph(g, s, t);
49
50 int N = boost::num_vertices(g);
51 std::vector< int > dist(N);
52 std::vector< int > dist_prev(N);
53 typedef boost::graph_traits< Graph >::edge_descriptor edge_descriptor;
54 std::vector< edge_descriptor > pred(N);
55
56 boost::property_map< Graph, boost::vertex_index_t >::const_type idx
57 = get(boost::vertex_index, g);
58
59 boost::successive_shortest_path_nonnegative_weights(g, s, t,
60 boost::distance_map(
61 boost::make_iterator_property_map(dist.begin(), idx))
62 .predecessor_map(
63 boost::make_iterator_property_map(pred.begin(), idx))
64 .distance_map2(
65 boost::make_iterator_property_map(dist_prev.begin(), idx))
66 .vertex_index_map(idx));
67
68 int cost = boost::find_flow_cost(g);
69 BOOST_CHECK_EQUAL(cost, 29);
70 }
71