// -*- c++ -*- #include #include #include #include #include #include #include #include #include "test_tools.h" #include "graph_test.h" #include "map_test.h" using namespace lemon; using namespace lemon::concept; int main() { typedef SmartGraph Graph; typedef Graph::Node Node; { // checking MatrixMap for int typedef DynamicMatrixMap IntMatrixMap; checkConcept, IntMatrixMap>(); } { // checking MatrixMap for bool typedef DynamicMatrixMap BoolMatrixMap; checkConcept, BoolMatrixMap>(); } { Graph graph; typedef DynamicMatrixMap IntMatrixMap; IntMatrixMap matrix(graph); for (int i = 0; i < 10; ++i) { graph.addNode(); } for (Graph::NodeIt it(graph); it != INVALID; ++it) { for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) { int val = urandom(100); matrix.set(it, jt, val); check(matrix(it, jt) == val, "Wrong assign"); check(matrix(it, jt) == matrixColMap(matrix, it)[jt], "Wrong colMap"); check(matrix(it, jt) == matrixRowMap(matrix, jt)[it], "Wrong rowMap"); } } const IntMatrixMap& cm = matrix; for (Graph::NodeIt it(graph); it != INVALID; ++it) { for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) { check(cm(it, jt) == matrixColMap(cm, it)[jt], "Wrong colMap"); check(cm(it, jt) == matrixRowMap(cm, jt)[it], "Wrong rowMap"); } } } { // checking MatrixMap for int typedef DynamicSymMatrixMap IntMatrixMap; checkConcept, IntMatrixMap>(); } { // checking MatrixMap for bool typedef DynamicSymMatrixMap BoolMatrixMap; checkConcept, BoolMatrixMap>(); } { Graph graph; typedef DynamicSymMatrixMap IntMatrixMap; IntMatrixMap matrix(graph); for (int i = 0; i < 10; ++i) { graph.addNode(); } for (Graph::NodeIt it(graph); it != INVALID; ++it) { for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) { int val = urandom(100); matrix.set(it, jt, val); check(matrix(it, jt) == val, "Wrong assign"); check(matrix(jt, it) == val, "Wrong assign"); check(matrix(it, jt) == matrixColMap(matrix, it)[jt], "Wrong colMap"); check(matrix(it, jt) == matrixRowMap(matrix, jt)[it], "Wrong rowMap"); } } const IntMatrixMap& cm = matrix; for (Graph::NodeIt it(graph); it != INVALID; ++it) { for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) { check(cm(it, jt) == matrixColMap(cm, it)[jt], "Wrong colMap"); check(cm(it, jt) == matrixRowMap(cm, jt)[it], "Wrong rowMap"); } } } std::cout << __FILE__ ": All tests passed.\n"; return 0; }