COIN-OR::LEMON - Graph Library

Changeset 1188:5ef0ab7b61cd in lemon for test/bpgraph_test.cc


Ignore:
Timestamp:
11/14/10 22:48:32 (13 years ago)
Author:
Balazs Dezso <deba@…>
Branch:
default
Phase:
public
Message:

FullBpGraph? implementation (#69)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/bpgraph_test.cc

    r1187 r1188  
    2020//#include <lemon/list_graph.h>
    2121#include <lemon/smart_graph.h>
    22 //#include <lemon/full_graph.h>
     22#include <lemon/full_graph.h>
    2323
    2424#include "test_tools.h"
     
    251251}
    252252
     253void checkFullBpGraph(int redNum, int blueNum) {
     254  typedef FullBpGraph BpGraph;
     255  BPGRAPH_TYPEDEFS(BpGraph);
     256
     257  BpGraph G(redNum, blueNum);
     258  checkGraphNodeList(G, redNum + blueNum);
     259  checkGraphRedNodeList(G, redNum);
     260  checkGraphBlueNodeList(G, blueNum);
     261  checkGraphEdgeList(G, redNum * blueNum);
     262  checkGraphArcList(G, 2 * redNum * blueNum);
     263
     264  G.resize(redNum, blueNum);
     265  checkGraphNodeList(G, redNum + blueNum);
     266  checkGraphRedNodeList(G, redNum);
     267  checkGraphBlueNodeList(G, blueNum);
     268  checkGraphEdgeList(G, redNum * blueNum);
     269  checkGraphArcList(G, 2 * redNum * blueNum);
     270
     271  for (RedIt n(G); n != INVALID; ++n) {
     272    checkGraphOutArcList(G, n, blueNum);
     273    checkGraphInArcList(G, n, blueNum);
     274    checkGraphIncEdgeList(G, n, blueNum);
     275  }
     276
     277  for (BlueIt n(G); n != INVALID; ++n) {
     278    checkGraphOutArcList(G, n, redNum);
     279    checkGraphInArcList(G, n, redNum);
     280    checkGraphIncEdgeList(G, n, redNum);
     281  }
     282
     283  checkGraphConArcList(G, 2 * redNum * blueNum);
     284  checkGraphConEdgeList(G, redNum * blueNum);
     285
     286  checkArcDirections(G);
     287
     288  checkNodeIds(G);
     289  checkRedNodeIds(G);
     290  checkBlueNodeIds(G);
     291  checkArcIds(G);
     292  checkEdgeIds(G);
     293
     294  checkGraphNodeMap(G);
     295  checkGraphRedMap(G);
     296  checkGraphBlueMap(G);
     297  checkGraphArcMap(G);
     298  checkGraphEdgeMap(G);
     299
     300  for (int i = 0; i < G.redNum(); ++i) {
     301    check(G.red(G.redNode(i)), "Wrong node");
     302    check(G.redIndex(G.redNode(i)) == i, "Wrong index");
     303  }
     304
     305  for (int i = 0; i < G.blueNum(); ++i) {
     306    check(G.blue(G.blueNode(i)), "Wrong node");
     307    check(G.blueIndex(G.blueNode(i)) == i, "Wrong index");
     308  }
     309
     310  for (NodeIt u(G); u != INVALID; ++u) {
     311    for (NodeIt v(G); v != INVALID; ++v) {
     312      Edge e = G.edge(u, v);
     313      Arc a = G.arc(u, v);
     314      if (G.red(u) == G.red(v)) {
     315        check(e == INVALID, "Wrong edge lookup");
     316        check(a == INVALID, "Wrong arc lookup");
     317      } else {
     318        check((G.u(e) == u && G.v(e) == v) ||
     319              (G.u(e) == v && G.v(e) == u), "Wrong edge lookup");
     320        check(G.source(a) == u && G.target(a) == v, "Wrong arc lookup");
     321      }
     322    }
     323  }
     324
     325}
     326
    253327void checkGraphs() {
    254328  { // Checking SmartGraph
     
    257331    checkBpGraphValidity<SmartBpGraph>();
    258332  }
     333  { // Checking FullBpGraph
     334    checkFullBpGraph(6, 8);
     335    checkFullBpGraph(7, 4);
     336  }
    259337}
    260338
Note: See TracChangeset for help on using the changeset viewer.