- Increased max. number of iteration
- Better tests.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
22 #include <lemon/concept_check.h>
24 #include <lemon/concept/matrix_maps.h>
25 #include <lemon/concept/maps.h>
26 #include <lemon/concept/graph.h>
28 #include <lemon/matrix_maps.h>
30 #include <lemon/smart_graph.h>
32 #include "test_tools.h"
33 #include "graph_test.h"
37 using namespace lemon;
38 using namespace lemon::concept;
41 typedef SmartGraph Graph;
42 typedef Graph::Node Node;
44 { // checking MatrixMap for int
45 typedef DynamicMatrixMap<Graph, Node, int> IntMatrixMap;
46 checkConcept<ReferenceMatrixMap<Node, Node, int,
47 IntMatrixMap::Reference, IntMatrixMap::ConstReference>,
52 { // checking MatrixMap for bool
53 typedef DynamicMatrixMap<Graph, Node, bool> BoolMatrixMap;
54 checkConcept<ReferenceMatrixMap<Node, Node, bool,
55 BoolMatrixMap::Reference, BoolMatrixMap::ConstReference>,
62 typedef DynamicMatrixMap<Graph, Node, int> IntMatrixMap;
63 IntMatrixMap matrix(graph);
64 for (int i = 0; i < 10; ++i) {
67 for (Graph::NodeIt it(graph); it != INVALID; ++it) {
68 for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
69 int val = urandom(100);
70 matrix.set(it, jt, val);
71 check(matrix(it, jt) == val, "Wrong assign");
72 check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
73 check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
76 const IntMatrixMap& cm = matrix;
77 for (Graph::NodeIt it(graph); it != INVALID; ++it) {
78 for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
79 check(cm(it, jt) == matrixRowMap(cm, it)[jt], "Wrong rowMap");
80 check(cm(it, jt) == matrixColMap(cm, jt)[it], "Wrong colMap");
85 { // checking MatrixMap for int
86 typedef DynamicSymMatrixMap<Graph, Node, int> IntMatrixMap;
87 checkConcept<ReferenceMatrixMap<Node, Node, int,
88 IntMatrixMap::Reference, IntMatrixMap::ConstReference>,
93 { // checking MatrixMap for bool
94 typedef DynamicSymMatrixMap<Graph, Node, bool> BoolMatrixMap;
95 checkConcept<ReferenceMatrixMap<Node, Node, bool,
96 BoolMatrixMap::Reference, BoolMatrixMap::ConstReference>,
103 typedef DynamicSymMatrixMap<Graph, Node, int> IntMatrixMap;
104 IntMatrixMap matrix(graph);
105 for (int i = 0; i < 10; ++i) {
108 for (Graph::NodeIt it(graph); it != INVALID; ++it) {
109 for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
110 int val = urandom(100);
111 matrix.set(it, jt, val);
112 check(matrix(it, jt) == val, "Wrong assign");
113 check(matrix(jt, it) == val, "Wrong assign");
114 check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
115 check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
118 const IntMatrixMap& cm = matrix;
119 for (Graph::NodeIt it(graph); it != INVALID; ++it) {
120 for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
121 check(cm(it, jt) == matrixRowMap(cm, it)[jt], "Wrong rowMap");
122 check(cm(it, jt) == matrixColMap(cm, jt)[it], "Wrong colMap");
127 std::cout << __FILE__ ": All tests passed.\n";