alpar@1956: /* -*- C++ -*- alpar@1956: * alpar@1956: * This file is a part of LEMON, a generic C++ optimization library alpar@1956: * alpar@1956: * Copyright (C) 2003-2006 alpar@1956: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@1956: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@1956: * alpar@1956: * Permission to use, modify and distribute this software is granted alpar@1956: * provided that this copyright notice appears in all copies. For alpar@1956: * precise terms see the accompanying LICENSE file. alpar@1956: * alpar@1956: * This software is provided "AS IS" with no warranty of any kind, alpar@1956: * express or implied, and with no claim as to its suitability for any alpar@1956: * purpose. alpar@1956: * alpar@1956: */ deba@1728: deba@1728: #include deba@1728: #include deba@1728: deba@1728: #include deba@1728: deba@1728: #include deba@1728: #include deba@1728: #include deba@1728: deba@1728: #include deba@1728: deba@1728: #include deba@1728: deba@1728: #include "test_tools.h" deba@1728: #include "graph_test.h" deba@1728: #include "map_test.h" deba@1728: deba@1728: deba@1728: using namespace lemon; deba@1728: using namespace lemon::concept; deba@1728: deba@1728: int main() { deba@1728: typedef SmartGraph Graph; deba@1728: typedef Graph::Node Node; deba@1728: deba@1728: { // checking MatrixMap for int deba@1728: typedef DynamicMatrixMap IntMatrixMap; deba@1728: checkConcept, deba@1728: IntMatrixMap>(); deba@1728: deba@1728: } deba@1728: deba@1728: { // checking MatrixMap for bool deba@1728: typedef DynamicMatrixMap BoolMatrixMap; deba@1728: checkConcept, deba@1728: BoolMatrixMap>(); deba@1728: deba@1728: } deba@1728: deba@1728: { deba@1728: Graph graph; deba@1728: typedef DynamicMatrixMap IntMatrixMap; deba@1728: IntMatrixMap matrix(graph); deba@1728: for (int i = 0; i < 10; ++i) { deba@1728: graph.addNode(); deba@1728: } deba@1728: for (Graph::NodeIt it(graph); it != INVALID; ++it) { deba@1728: for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) { deba@1728: int val = urandom(100); deba@1728: matrix.set(it, jt, val); deba@1728: check(matrix(it, jt) == val, "Wrong assign"); deba@1751: check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap"); deba@1751: check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap"); deba@1728: } deba@1728: } deba@1728: const IntMatrixMap& cm = matrix; deba@1728: for (Graph::NodeIt it(graph); it != INVALID; ++it) { deba@1728: for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) { deba@1751: check(cm(it, jt) == matrixRowMap(cm, it)[jt], "Wrong rowMap"); deba@1751: check(cm(it, jt) == matrixColMap(cm, jt)[it], "Wrong colMap"); deba@1728: } deba@1728: } deba@1728: } deba@1728: deba@1728: { // checking MatrixMap for int deba@1728: typedef DynamicSymMatrixMap IntMatrixMap; deba@1728: checkConcept, deba@1728: IntMatrixMap>(); deba@1728: deba@1728: } deba@1728: deba@1728: { // checking MatrixMap for bool deba@1728: typedef DynamicSymMatrixMap BoolMatrixMap; deba@1728: checkConcept, deba@1728: BoolMatrixMap>(); deba@1728: deba@1728: } deba@1728: deba@1728: { deba@1728: Graph graph; deba@1728: typedef DynamicSymMatrixMap IntMatrixMap; deba@1728: IntMatrixMap matrix(graph); deba@1728: for (int i = 0; i < 10; ++i) { deba@1728: graph.addNode(); deba@1728: } deba@1728: for (Graph::NodeIt it(graph); it != INVALID; ++it) { deba@1728: for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) { deba@1728: int val = urandom(100); deba@1728: matrix.set(it, jt, val); deba@1728: check(matrix(it, jt) == val, "Wrong assign"); deba@1728: check(matrix(jt, it) == val, "Wrong assign"); deba@1751: check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap"); deba@1751: check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap"); deba@1728: } deba@1728: } deba@1728: const IntMatrixMap& cm = matrix; deba@1728: for (Graph::NodeIt it(graph); it != INVALID; ++it) { deba@1728: for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) { deba@1751: check(cm(it, jt) == matrixRowMap(cm, it)[jt], "Wrong rowMap"); deba@1751: check(cm(it, jt) == matrixColMap(cm, jt)[it], "Wrong colMap"); deba@1728: } deba@1728: } deba@1728: } deba@1728: deba@1728: std::cout << __FILE__ ": All tests passed.\n"; deba@1728: deba@1728: return 0; deba@1728: }