COIN-OR::LEMON - Graph Library

Changeset 2039:dacc4ce9474d in lemon-0.x for test


Ignore:
Timestamp:
04/06/06 11:33:29 (14 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2678
Message:

Commiting The DynamicAsymMatrixMap? from Nagy Jano

+ MatrixMapTraits?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/matrix_maps_test.cc

    r1956 r2039  
    4141  typedef SmartGraph Graph;
    4242  typedef Graph::Node Node;
     43  typedef Graph::Edge Edge;
    4344
    4445  { // checking MatrixMap for int
     
    125126  }
    126127
     128  { // checking MatrixMap for int
     129    typedef DynamicAsymMatrixMap<Graph, Node, Graph, Edge, int> IntMatrixMap;
     130    checkConcept<ReferenceMatrixMap<Node, Edge, int,
     131      IntMatrixMap::Reference, IntMatrixMap::ConstReference>,
     132      IntMatrixMap>();
     133
     134  }
     135
     136  { // checking MatrixMap for bool
     137    typedef DynamicAsymMatrixMap<Graph, Node, Graph, Edge, bool> BoolMatrixMap;
     138    checkConcept<ReferenceMatrixMap<Node, Edge, bool,
     139      BoolMatrixMap::Reference, BoolMatrixMap::ConstReference>,
     140      BoolMatrixMap>();
     141
     142  }
     143
     144  {
     145    Graph graph1, graph2;
     146    typedef DynamicAsymMatrixMap<Graph, Node, Graph, Edge, int> IntMatrixMap;
     147    IntMatrixMap matrix(graph1, graph2);
     148    for (int i = 0; i < 10; ++i) {
     149      graph1.addNode();
     150    }
     151    graph2.addNode();
     152    for (int i = 0; i < 20; ++i) {
     153      graph2.addEdge(Graph::NodeIt(graph2), Graph::NodeIt(graph2));
     154    }
     155    for (Graph::NodeIt it(graph1); it != INVALID; ++it) {
     156      for (Graph::EdgeIt jt(graph2); jt != INVALID; ++jt) {
     157        int val = urandom(100);
     158        matrix.set(it, jt, val);
     159        check(matrix(it, jt) == val, "Wrong assign");
     160        check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
     161        check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
     162      }
     163    }
     164    const IntMatrixMap& cm = matrix;
     165    for (Graph::NodeIt it(graph1); it != INVALID; ++it) {
     166      for (Graph::EdgeIt jt(graph2); jt != INVALID; ++jt) {
     167        check(cm(it, jt) == matrixRowMap(cm, it)[jt], "Wrong rowMap");
     168        check(cm(it, jt) == matrixColMap(cm, jt)[it], "Wrong colMap");
     169      }
     170    }
     171  }
     172
     173  { // checking MatrixMap for int
     174    typedef DynamicAsymMatrixMap<Graph, Node, Graph, Node, int> IntMatrixMap;
     175    checkConcept<ReferenceMatrixMap<Node, Node, int,
     176      IntMatrixMap::Reference, IntMatrixMap::ConstReference>,
     177      IntMatrixMap>();
     178
     179  }
     180
     181  { // checking MatrixMap for bool
     182    typedef DynamicAsymMatrixMap<Graph, Node, Graph, Node, bool> BoolMatrixMap;
     183    checkConcept<ReferenceMatrixMap<Node, Node, bool,
     184      BoolMatrixMap::Reference, BoolMatrixMap::ConstReference>,
     185      BoolMatrixMap>();
     186
     187  }
     188
     189  {
     190    Graph graph;
     191    typedef DynamicAsymMatrixMap<Graph, Node, Graph, Node, int> IntMatrixMap;
     192    IntMatrixMap matrix(graph, graph);
     193    for (int i = 0; i < 10; ++i) {
     194      graph.addNode();
     195    }
     196    for (int i = 0; i < 20; ++i) {
     197      graph.addEdge(Graph::NodeIt(graph), Graph::NodeIt(graph));
     198    }
     199    for (Graph::NodeIt it(graph); it != INVALID; ++it) {
     200      for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
     201        int val = urandom(100);
     202        matrix.set(it, jt, val);
     203        check(matrix(it, jt) == val, "Wrong assign");
     204        check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
     205        check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
     206      }
     207    }
     208    const IntMatrixMap& cm = matrix;
     209    for (Graph::NodeIt it(graph); it != INVALID; ++it) {
     210      for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
     211        check(cm(it, jt) == matrixRowMap(cm, it)[jt], "Wrong rowMap");
     212        check(cm(it, jt) == matrixColMap(cm, jt)[it], "Wrong colMap");
     213      }
     214    }
     215  }
     216
    127217  std::cout << __FILE__ ": All tests passed.\n";
    128218
Note: See TracChangeset for help on using the changeset viewer.