successive_shortest_path_nonnegative_weights_test.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #define BOOST_TEST_MODULE successive_shortest_path_nonnegative_weights_test
  10. #include <boost/test/unit_test.hpp>
  11. #include <boost/graph/successive_shortest_path_nonnegative_weights.hpp>
  12. #include <boost/graph/find_flow_cost.hpp>
  13. #include "min_cost_max_flow_utils.hpp"
  14. BOOST_AUTO_TEST_CASE(path_augmentation_def_test) {
  15. boost::SampleGraph::vertex_descriptor s,t;
  16. boost::SampleGraph::Graph g;
  17. boost::SampleGraph::getSampleGraph(g, s, t);
  18. boost::successive_shortest_path_nonnegative_weights(g, s, t);
  19. int cost = boost::find_flow_cost(g);
  20. BOOST_CHECK_EQUAL(cost, 29);
  21. }
  22. BOOST_AUTO_TEST_CASE(path_augmentation_def_test2) {
  23. boost::SampleGraph::vertex_descriptor s,t;
  24. boost::SampleGraph::Graph g;
  25. boost::SampleGraph::getSampleGraph2(g, s, t);
  26. boost::successive_shortest_path_nonnegative_weights(g, s, t);
  27. int cost = boost::find_flow_cost(g);
  28. BOOST_CHECK_EQUAL(cost, 7);
  29. }
  30. BOOST_AUTO_TEST_CASE(path_augmentation_test) {
  31. boost::SampleGraph::vertex_descriptor s,t;
  32. typedef boost::SampleGraph::Graph Graph;
  33. Graph g;
  34. boost::SampleGraph::getSampleGraph(g, s, t);
  35. int N = boost::num_vertices(g);
  36. std::vector<int> dist(N);
  37. std::vector<int> dist_prev(N);
  38. typedef boost::graph_traits<Graph>::edge_descriptor edge_descriptor;
  39. std::vector<edge_descriptor> pred(N);
  40. boost::property_map<Graph, boost::vertex_index_t>::const_type
  41. idx = get(boost::vertex_index, g);
  42. boost::successive_shortest_path_nonnegative_weights(g, s, t,
  43. boost::distance_map(boost::make_iterator_property_map(dist.begin(), idx)).
  44. predecessor_map(boost::make_iterator_property_map(pred.begin(), idx)).
  45. distance_map2(boost::make_iterator_property_map(dist_prev.begin(), idx)).
  46. vertex_index_map(idx));
  47. int cost = boost::find_flow_cost(g);
  48. BOOST_CHECK_EQUAL(cost, 29);
  49. }