COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/suurballe_test.cc

    r670 r932  
    2424#include <lemon/suurballe.h>
    2525#include <lemon/concepts/digraph.h>
     26#include <lemon/concepts/heap.h>
    2627
    2728#include "test_tools.h"
     
    8283  typedef concepts::ReadMap<Arc, VType> LengthMap;
    8384 
    84   typedef Suurballe<Digraph, LengthMap> SuurballeType;
     85  typedef Suurballe<Digraph, LengthMap> ST;
     86  typedef Suurballe<Digraph, LengthMap>
     87    ::SetFlowMap<ST::FlowMap>
     88    ::SetPotentialMap<ST::PotentialMap>
     89    ::SetPath<SimplePath<Digraph> >
     90    ::SetHeap<concepts::Heap<VType, Digraph::NodeMap<int> > >
     91    ::Create SuurballeType;
    8592
    8693  Digraph g;
     
    102109  k = suurb_test.run(n, n, k);
    103110  suurb_test.init(n);
     111  suurb_test.fullInit(n);
     112  suurb_test.start(n);
     113  suurb_test.start(n, k);
    104114  k = suurb_test.findFlow(n);
    105115  k = suurb_test.findFlow(n, k);
     
    196206    run();
    197207
    198   // Find 2 paths
     208  // Check run()
    199209  {
    200210    Suurballe<ListDigraph> suurballe(digraph, length);
     211   
     212    // Find 2 paths
    201213    check(suurballe.run(s, t) == 2, "Wrong number of paths");
    202214    check(checkFlow(digraph, suurballe.flowMap(), s, t, 2),
     
    208220    for (int i = 0; i < suurballe.pathNum(); ++i)
    209221      check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path");
    210   }
    211 
    212   // Find 3 paths
    213   {
    214     Suurballe<ListDigraph> suurballe(digraph, length);
     222   
     223    // Find 3 paths
    215224    check(suurballe.run(s, t, 3) == 3, "Wrong number of paths");
    216225    check(checkFlow(digraph, suurballe.flowMap(), s, t, 3),
     
    222231    for (int i = 0; i < suurballe.pathNum(); ++i)
    223232      check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path");
    224   }
    225 
    226   // Find 5 paths (only 3 can be found)
    227   {
    228     Suurballe<ListDigraph> suurballe(digraph, length);
     233   
     234    // Find 5 paths (only 3 can be found)
    229235    check(suurballe.run(s, t, 5) == 3, "Wrong number of paths");
    230236    check(checkFlow(digraph, suurballe.flowMap(), s, t, 3),
     
    237243      check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path");
    238244  }
     245 
     246  // Check fullInit() + start()
     247  {
     248    Suurballe<ListDigraph> suurballe(digraph, length);
     249    suurballe.fullInit(s);
     250   
     251    // Find 2 paths
     252    check(suurballe.start(t) == 2, "Wrong number of paths");
     253    check(suurballe.totalLength() == 510, "The flow is not optimal");
     254
     255    // Find 3 paths
     256    check(suurballe.start(t, 3) == 3, "Wrong number of paths");
     257    check(suurballe.totalLength() == 1040, "The flow is not optimal");
     258
     259    // Find 5 paths (only 3 can be found)
     260    check(suurballe.start(t, 5) == 3, "Wrong number of paths");
     261    check(suurballe.totalLength() == 1040, "The flow is not optimal");
     262  }
    239263
    240264  return 0;
Note: See TracChangeset for help on using the changeset viewer.