Small fixes in README.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2008
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/concepts/matrix_maps.h>
25 #include <lemon/concepts/maps.h>
26 #include <lemon/concepts/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::concepts;
41 typedef SmartGraph Graph;
42 typedef Graph::Node Node;
43 typedef Graph::Edge Edge;
45 { // checking MatrixMap for int
46 typedef DynamicMatrixMap<Graph, Node, int> IntMatrixMap;
47 checkConcept<ReferenceMatrixMap<Node, Node, int,
48 IntMatrixMap::Reference, IntMatrixMap::ConstReference>,
53 { // checking MatrixMap for bool
54 typedef DynamicMatrixMap<Graph, Node, bool> BoolMatrixMap;
55 checkConcept<ReferenceMatrixMap<Node, Node, bool,
56 BoolMatrixMap::Reference, BoolMatrixMap::ConstReference>,
63 typedef DynamicMatrixMap<Graph, Node, int> IntMatrixMap;
64 IntMatrixMap matrix(graph);
65 for (int i = 0; i < 10; ++i) {
68 for (Graph::NodeIt it(graph); it != INVALID; ++it) {
69 for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
71 matrix.set(it, jt, val);
72 check(matrix(it, jt) == val, "Wrong assign");
73 check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
74 check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
77 const IntMatrixMap& cm = matrix;
78 for (Graph::NodeIt it(graph); it != INVALID; ++it) {
79 for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
80 check(cm(it, jt) == matrixRowMap(cm, it)[jt], "Wrong rowMap");
81 check(cm(it, jt) == matrixColMap(cm, jt)[it], "Wrong colMap");
86 { // checking MatrixMap for int
87 typedef DynamicSymMatrixMap<Graph, Node, int> IntMatrixMap;
88 checkConcept<ReferenceMatrixMap<Node, Node, int,
89 IntMatrixMap::Reference, IntMatrixMap::ConstReference>,
94 { // checking MatrixMap for bool
95 typedef DynamicSymMatrixMap<Graph, Node, bool> BoolMatrixMap;
96 checkConcept<ReferenceMatrixMap<Node, Node, bool,
97 BoolMatrixMap::Reference, BoolMatrixMap::ConstReference>,
104 typedef DynamicSymMatrixMap<Graph, Node, int> IntMatrixMap;
105 IntMatrixMap matrix(graph);
106 for (int i = 0; i < 10; ++i) {
109 for (Graph::NodeIt it(graph); it != INVALID; ++it) {
110 for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
112 matrix.set(it, jt, val);
113 check(matrix(it, jt) == val, "Wrong assign");
114 check(matrix(jt, it) == val, "Wrong assign");
115 check(matrix(it, jt) == matrixRowMap(matrix, it)[jt], "Wrong rowMap");
116 check(matrix(it, jt) == matrixColMap(matrix, jt)[it], "Wrong colMap");
119 const IntMatrixMap& cm = matrix;
120 for (Graph::NodeIt it(graph); it != INVALID; ++it) {
121 for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
122 check(cm(it, jt) == matrixRowMap(cm, it)[jt], "Wrong rowMap");
123 check(cm(it, jt) == matrixColMap(cm, jt)[it], "Wrong colMap");
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>,
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>,
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) {
152 for (int i = 0; i < 20; ++i) {
153 graph2.addEdge(Graph::NodeIt(graph2), Graph::NodeIt(graph2));
155 for (Graph::NodeIt it(graph1); it != INVALID; ++it) {
156 for (Graph::EdgeIt jt(graph2); jt != INVALID; ++jt) {
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");
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");
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>,
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>,
191 typedef DynamicAsymMatrixMap<Graph, Node, Graph, Node, int> IntMatrixMap;
192 IntMatrixMap matrix(graph, graph);
193 for (int i = 0; i < 10; ++i) {
196 for (int i = 0; i < 20; ++i) {
197 graph.addEdge(Graph::NodeIt(graph), Graph::NodeIt(graph));
199 for (Graph::NodeIt it(graph); it != INVALID; ++it) {
200 for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
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");
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");
217 std::cout << __FILE__ ": All tests passed.\n";