COIN-OR::LEMON - Graph Library

Changeset 964:7fdaa05a69a1 in lemon-1.2 for test/digraph_test.cc


Ignore:
Timestamp:
09/13/12 11:56:19 (7 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Parents:
961:4bb9e72e1a41 (diff), 963:761fe0846f49 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge #449 to branches >=1.2

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • test/digraph_test.cc

    r877 r964  
    6565      a3 = G.addArc(n2, n3),
    6666      a4 = G.addArc(n2, n3);
     67  ignore_unused_variable_warning(a2,a3,a4);
    6768
    6869  checkGraphNodeList(G, 3);
     
    9394  Arc a1 = G.addArc(n1, n2), a2 = G.addArc(n2, n1),
    9495      a3 = G.addArc(n2, n3), a4 = G.addArc(n2, n3);
     96  ignore_unused_variable_warning(a1,a2,a3,a4);
    9597
    9698  Node n4 = G.split(n2);
     
    126128      a3 = G.addArc(n4, n3), a4 = G.addArc(n4, n3),
    127129      a5 = G.addArc(n2, n4);
     130  ignore_unused_variable_warning(a1,a2,a3,a5);
    128131
    129132  checkGraphNodeList(G, 4);
     
    205208      a3 = G.addArc(n4, n3), a4 = G.addArc(n3, n1),
    206209      a5 = G.addArc(n2, n4);
     210  ignore_unused_variable_warning(a2,a3,a4,a5);
    207211
    208212  // Check arc deletion
     
    252256  Arc a1 = G.addArc(n1, n2), a2 = G.addArc(n2, n1),
    253257      a3 = G.addArc(n2, n3), a4 = G.addArc(n2, n3);
     258  ignore_unused_variable_warning(a1,a2,a3,a4);
    254259
    255260  typename Digraph::Snapshot snapshot(G);
     
    352357    e1 = g.addArc(n1, n2),
    353358    e2 = g.addArc(n2, n3);
     359  ignore_unused_variable_warning(e2);
    354360
    355361  check(g.valid(n1), "Wrong validity check");
  • test/digraph_test.cc

    r963 r964  
    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).
     
    2020#include <lemon/list_graph.h>
    2121#include <lemon/smart_graph.h>
     22#include <lemon/static_graph.h>
    2223#include <lemon/full_graph.h>
    2324
     
    3536  checkGraphNodeList(G, 0);
    3637  checkGraphArcList(G, 0);
     38
     39  G.reserveNode(3);
     40  G.reserveArc(4);
    3741
    3842  Node
     
    289293
    290294  snapshot.restore();
     295  snapshot.save(G);
     296
     297  checkGraphNodeList(G, 4);
     298  checkGraphArcList(G, 4);
     299
     300  G.addArc(G.addNode(), G.addNode());
     301
     302  snapshot.restore();
    291303
    292304  checkGraphNodeList(G, 4);
     
    323335    checkConcept<ClearableDigraphComponent<>, SmartDigraph>();
    324336  }
     337  { // Checking StaticDigraph
     338    checkConcept<Digraph, StaticDigraph>();
     339    checkConcept<ClearableDigraphComponent<>, StaticDigraph>();
     340  }
    325341  { // Checking FullDigraph
    326342    checkConcept<Digraph, FullDigraph>();
     
    379395}
    380396
     397void checkStaticDigraph() {
     398  SmartDigraph g;
     399  SmartDigraph::NodeMap<StaticDigraph::Node> nref(g);
     400  SmartDigraph::ArcMap<StaticDigraph::Arc> aref(g);
     401
     402  StaticDigraph G;
     403
     404  checkGraphNodeList(G, 0);
     405  checkGraphArcList(G, 0);
     406
     407  G.build(g, nref, aref);
     408
     409  checkGraphNodeList(G, 0);
     410  checkGraphArcList(G, 0);
     411
     412  SmartDigraph::Node
     413    n1 = g.addNode(),
     414    n2 = g.addNode(),
     415    n3 = g.addNode();
     416
     417  G.build(g, nref, aref);
     418
     419  checkGraphNodeList(G, 3);
     420  checkGraphArcList(G, 0);
     421
     422  SmartDigraph::Arc a1 = g.addArc(n1, n2);
     423
     424  G.build(g, nref, aref);
     425
     426  check(G.source(aref[a1]) == nref[n1] && G.target(aref[a1]) == nref[n2],
     427        "Wrong arc or wrong references");
     428  checkGraphNodeList(G, 3);
     429  checkGraphArcList(G, 1);
     430
     431  checkGraphOutArcList(G, nref[n1], 1);
     432  checkGraphOutArcList(G, nref[n2], 0);
     433  checkGraphOutArcList(G, nref[n3], 0);
     434
     435  checkGraphInArcList(G, nref[n1], 0);
     436  checkGraphInArcList(G, nref[n2], 1);
     437  checkGraphInArcList(G, nref[n3], 0);
     438
     439  checkGraphConArcList(G, 1);
     440
     441  SmartDigraph::Arc
     442    a2 = g.addArc(n2, n1),
     443    a3 = g.addArc(n2, n3),
     444    a4 = g.addArc(n2, n3);
     445
     446  digraphCopy(g, G).nodeRef(nref).run();
     447
     448  checkGraphNodeList(G, 3);
     449  checkGraphArcList(G, 4);
     450
     451  checkGraphOutArcList(G, nref[n1], 1);
     452  checkGraphOutArcList(G, nref[n2], 3);
     453  checkGraphOutArcList(G, nref[n3], 0);
     454
     455  checkGraphInArcList(G, nref[n1], 1);
     456  checkGraphInArcList(G, nref[n2], 1);
     457  checkGraphInArcList(G, nref[n3], 2);
     458
     459  checkGraphConArcList(G, 4);
     460
     461  std::vector<std::pair<int,int> > arcs;
     462  arcs.push_back(std::make_pair(0,1));
     463  arcs.push_back(std::make_pair(0,2));
     464  arcs.push_back(std::make_pair(1,3));
     465  arcs.push_back(std::make_pair(1,2));
     466  arcs.push_back(std::make_pair(3,0));
     467  arcs.push_back(std::make_pair(3,3));
     468  arcs.push_back(std::make_pair(4,2));
     469  arcs.push_back(std::make_pair(4,3));
     470  arcs.push_back(std::make_pair(4,1));
     471
     472  G.build(6, arcs.begin(), arcs.end());
     473
     474  checkGraphNodeList(G, 6);
     475  checkGraphArcList(G, 9);
     476
     477  checkGraphOutArcList(G, G.node(0), 2);
     478  checkGraphOutArcList(G, G.node(1), 2);
     479  checkGraphOutArcList(G, G.node(2), 0);
     480  checkGraphOutArcList(G, G.node(3), 2);
     481  checkGraphOutArcList(G, G.node(4), 3);
     482  checkGraphOutArcList(G, G.node(5), 0);
     483
     484  checkGraphInArcList(G, G.node(0), 1);
     485  checkGraphInArcList(G, G.node(1), 2);
     486  checkGraphInArcList(G, G.node(2), 3);
     487  checkGraphInArcList(G, G.node(3), 3);
     488  checkGraphInArcList(G, G.node(4), 0);
     489  checkGraphInArcList(G, G.node(5), 0);
     490
     491  checkGraphConArcList(G, 9);
     492
     493  checkNodeIds(G);
     494  checkArcIds(G);
     495  checkGraphNodeMap(G);
     496  checkGraphArcMap(G);
     497
     498  int n = G.nodeNum();
     499  int m = G.arcNum();
     500  check(G.index(G.node(n-1)) == n-1, "Wrong index.");
     501  check(G.index(G.arc(m-1)) == m-1, "Wrong index.");
     502}
     503
    381504void checkFullDigraph(int num) {
    382505  typedef FullDigraph Digraph;
    383506  DIGRAPH_TYPEDEFS(Digraph);
     507
    384508  Digraph G(num);
     509  check(G.nodeNum() == num && G.arcNum() == num * num, "Wrong size");
     510
     511  G.resize(num);
     512  check(G.nodeNum() == num && G.arcNum() == num * num, "Wrong size");
    385513
    386514  checkGraphNodeList(G, num);
     
    426554    checkDigraphValidity<SmartDigraph>();
    427555  }
     556  { // Checking StaticDigraph
     557    checkStaticDigraph();
     558  }
    428559  { // Checking FullDigraph
    429560    checkFullDigraph(8);
Note: See TracChangeset for help on using the changeset viewer.