COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
04/26/09 16:44:53 (16 years ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Phase:
public
Message:

Modify the interface of MinCostArborescence? + improvements (#267)

  • Rename arborescenceValue() to arborescenceCost().
  • Rename DefXyz? template named paramaters to SetXyz?.
  • Rearrange public functions (for better doc).
  • Doc improvements.
  • Extend the test file with interface checking.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/min_cost_arborescence_test.cc

    r490 r625  
    2525#include <lemon/min_cost_arborescence.h>
    2626#include <lemon/lgf_reader.h>
     27#include <lemon/concepts/digraph.h>
    2728
    2829#include "test_tools.h"
     
    7172  "source 0\n";
    7273
     74
     75void checkMinCostArborescenceCompile()
     76{
     77  typedef double VType;
     78  typedef concepts::Digraph Digraph;
     79  typedef concepts::ReadMap<Digraph::Arc, VType> CostMap;
     80  typedef Digraph::Node Node;
     81  typedef Digraph::Arc Arc;
     82  typedef concepts::WriteMap<Digraph::Arc, bool> ArbMap;
     83  typedef concepts::ReadWriteMap<Digraph::Node, Digraph::Arc> PredMap;
     84
     85  typedef MinCostArborescence<Digraph, CostMap>::
     86            SetArborescenceMap<ArbMap>::
     87            SetPredMap<PredMap>::Create MinCostArbType;
     88
     89  Digraph g;
     90  Node s, n;
     91  Arc e;
     92  VType c;
     93  bool b;
     94  int i;
     95  CostMap cost;
     96  ArbMap arb;
     97  PredMap pred;
     98
     99  MinCostArbType mcarb_test(g, cost);
     100  const MinCostArbType& const_mcarb_test = mcarb_test;
     101
     102  mcarb_test
     103    .arborescenceMap(arb)
     104    .predMap(pred)
     105    .run(s);
     106
     107  mcarb_test.init();
     108  mcarb_test.addSource(s);
     109  mcarb_test.start();
     110  n = mcarb_test.processNextNode();
     111  b = const_mcarb_test.emptyQueue();
     112  i = const_mcarb_test.queueSize();
     113 
     114  c = const_mcarb_test.arborescenceCost();
     115  b = const_mcarb_test.arborescence(e);
     116  e = const_mcarb_test.pred(n);
     117  const MinCostArbType::ArborescenceMap &am =
     118    const_mcarb_test.arborescenceMap();
     119  const MinCostArbType::PredMap &pm =
     120    const_mcarb_test.predMap();
     121  b = const_mcarb_test.reached(n);
     122  b = const_mcarb_test.processed(n);
     123 
     124  i = const_mcarb_test.dualNum();
     125  c = const_mcarb_test.dualValue();
     126  i = const_mcarb_test.dualSize(i);
     127  c = const_mcarb_test.dualValue(i);
     128 
     129  ignore_unused_variable_warning(am);
     130  ignore_unused_variable_warning(pm);
     131}
     132
    73133int main() {
    74134  typedef SmartDigraph Digraph;
     
    111171      }
    112172      if (mca.arborescence(it)) {
    113         check(sum == cost[it], "INVALID DUAL");
     173        check(sum == cost[it], "Invalid dual solution");
    114174      }
    115       check(sum <= cost[it], "INVALID DUAL");
     175      check(sum <= cost[it], "Invalid dual solution");
    116176    }
    117177  }
    118178
    119179
    120   check(mca.dualValue() == mca.arborescenceValue(), "INVALID DUAL");
    121 
    122   check(mca.reached(source), "INVALID ARBORESCENCE");
     180  check(mca.dualValue() == mca.arborescenceCost(), "Invalid dual solution");
     181
     182  check(mca.reached(source), "Invalid arborescence");
    123183  for (ArcIt a(digraph); a != INVALID; ++a) {
    124184    check(!mca.reached(digraph.source(a)) ||
    125           mca.reached(digraph.target(a)), "INVALID ARBORESCENCE");
     185          mca.reached(digraph.target(a)), "Invalid arborescence");
    126186  }
    127187
     
    131191    for (InArcIt a(digraph, n); a != INVALID; ++a) {
    132192      if (mca.arborescence(a)) {
    133         check(mca.pred(n) == a, "INVALID ARBORESCENCE");
     193        check(mca.pred(n) == a, "Invalid arborescence");
    134194        ++cnt;
    135195      }
    136196    }
    137     check((n == source ? cnt == 0 : cnt == 1), "INVALID ARBORESCENCE");
     197    check((n == source ? cnt == 0 : cnt == 1), "Invalid arborescence");
    138198  }
    139199
    140200  Digraph::ArcMap<bool> arborescence(digraph);
    141   check(mca.arborescenceValue() ==
     201  check(mca.arborescenceCost() ==
    142202        minCostArborescence(digraph, cost, source, arborescence),
    143         "WRONG FUNCTION");
     203        "Wrong result of the function interface");
    144204
    145205  return 0;
Note: See TracChangeset for help on using the changeset viewer.