deba@1728: // -*- c++ -*- 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: }