COIN-OR::LEMON - Graph Library

Changeset 1568:f694f75de683 in lemon-0.x


Ignore:
Timestamp:
07/18/05 17:10:22 (19 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2067
Message:

Improving tests.

Location:
test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • test/graph_utils_test.cc

    r1459 r1568  
    5151  { // checking list graph
    5252    checkGraphCounters<ListGraph>();
     53    checkFindEdge<ListGraph>();
    5354  }
    5455  { // checking smart graph
    5556    checkGraphCounters<SmartGraph>();
     57    checkFindEdge<SmartGraph>();
    5658  }
    5759  {
     
    5961    FullGraph fg(num);
    6062    check(countNodes(fg) == num, "FullGraph: wrong node number.");
    61     check(countEdges(fg) == num*num, "FullGraph: wrong edge number.");   
     63    check(countEdges(fg) == num*num, "FullGraph: wrong edge number.");
     64    for (FullGraph::NodeIt src(fg); src != INVALID; ++src) {
     65      for (FullGraph::NodeIt trg(fg); trg != INVALID; ++trg) {
     66        ConEdgeIt<FullGraph> con(fg, src, trg);
     67        check(con != INVALID, "There is no connecting edge.");
     68        check(fg.source(con) == src, "Wrong source.");
     69        check(fg.target(con) == trg, "Wrong target.");
     70        check(++con == INVALID, "There is more connecting edge.");
     71      }
     72    }
    6273  }
    6374
  • test/graph_utils_test.h

    r1435 r1568  
    1919
    2020#include "test_tools.h"
     21#include <cstdlib>
     22#include <ctime>
    2123
    2224//! \ingroup misc
     
    3840    }
    3941  }
     42
     43  template <typename Graph>
     44  void checkFindEdge() {
     45    typedef typename Graph::Node Node;
     46    typedef typename Graph::Edge Edge;
     47    typedef typename Graph::NodeIt NodeIt;
     48    typedef typename Graph::EdgeIt EdgeIt;
     49    Graph graph;
     50    srand(time(0));
     51    for (int i = 0; i < 10; ++i) {
     52      graph.addNode();
     53    }
     54    DescriptorMap<Graph, Node> nodes(graph);
     55    typename DescriptorMap<Graph, Node>::InverseMap invNodes(nodes);
     56    for (int i = 0; i < 100; ++i) {
     57      int src = (int)(rand() / (RAND_MAX + 1.0) * invNodes.size());
     58      int trg = (int)(rand() / (RAND_MAX + 1.0) * invNodes.size());
     59      graph.addEdge(invNodes[src], invNodes[trg]);
     60    }
     61    typename Graph::template EdgeMap<bool> found(graph, false);
     62    DescriptorMap<Graph, Edge> edges(graph);
     63    for (NodeIt src(graph); src != INVALID; ++src) {
     64      for (NodeIt trg(graph); trg != INVALID; ++trg) {
     65        for (ConEdgeIt<Graph> con(graph, src, trg); con != INVALID; ++con) {
     66          check(graph.source(con) == src, "Wrong source.");
     67          check(graph.target(con) == trg, "Wrong target.");
     68          check(found[con] == false, "The edge found already.");
     69          found[con] = true;
     70        }
     71      }
     72    }
     73    for (EdgeIt it(graph); it != INVALID; ++it) {
     74      check(found[it] == true, "The edge is not found.");
     75    }
     76  }
    4077 
    4178} //namespace lemon
  • test/undir_graph_test.cc

    r1435 r1568  
    4040  checkConcept<UndirGraph, UndirSmartGraph>();
    4141  checkConcept<ExtendableUndirGraph, UndirSmartGraph>();
     42
     43  checkConcept<UndirGraph, UndirFullGraph>();
    4244
    4345  checkConcept<UndirGraph, UndirGraph>();
     
    117119  check_graph<UndirSmartGraph>();
    118120
     121  {
     122    UndirFullGraph g(5);
     123    check_item_counts(g, 5, 10);
     124  }
     125
    119126  return 0;
    120127}
Note: See TracChangeset for help on using the changeset viewer.