COIN-OR::LEMON - Graph Library

Changeset 877:141f9c0db4a3 in lemon-main for test


Ignore:
Timestamp:
03/06/10 15:35:12 (15 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Children:
879:38213abd2911, 931:f112c18bc304
Phase:
public
Message:

Unify the sources (#339)

Location:
test
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • test/bellman_ford_test.cc

    r844 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    9898    pp = const_bf_test.path(t);
    9999    pp = const_bf_test.negativeCycle();
    100    
     100
    101101    for (BF::ActiveIt it(const_bf_test); it != INVALID; ++it) {}
    102102  }
     
    111111    concepts::ReadWriteMap<Node,Arc> pred_map;
    112112    concepts::ReadWriteMap<Node,Value> dist_map;
    113    
     113
    114114    bf_test
    115115      .lengthMap(length_map)
     
    190190  check(pathSource(gr, p) == s, "path() found a wrong path.");
    191191  check(pathTarget(gr, p) == t, "path() found a wrong path.");
    192  
     192
    193193  ListPath<Digraph> path;
    194194  Value dist;
     
    229229  SmartDigraph gr;
    230230  IntArcMap length(gr);
    231  
     231
    232232  Node n1 = gr.addNode();
    233233  Node n2 = gr.addNode();
    234234  Node n3 = gr.addNode();
    235235  Node n4 = gr.addNode();
    236  
     236
    237237  Arc a1 = gr.addArc(n1, n2);
    238238  Arc a2 = gr.addArc(n2, n2);
    239  
     239
    240240  length[a1] = 2;
    241241  length[a2] = -1;
    242  
     242
    243243  {
    244244    BellmanFord<SmartDigraph, IntArcMap> bf(gr, length);
     
    248248          "Wrong negative cycle.");
    249249  }
    250  
     250
    251251  length[a2] = 0;
    252  
     252
    253253  {
    254254    BellmanFord<SmartDigraph, IntArcMap> bf(gr, length);
     
    257257          "Negative cycle should not be found.");
    258258  }
    259  
     259
    260260  length[gr.addArc(n1, n3)] = 5;
    261261  length[gr.addArc(n4, n3)] = 1;
    262262  length[gr.addArc(n2, n4)] = 2;
    263263  length[gr.addArc(n3, n2)] = -4;
    264  
     264
    265265  {
    266266    BellmanFord<SmartDigraph, IntArcMap> bf(gr, length);
  • test/bfs_test.cc

    r585 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    8484    b = const_bfs_test.emptyQueue();
    8585    i = const_bfs_test.queueSize();
    86    
     86
    8787    bfs_test.start();
    8888    bfs_test.start(t);
     
    105105      ::SetProcessedMap<concepts::WriteMap<Node,bool> >
    106106      ::Create bfs_test(G);
    107      
     107
    108108    concepts::ReadWriteMap<Node,Arc> pred_map;
    109109    concepts::ReadWriteMap<Node,int> dist_map;
    110110    concepts::ReadWriteMap<Node,bool> reached_map;
    111111    concepts::WriteMap<Node,bool> processed_map;
    112    
     112
    113113    bfs_test
    114114      .predMap(pred_map)
     
    120120    bfs_test.run(s,t);
    121121    bfs_test.run();
    122    
     122
    123123    bfs_test.init();
    124124    bfs_test.addSource(s);
     
    129129    b = bfs_test.emptyQueue();
    130130    i = bfs_test.queueSize();
    131    
     131
    132132    bfs_test.start();
    133133    bfs_test.start(t);
  • test/circulation_test.cc

    r689 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    8282  CirculationType circ_test(g, lcap, ucap, supply);
    8383  const CirculationType& const_circ_test = circ_test;
    84    
     84
    8585  circ_test
    8686    .lowerMap(lcap)
     
    8888    .supplyMap(supply)
    8989    .flowMap(flow);
    90  
     90
    9191  const CirculationType::Elevator& elev = const_circ_test.elevator();
    9292  circ_test.elevator(const_cast<CirculationType::Elevator&>(elev));
     
    103103  b = const_circ_test.barrier(n);
    104104  const_circ_test.barrierMap(bar);
    105  
     105
    106106  ignore_unused_variable_warning(fm);
    107107}
  • test/connectivity_test.cc

    r649 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    3030  typedef ListDigraph Digraph;
    3131  typedef Undirector<Digraph> Graph;
    32  
    33   {
    34     Digraph d;
    35     Digraph::NodeMap<int> order(d);
    36     Graph g(d);
    37    
     32
     33  {
     34    Digraph d;
     35    Digraph::NodeMap<int> order(d);
     36    Graph g(d);
     37
    3838    check(stronglyConnected(d), "The empty digraph is strongly connected");
    3939    check(countStronglyConnectedComponents(d) == 0,
     
    4949    check(countBiEdgeConnectedComponents(g) == 0,
    5050          "The empty graph has 0 bi-edge-connected component");
    51          
     51
    5252    check(dag(d), "The empty digraph is DAG.");
    5353    check(checkedTopologicalSort(d, order), "The empty digraph is DAG.");
     
    8383    check(countBiEdgeConnectedComponents(g) == 1,
    8484          "This graph has 1 bi-edge-connected component");
    85          
     85
    8686    check(dag(d), "This digraph is DAG.");
    8787    check(checkedTopologicalSort(d, order), "This digraph is DAG.");
     
    102102    Digraph::NodeMap<int> order(d);
    103103    Graph g(d);
    104    
     104
    105105    Digraph::Node n1 = d.addNode();
    106106    Digraph::Node n2 = d.addNode();
     
    109109    Digraph::Node n5 = d.addNode();
    110110    Digraph::Node n6 = d.addNode();
    111    
     111
    112112    d.addArc(n1, n3);
    113113    d.addArc(n3, n2);
     
    137137    check(!parallelFree(g), "This graph is not parallel-free.");
    138138    check(!simpleGraph(g), "This graph is not simple.");
    139    
     139
    140140    d.addArc(n3, n3);
    141    
     141
    142142    check(!loopFree(d), "This digraph is not loop-free.");
    143143    check(!loopFree(g), "This graph is not loop-free.");
    144144    check(!simpleGraph(d), "This digraph is not simple.");
    145    
     145
    146146    d.addArc(n3, n2);
    147    
     147
    148148    check(!parallelFree(d), "This digraph is not parallel-free.");
    149149  }
    150  
     150
    151151  {
    152152    Digraph d;
    153153    Digraph::ArcMap<bool> cutarcs(d, false);
    154154    Graph g(d);
    155    
     155
    156156    Digraph::Node n1 = d.addNode();
    157157    Digraph::Node n2 = d.addNode();
     
    173173    d.addArc(n6, n7);
    174174    d.addArc(n7, n6);
    175    
     175
    176176    check(!stronglyConnected(d), "This digraph is not strongly connected");
    177177    check(countStronglyConnectedComponents(d) == 3,
     
    236236    Digraph d;
    237237    Digraph::NodeMap<int> order(d);
    238    
     238
    239239    Digraph::Node belt = d.addNode();
    240240    Digraph::Node trousers = d.addNode();
     
    256256    d.addArc(shirt, necktie);
    257257    d.addArc(necktie, coat);
    258    
     258
    259259    check(dag(d), "This digraph is DAG.");
    260260    topologicalSort(d, order);
     
    268268    ListGraph g;
    269269    ListGraph::NodeMap<bool> map(g);
    270    
     270
    271271    ListGraph::Node n1 = g.addNode();
    272272    ListGraph::Node n2 = g.addNode();
     
    284284    g.addEdge(n4, n7);
    285285    g.addEdge(n5, n7);
    286    
     286
    287287    check(bipartite(g), "This graph is bipartite");
    288288    check(bipartitePartitions(g, map), "This graph is bipartite");
    289    
     289
    290290    check(map[n1] == map[n2] && map[n1] == map[n6] && map[n1] == map[n7],
    291291          "Wrong bipartitePartitions()");
  • test/dfs_test.cc

    r585 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    8484    b = const_dfs_test.emptyQueue();
    8585    i = const_dfs_test.queueSize();
    86    
     86
    8787    dfs_test.start();
    8888    dfs_test.start(t);
     
    110110    concepts::ReadWriteMap<Node,bool> reached_map;
    111111    concepts::WriteMap<Node,bool> processed_map;
    112    
     112
    113113    dfs_test
    114114      .predMap(pred_map)
     
    127127    b = dfs_test.emptyQueue();
    128128    i = dfs_test.queueSize();
    129    
     129
    130130    dfs_test.start();
    131131    dfs_test.start(t);
  • test/digraph_test.cc

    r780 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    393393  SmartDigraph::NodeMap<StaticDigraph::Node> nref(g);
    394394  SmartDigraph::ArcMap<StaticDigraph::Arc> aref(g);
    395  
     395
    396396  StaticDigraph G;
    397  
     397
    398398  checkGraphNodeList(G, 0);
    399399  checkGraphArcList(G, 0);
     
    465465
    466466  G.build(6, arcs.begin(), arcs.end());
    467  
     467
    468468  checkGraphNodeList(G, 6);
    469469  checkGraphArcList(G, 9);
     
    489489  checkGraphNodeMap(G);
    490490  checkGraphArcMap(G);
    491  
     491
    492492  int n = G.nodeNum();
    493493  int m = G.arcNum();
  • test/dijkstra_test.cc

    r585 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    8686    b = const_dijkstra_test.emptyQueue();
    8787    i = const_dijkstra_test.queueSize();
    88    
     88
    8989    dijkstra_test.start();
    9090    dijkstra_test.start(t);
     
    110110      ::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> > >
    111111      ::SetStandardHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> > >
    112       ::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> >, 
     112      ::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> >,
    113113                concepts::ReadWriteMap<Node,int> >
    114114      ::Create dijkstra_test(G,length);
     
    120120    concepts::ReadWriteMap<Node,int> heap_cross_ref;
    121121    BinHeap<VType, concepts::ReadWriteMap<Node,int> > heap(heap_cross_ref);
    122    
     122
    123123    dijkstra_test
    124124      .lengthMap(length_map)
     
    137137    b = dijkstra_test.emptyQueue();
    138138    i = dijkstra_test.queueSize();
    139    
     139
    140140    dijkstra_test.start();
    141141    dijkstra_test.start(t);
  • test/edge_set_test.cc

    r488 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  • test/euler_test.cc

    r592 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    8686  typedef ListDigraph Digraph;
    8787  typedef Undirector<Digraph> Graph;
    88  
    89   {
    90     Digraph d;
    91     Graph g(d);
    92    
     88
     89  {
     90    Digraph d;
     91    Graph g(d);
     92
    9393    checkDiEulerIt(d);
    9494    checkDiEulerIt(g);
     
    129129    Digraph::Node n2 = d.addNode();
    130130    Digraph::Node n3 = d.addNode();
    131    
     131
    132132    d.addArc(n1, n2);
    133133    d.addArc(n2, n1);
     
    154154    Digraph::Node n5 = d.addNode();
    155155    Digraph::Node n6 = d.addNode();
    156    
     156
    157157    d.addArc(n1, n2);
    158158    d.addArc(n2, n4);
     
    190190    Digraph::Node n4 = d.addNode();
    191191    Digraph::Node n5 = d.addNode();
    192    
     192
    193193    d.addArc(n1, n2);
    194194    d.addArc(n2, n3);
     
    212212    Digraph::Node n2 = d.addNode();
    213213    Digraph::Node n3 = d.addNode();
    214    
     214
    215215    d.addArc(n1, n2);
    216216    d.addArc(n2, n3);
  • test/fractional_matching_test.cc

    r872 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    239239  for (SmartGraph::EdgeIt e(graph); e != INVALID; ++e) {
    240240    check((e == mfm.matching(graph.u(e)) ? 1 : 0) +
    241           (e == mfm.matching(graph.v(e)) ? 1 : 0) == 
     241          (e == mfm.matching(graph.v(e)) ? 1 : 0) ==
    242242          mfm.matching(e), "Invalid matching");
    243243  }
     
    293293    for (SmartGraph::EdgeIt e(graph); e != INVALID; ++e) {
    294294      check((e == mfm.matching(graph.u(e)) ? 1 : 0) +
    295             (e == mfm.matching(graph.v(e)) ? 1 : 0) == 
     295            (e == mfm.matching(graph.v(e)) ? 1 : 0) ==
    296296            mfm.matching(e), "Invalid matching");
    297297    }
     
    351351  for (SmartGraph::EdgeIt e(graph); e != INVALID; ++e) {
    352352    check((e == mwfm.matching(graph.u(e)) ? 1 : 0) +
    353           (e == mwfm.matching(graph.v(e)) ? 1 : 0) == 
     353          (e == mwfm.matching(graph.v(e)) ? 1 : 0) ==
    354354          mwfm.matching(e), "Invalid matching");
    355355  }
     
    411411  for (SmartGraph::EdgeIt e(graph); e != INVALID; ++e) {
    412412    check((e == mwpfm.matching(graph.u(e)) ? 1 : 0) +
    413           (e == mwpfm.matching(graph.v(e)) ? 1 : 0) == 
     413          (e == mwpfm.matching(graph.v(e)) ? 1 : 0) ==
    414414          mwpfm.matching(e), "Invalid matching");
    415415  }
  • test/gomory_hu_test.cc

    r596 r877  
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
     2 *
     3 * This file is a part of LEMON, a generic C++ optimization library.
     4 *
     5 * Copyright (C) 2003-2010
     6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8 *
     9 * Permission to use, modify and distribute this software is granted
     10 * provided that this copyright notice appears in all copies. For
     11 * precise terms see the accompanying LICENSE file.
     12 *
     13 * This software is provided "AS IS" with no warranty of any kind,
     14 * express or implied, and with no claim as to its suitability for any
     15 * purpose.
     16 *
     17 */
     18
    119#include <iostream>
    220
     
    3452  "source 0\n"
    3553  "target 3\n";
    36  
     54
    3755void checkGomoryHuCompile()
    3856{
     
    7088
    7189int cutValue(const Graph& graph, const BoolNodeMap& cut,
    72              const IntEdgeMap& capacity) {
     90             const IntEdgeMap& capacity) {
    7391
    7492  int sum = 0;
     
    108126      int sum=0;
    109127      for(GomoryHu<Graph>::MinCutEdgeIt a(ght, u, v);a!=INVALID;++a)
    110         sum+=capacity[a]; 
     128        sum+=capacity[a];
    111129      check(sum == ght.minCutValue(u, v), "Problem with MinCutEdgeIt");
    112130
     
    119137    }
    120138  }
    121  
     139
    122140  return 0;
    123141}
  • test/graph_test.cc

    r740 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    265265  checkGraphEdgeList(G, 3);
    266266  checkGraphArcList(G, 6);
    267  
     267
    268268  G.addEdge(G.addNode(), G.addNode());
    269269
     
    514514  G.resize(dim);
    515515  check(G.dimension() == dim, "Wrong dimension");
    516  
     516
    517517  checkGraphNodeList(G, 1 << dim);
    518518  checkGraphEdgeList(G, dim * (1 << (dim-1)));
  • test/hao_orlin_test.cc

    r597 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    8484
    8585template <typename Graph, typename CapMap, typename CutMap>
    86 typename CapMap::Value 
     86typename CapMap::Value
    8787  cutValue(const Graph& graph, const CapMap& cap, const CutMap& cut)
    8888{
     
    111111    ho.run();
    112112    ho.minCutMap(cut);
    113    
     113
    114114    check(ho.minCutValue() == 1, "Wrong cut value");
    115115    check(ho.minCutValue() == cutValue(graph, cap1, cut), "Wrong cut value");
     
    127127    ho.run();
    128128    ho.minCutMap(cut);
    129    
     129
    130130    check(ho.minCutValue() == 1, "Wrong cut value");
    131131    check(ho.minCutValue() == cutValue(graph, cap3, cut), "Wrong cut value");
    132132  }
    133  
     133
    134134  typedef Undirector<SmartDigraph> UGraph;
    135135  UGraph ugraph(graph);
    136  
     136
    137137  {
    138138    HaoOrlin<UGraph, SmartDigraph::ArcMap<int> > ho(ugraph, cap1);
    139139    ho.run();
    140140    ho.minCutMap(cut);
    141    
     141
    142142    check(ho.minCutValue() == 2, "Wrong cut value");
    143143    check(ho.minCutValue() == cutValue(ugraph, cap1, cut), "Wrong cut value");
     
    147147    ho.run();
    148148    ho.minCutMap(cut);
    149    
     149
    150150    check(ho.minCutValue() == 5, "Wrong cut value");
    151151    check(ho.minCutValue() == cutValue(ugraph, cap2, cut), "Wrong cut value");
     
    155155    ho.run();
    156156    ho.minCutMap(cut);
    157    
     157
    158158    check(ho.minCutValue() == 5, "Wrong cut value");
    159159    check(ho.minCutValue() == cutValue(ugraph, cap3, cut), "Wrong cut value");
  • test/maps_test.cc

    r789 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    226226
    227227    checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >();
    228     MapToFunctor<ReadMap<A,B> > map = MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>());
     228    MapToFunctor<ReadMap<A,B> > map =
     229      MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>());
    229230
    230231    check(functorToMap(&func)[A()] == 3,
     
    378379          it != map2.end(); ++it )
    379380      check(v1[i++] == *it, "Something is wrong with LoggerBoolMap");
    380    
     381
    381382    typedef ListDigraph Graph;
    382383    DIGRAPH_TYPEDEFS(Graph);
     
    387388    Node n2 = gr.addNode();
    388389    Node n3 = gr.addNode();
    389    
     390
    390391    gr.addArc(n3, n0);
    391392    gr.addArc(n3, n2);
     
    393394    gr.addArc(n2, n1);
    394395    gr.addArc(n0, n1);
    395    
     396
    396397    {
    397398      std::vector<Node> v;
     
    404405      std::vector<Node> v(countNodes(gr));
    405406      dfs(gr).processedMap(loggerBoolMap(v.begin())).run();
    406      
     407
    407408      check(v.size()==4 && v[0]==n1 && v[1]==n2 && v[2]==n0 && v[3]==n3,
    408409            "Something is wrong with LoggerBoolMap");
    409410    }
    410411  }
    411  
     412
    412413  // IdMap, RangeIdMap
    413414  {
     
    419420    checkConcept<ReadMap<Node, int>, RangeIdMap<Graph, Node> >();
    420421    checkConcept<ReadMap<Arc, int>, RangeIdMap<Graph, Arc> >();
    421    
     422
    422423    Graph gr;
    423424    IdMap<Graph, Node> nmap(gr);
     
    425426    RangeIdMap<Graph, Node> nrmap(gr);
    426427    RangeIdMap<Graph, Arc> armap(gr);
    427    
     428
    428429    Node n0 = gr.addNode();
    429430    Node n1 = gr.addNode();
    430431    Node n2 = gr.addNode();
    431    
     432
    432433    Arc a0 = gr.addArc(n0, n1);
    433434    Arc a1 = gr.addArc(n0, n2);
    434435    Arc a2 = gr.addArc(n2, n1);
    435436    Arc a3 = gr.addArc(n2, n0);
    436    
     437
    437438    check(nmap[n0] == gr.id(n0) && nmap(gr.id(n0)) == n0, "Wrong IdMap");
    438439    check(nmap[n1] == gr.id(n1) && nmap(gr.id(n1)) == n1, "Wrong IdMap");
     
    446447    check(nmap.inverse()[gr.id(n0)] == n0, "Wrong IdMap::InverseMap");
    447448    check(amap.inverse()[gr.id(a0)] == a0, "Wrong IdMap::InverseMap");
    448    
     449
    449450    check(nrmap.size() == 3 && armap.size() == 4,
    450451          "Wrong RangeIdMap::size()");
     
    453454    check(nrmap[n1] == 1 && nrmap(1) == n1, "Wrong RangeIdMap");
    454455    check(nrmap[n2] == 2 && nrmap(2) == n2, "Wrong RangeIdMap");
    455    
     456
    456457    check(armap[a0] == 0 && armap(0) == a0, "Wrong RangeIdMap");
    457458    check(armap[a1] == 1 && armap(1) == a1, "Wrong RangeIdMap");
     
    461462    check(nrmap.inverse()[0] == n0, "Wrong RangeIdMap::InverseMap");
    462463    check(armap.inverse()[0] == a0, "Wrong RangeIdMap::InverseMap");
    463    
     464
    464465    gr.erase(n1);
    465    
     466
    466467    if (nrmap[n0] == 1) nrmap.swap(n0, n2);
    467468    nrmap.swap(n2, n0);
    468469    if (armap[a1] == 1) armap.swap(a1, a3);
    469470    armap.swap(a3, a1);
    470    
     471
    471472    check(nrmap.size() == 2 && armap.size() == 2,
    472473          "Wrong RangeIdMap::size()");
     
    474475    check(nrmap[n0] == 1 && nrmap(1) == n0, "Wrong RangeIdMap");
    475476    check(nrmap[n2] == 0 && nrmap(0) == n2, "Wrong RangeIdMap");
    476    
     477
    477478    check(armap[a1] == 1 && armap(1) == a1, "Wrong RangeIdMap");
    478479    check(armap[a3] == 0 && armap(0) == a3, "Wrong RangeIdMap");
     
    481482    check(armap.inverse()[0] == a3, "Wrong RangeIdMap::InverseMap");
    482483  }
    483  
     484
    484485  // SourceMap, TargetMap, ForwardMap, BackwardMap, InDegMap, OutDegMap
    485486  {
    486487    typedef ListGraph Graph;
    487488    GRAPH_TYPEDEFS(Graph);
    488    
     489
    489490    checkConcept<ReadMap<Arc, Node>, SourceMap<Graph> >();
    490491    checkConcept<ReadMap<Arc, Node>, TargetMap<Graph> >();
     
    498499    Node n1 = gr.addNode();
    499500    Node n2 = gr.addNode();
    500    
     501
    501502    gr.addEdge(n0,n1);
    502503    gr.addEdge(n1,n2);
     
    505506    gr.addEdge(n1,n2);
    506507    gr.addEdge(n0,n1);
    507    
     508
    508509    for (EdgeIt e(gr); e != INVALID; ++e) {
    509510      check(forwardMap(gr)[e] == gr.direct(e, true), "Wrong ForwardMap");
    510511      check(backwardMap(gr)[e] == gr.direct(e, false), "Wrong BackwardMap");
    511512    }
    512    
     513
    513514    check(mapCompare(gr,
    514515          sourceMap(orienter(gr, constMap<Edge, bool>(true))),
     
    520521    OutDegMap<Digraph> odm(dgr);
    521522    InDegMap<Digraph> idm(dgr);
    522    
     523
    523524    check(odm[n0] == 3 && odm[n1] == 2 && odm[n2] == 1, "Wrong OutDegMap");
    524525    check(idm[n0] == 0 && idm[n1] == 3 && idm[n2] == 3, "Wrong InDegMap");
    525    
     526
    526527    gr.addEdge(n2, n0);
    527528
     
    529530    check(idm[n0] == 1 && idm[n1] == 3 && idm[n2] == 3, "Wrong InDegMap");
    530531  }
    531  
     532
    532533  // CrossRefMap
    533534  {
     
    541542    checkConcept<ReadWriteMap<Node, double>,
    542543                 CrossRefMap<Graph, Node, double> >();
    543    
     544
    544545    Graph gr;
    545546    typedef CrossRefMap<Graph, Node, char> CRMap;
    546547    CRMap map(gr);
    547    
     548
    548549    Node n0 = gr.addNode();
    549550    Node n1 = gr.addNode();
    550551    Node n2 = gr.addNode();
    551    
     552
    552553    map.set(n0, 'A');
    553554    map.set(n1, 'B');
    554555    map.set(n2, 'C');
    555    
     556
    556557    check(map[n0] == 'A' && map('A') == n0 && map.inverse()['A'] == n0,
    557558          "Wrong CrossRefMap");
     
    562563    check(map.count('A') == 1 && map.count('B') == 1 && map.count('C') == 1,
    563564          "Wrong CrossRefMap::count()");
    564    
     565
    565566    CRMap::ValueIt it = map.beginValue();
    566567    check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' &&
    567568          it == map.endValue(), "Wrong value iterator");
    568    
     569
    569570    map.set(n2, 'A');
    570571
     
    604605    checkConcept<ReadWriteMap<Node, int>,
    605606                 CrossRefMap<Graph, Node, int> >();
    606    
     607
    607608    Graph gr;
    608609    typedef CrossRefMap<Graph, Node, char> CRMap;
    609610    typedef CRMap::ValueIterator ValueIt;
    610611    CRMap map(gr);
    611    
     612
    612613    Node n0 = gr.addNode();
    613614    Node n1 = gr.addNode();
    614615    Node n2 = gr.addNode();
    615    
     616
    616617    map.set(n0, 'A');
    617618    map.set(n1, 'B');
     
    630631          it == map.endValue(), "Wrong value iterator");
    631632  }
    632  
     633
    633634  // Iterable bool map
    634635  {
     
    818819
    819820  }
    820  
     821
    821822  // Graph map utilities:
    822823  // mapMin(), mapMax(), mapMinValue(), mapMaxValue()
     
    830831    Node n2 = g.addNode();
    831832    Node n3 = g.addNode();
    832    
     833
    833834    SmartDigraph::NodeMap<int> map1(g);
    834835    SmartDigraph::ArcMap<char> map2(g);
    835836    ConstMap<Node, A> cmap1 = A();
    836837    ConstMap<Arc, C> cmap2 = C(0);
    837    
     838
    838839    map1[n1] = 10;
    839840    map1[n2] = 5;
    840841    map1[n3] = 12;
    841    
     842
    842843    // mapMin(), mapMax(), mapMinValue(), mapMaxValue()
    843844    check(mapMin(g, map1) == n2, "Wrong mapMin()");
     
    858859    Arc a3 = g.addArc(n2, n3);
    859860    Arc a4 = g.addArc(n3, n1);
    860    
     861
    861862    map2[a1] = 'b';
    862863    map2[a2] = 'a';
     
    925926    check(mapCountIf(g, map2, Less<char>('a')) == 0,
    926927          "Wrong mapCountIf()");
    927      
     928
    928929    // MapIt, ConstMapIt
    929930/*
     
    935936    check(*std::max_element(ConstMapIt(map1), ConstMapIt(INVALID)) == 12,
    936937          "Wrong NodeMap<>::MapIt");
    937    
     938
    938939    int sum = 0;
    939940    std::for_each(MapIt(map1), MapIt(INVALID), Sum<int>(sum));
     
    952953    SmartDigraph::NodeMap<int> map3(g, 0);
    953954    SmartDigraph::ArcMap<char> map4(g, 'a');
    954    
     955
    955956    check(!mapCompare(g, map1, map3), "Wrong mapCompare()");
    956     check(!mapCompare(g, map2, map4), "Wrong mapCompare()");   
    957    
     957    check(!mapCompare(g, map2, map4), "Wrong mapCompare()");
     958
    958959    mapCopy(g, map1, map3);
    959960    mapCopy(g, map2, map4);
    960961
    961962    check(mapCompare(g, map1, map3), "Wrong mapCompare() or mapCopy()");
    962     check(mapCompare(g, map2, map4), "Wrong mapCompare() or mapCopy()");   
    963    
     963    check(mapCompare(g, map2, map4), "Wrong mapCompare() or mapCopy()");
     964
    964965    Undirector<SmartDigraph> ug(g);
    965966    Undirector<SmartDigraph>::EdgeMap<char> umap1(ug, 'x');
    966967    Undirector<SmartDigraph>::ArcMap<double> umap2(ug, 3.14);
    967    
     968
    968969    check(!mapCompare(g, map2, umap1), "Wrong mapCompare() or mapCopy()");
    969970    check(!mapCompare(g, umap1, map2), "Wrong mapCompare() or mapCopy()");
    970971    check(!mapCompare(ug, map2, umap1), "Wrong mapCompare() or mapCopy()");
    971972    check(!mapCompare(ug, umap1, map2), "Wrong mapCompare() or mapCopy()");
    972    
     973
    973974    mapCopy(g, map2, umap1);
    974975
     
    977978    check(mapCompare(ug, map2, umap1), "Wrong mapCompare() or mapCopy()");
    978979    check(mapCompare(ug, umap1, map2), "Wrong mapCompare() or mapCopy()");
    979    
     980
    980981    mapCopy(g, map2, umap1);
    981982    mapCopy(g, umap1, map2);
    982983    mapCopy(ug, map2, umap1);
    983984    mapCopy(ug, umap1, map2);
    984    
     985
    985986    check(!mapCompare(ug, umap1, umap2), "Wrong mapCompare() or mapCopy()");
    986987    mapCopy(ug, umap1, umap2);
    987988    check(mapCompare(ug, umap1, umap2), "Wrong mapCompare() or mapCopy()");
    988    
     989
    989990    check(!mapCompare(g, map1, constMap<Node>(2)), "Wrong mapCompare()");
    990991    mapFill(g, map1, 2);
     
    995996    check(mapCompare(g, constMap<Arc>('z'), map2), "Wrong mapCopy()");
    996997  }
    997  
     998
    998999  return 0;
    9991000}
  • test/matching_test.cc

    r870 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    135135  mat_test.startDense();
    136136  mat_test.run();
    137  
     137
    138138  const_mat_test.matchingSize();
    139139  const_mat_test.matching(e);
     
    144144  const_mat_test.mate(n);
    145145
    146   MaxMatching<Graph>::Status stat = 
     146  MaxMatching<Graph>::Status stat =
    147147    const_mat_test.status(n);
    148148  const MaxMatching<Graph>::StatusMap& smap =
     
    171171  mat_test.start();
    172172  mat_test.run();
    173  
     173
    174174  const_mat_test.matchingWeight();
    175175  const_mat_test.matchingSize();
     
    180180  e = mmap[n];
    181181  const_mat_test.mate(n);
    182  
     182
    183183  int k = 0;
    184184  const_mat_test.dualValue();
     
    208208  mat_test.start();
    209209  mat_test.run();
    210  
     210
    211211  const_mat_test.matchingWeight();
    212212  const_mat_test.matching(e);
     
    216216  e = mmap[n];
    217217  const_mat_test.mate(n);
    218  
     218
    219219  int k = 0;
    220220  const_mat_test.dualValue();
     
    426426      MaxWeightedPerfectMatching<SmartGraph> mwpm(graph, weight);
    427427      bool result = mwpm.run();
    428      
     428
    429429      check(result == perfect, "Perfect matching found");
    430430      if (perfect) {
     
    437437      mwpm.init();
    438438      bool result = mwpm.start();
    439      
     439
    440440      check(result == perfect, "Perfect matching found");
    441441      if (perfect) {
  • test/min_cost_arborescence_test.cc

    r625 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    111111  b = const_mcarb_test.emptyQueue();
    112112  i = const_mcarb_test.queueSize();
    113  
     113
    114114  c = const_mcarb_test.arborescenceCost();
    115115  b = const_mcarb_test.arborescence(e);
     
    121121  b = const_mcarb_test.reached(n);
    122122  b = const_mcarb_test.processed(n);
    123  
     123
    124124  i = const_mcarb_test.dualNum();
    125125  c = const_mcarb_test.dualValue();
    126126  i = const_mcarb_test.dualSize(i);
    127127  c = const_mcarb_test.dualValue(i);
    128  
     128
    129129  ignore_unused_variable_warning(am);
    130130  ignore_unused_variable_warning(pm);
  • test/min_cost_flow_test.cc

    r830 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    5353  "   11     0    0    0    0  -10    0\n"
    5454  "   12   -20  -27    0  -30  -30  -20\n"
    55   "\n"               
     55  "\n"
    5656  "@arcs\n"
    5757  "       cost  cap low1 low2 low3\n"
     
    103103  "6 7     30      0  -1000\n"
    104104  "7 5   -120      0      0\n";
    105  
     105
    106106char test_neg2_lgf[] =
    107107  "@nodes\n"
     
    152152    void constraints() {
    153153      checkConcept<concepts::Digraph, GR>();
    154      
     154
    155155      const Constraints& me = *this;
    156156
     
    181181    typedef concepts::WriteMap<Arc, Value> FlowMap;
    182182    typedef concepts::WriteMap<Node, Cost> PotMap;
    183  
     183
    184184    GR g;
    185185    VAM lower;
     
    235235           typename CM, typename SM, typename FM, typename PM >
    236236bool checkPotential( const GR& gr, const LM& lower, const UM& upper,
    237                      const CM& cost, const SM& supply, const FM& flow, 
     237                     const CM& cost, const SM& supply, const FM& flow,
    238238                     const PM& pi, SupplyType type )
    239239{
     
    248248          (red_cost < 0 && flow[e] == upper[e]);
    249249  }
    250  
     250
    251251  for (NodeIt n(gr); opt && n != INVALID; ++n) {
    252252    typename SM::Value sum = 0;
     
    261261    }
    262262  }
    263  
     263
    264264  return opt;
    265265}
     
    286286    }
    287287  }
    288  
     288
    289289  for (NodeIt n(gr); n != INVALID; ++n) {
    290290    dual_cost -= red_supply[n] * pi[n];
     
    295295    dual_cost -= (upper[a] - lower[a]) * std::max(-red_cost, 0);
    296296  }
    297  
     297
    298298  return dual_cost == total;
    299299}
     
    333333{
    334334  MCF mcf1(gr), mcf2(neg1_gr), mcf3(neg2_gr);
    335  
     335
    336336  // Basic tests
    337337  mcf1.upperMap(u).costMap(c).supplyMap(s1);
     
    436436    .node("target", w)
    437437    .run();
    438  
     438
    439439  std::istringstream neg_inp1(test_neg1_lgf);
    440440  DigraphReader<Digraph>(neg1_gr, neg_inp1)
     
    444444    .nodeMap("sup", neg1_s)
    445445    .run();
    446  
     446
    447447  std::istringstream neg_inp2(test_neg2_lgf);
    448448  DigraphReader<Digraph>(neg2_gr, neg_inp2)
     
    450450    .nodeMap("sup", neg2_s)
    451451    .run();
    452  
     452
    453453  // Check the interface of NetworkSimplex
    454454  {
     
    502502
    503503  // Test NetworkSimplex
    504   { 
     504  {
    505505    typedef NetworkSimplex<Digraph> MCF;
    506506    runMcfGeqTests<MCF>(MCF::FIRST_ELIGIBLE, "NS-FE", true);
     
    515515    runMcfLeqTests<MCF>(MCF::ALTERING_LIST,  "NS-AL");
    516516  }
    517  
     517
    518518  // Test CapacityScaling
    519519  {
  • test/min_mean_cycle_test.cc

    r864 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    6262  "7 7    4    4    4   -1   0  0  0  1\n";
    6363
    64                        
     64
    6565// Check the interface of an MMC algorithm
    6666template <typename GR, typename Cost>
     
    7878      MmcAlg mmc(me.g, me.cost);
    7979      const MmcAlg& const_mmc = mmc;
    80      
     80
    8181      typename MmcAlg::Tolerance tol = const_mmc.tolerance();
    8282      mmc.tolerance(tol);
    83      
     83
    8484      b = mmc.cycle(p).run();
    8585      b = mmc.findCycleMean();
     
    9393
    9494    typedef concepts::ReadMap<typename GR::Arc, Cost> CM;
    95  
     95
    9696    GR g;
    9797    CM cost;
     
    154154    checkConcept< MmcClassConcept<GR, float>,
    155155                  KarpMmc<GR, concepts::ReadMap<GR::Arc, float> > >();
    156    
     156
    157157    // HartmannOrlinMmc
    158158    checkConcept< MmcClassConcept<GR, int>,
     
    160160    checkConcept< MmcClassConcept<GR, float>,
    161161                  HartmannOrlinMmc<GR, concepts::ReadMap<GR::Arc, float> > >();
    162    
     162
    163163    // HowardMmc
    164164    checkConcept< MmcClassConcept<GR, int>,
     
    177177    typedef SmartDigraph GR;
    178178    DIGRAPH_TYPEDEFS(GR);
    179    
     179
    180180    GR gr;
    181181    IntArcMap l1(gr), l2(gr), l3(gr), l4(gr);
    182182    IntArcMap c1(gr), c2(gr), c3(gr), c4(gr);
    183    
     183
    184184    std::istringstream input(test_lgf);
    185185    digraphReader(gr, input).
  • test/preflow_test.cc

    r689 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    9595  PreflowType preflow_test(g, cap, n, n);
    9696  const PreflowType& const_preflow_test = preflow_test;
    97  
     97
    9898  const PreflowType::Elevator& elev = const_preflow_test.elevator();
    9999  preflow_test.elevator(const_cast<PreflowType::Elevator&>(elev));
     
    119119  b = const_preflow_test.minCut(n);
    120120  const_preflow_test.minCutMap(cut);
    121  
     121
    122122  ignore_unused_variable_warning(fm);
    123123}
  • test/suurballe_test.cc

    r858 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    8282  typedef Digraph::Arc Arc;
    8383  typedef concepts::ReadMap<Arc, VType> LengthMap;
    84  
     84
    8585  typedef Suurballe<Digraph, LengthMap> ST;
    8686  typedef Suurballe<Digraph, LengthMap>
     
    115115  k = suurb_test.findFlow(n, k);
    116116  suurb_test.findPaths();
    117  
     117
    118118  int f;
    119119  VType c;
     
    127127  k = const_suurb_test.pathNum();
    128128  Path<Digraph> p = const_suurb_test.path(k);
    129  
     129
    130130  ignore_unused_variable_warning(fm);
    131131  ignore_unused_variable_warning(pm);
     
    209209  {
    210210    Suurballe<ListDigraph> suurballe(digraph, length);
    211    
     211
    212212    // Find 2 paths
    213213    check(suurballe.run(s, t) == 2, "Wrong number of paths");
     
    220220    for (int i = 0; i < suurballe.pathNum(); ++i)
    221221      check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path");
    222    
     222
    223223    // Find 3 paths
    224224    check(suurballe.run(s, t, 3) == 3, "Wrong number of paths");
     
    231231    for (int i = 0; i < suurballe.pathNum(); ++i)
    232232      check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path");
    233    
     233
    234234    // Find 5 paths (only 3 can be found)
    235235    check(suurballe.run(s, t, 5) == 3, "Wrong number of paths");
     
    243243      check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path");
    244244  }
    245  
     245
    246246  // Check fullInit() + start()
    247247  {
    248248    Suurballe<ListDigraph> suurballe(digraph, length);
    249249    suurballe.fullInit(s);
    250    
     250
    251251    // Find 2 paths
    252252    check(suurballe.start(t) == 2, "Wrong number of paths");
  • test/test_tools.h

    r763 r877  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    4646    } else { }                                                          \
    4747  }                                                                     \
    48    
     48
    4949
    5050#endif
Note: See TracChangeset for help on using the changeset viewer.