Location: LEMON/LEMON-official/test/graph_test.cc - annotation
Load file history
Fix several doxygen warnings
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | r209:765619b7cbb2 r57:c1acf0018c0a r209:765619b7cbb2 r57:c1acf0018c0a r107:31a2e6d28f61 r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r109:abddaa08b507 r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r171:02f4d5d9bfd7 r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r228:b6732e0d38c5 r171:02f4d5d9bfd7 r57:c1acf0018c0a r57:c1acf0018c0a r209:765619b7cbb2 r57:c1acf0018c0a r57:c1acf0018c0a r209:765619b7cbb2 r57:c1acf0018c0a r57:c1acf0018c0a r209:765619b7cbb2 r57:c1acf0018c0a r57:c1acf0018c0a r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r57:c1acf0018c0a r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r228:b6732e0d38c5 r149:2f7ae34e1333 r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r57:c1acf0018c0a r57:c1acf0018c0a r149:2f7ae34e1333 r228:b6732e0d38c5 r149:2f7ae34e1333 r149:2f7ae34e1333 r149:2f7ae34e1333 r149:2f7ae34e1333 r149:2f7ae34e1333 r149:2f7ae34e1333 r149:2f7ae34e1333 r149:2f7ae34e1333 r149:2f7ae34e1333 r149:2f7ae34e1333 r149:2f7ae34e1333 r149:2f7ae34e1333 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r149:2f7ae34e1333 r149:2f7ae34e1333 r149:2f7ae34e1333 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r149:2f7ae34e1333 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r149:2f7ae34e1333 r149:2f7ae34e1333 r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r209:765619b7cbb2 r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r209:765619b7cbb2 r57:c1acf0018c0a r209:765619b7cbb2 r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r209:765619b7cbb2 r57:c1acf0018c0a r209:765619b7cbb2 r57:c1acf0018c0a r57:c1acf0018c0a r57:c1acf0018c0a r228:b6732e0d38c5 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r228:b6732e0d38c5 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r228:b6732e0d38c5 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r171:02f4d5d9bfd7 r57:c1acf0018c0a r228:b6732e0d38c5 r228:b6732e0d38c5 r57:c1acf0018c0a r57:c1acf0018c0a | /* -*- mode: C++; indent-tabs-mode: nil; -*-
*
* This file is a part of LEMON, a generic C++ optimization library.
*
* Copyright (C) 2003-2008
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
* (Egervary Research Group on Combinatorial Optimization, EGRES).
*
* Permission to use, modify and distribute this software is granted
* provided that this copyright notice appears in all copies. For
* precise terms see the accompanying LICENSE file.
*
* This software is provided "AS IS" with no warranty of any kind,
* express or implied, and with no claim as to its suitability for any
* purpose.
*
*/
#include <lemon/concepts/graph.h>
#include <lemon/list_graph.h>
#include <lemon/smart_graph.h>
// #include <lemon/full_graph.h>
// #include <lemon/grid_graph.h>
#include "test_tools.h"
#include "graph_test.h"
using namespace lemon;
using namespace lemon::concepts;
template <class Graph>
void checkGraph() {
TEMPLATE_GRAPH_TYPEDEFS(Graph);
Graph G;
checkGraphNodeList(G, 0);
checkGraphEdgeList(G, 0);
Node
n1 = G.addNode(),
n2 = G.addNode(),
n3 = G.addNode();
checkGraphNodeList(G, 3);
checkGraphEdgeList(G, 0);
Edge e1 = G.addEdge(n1, n2);
check((G.u(e1) == n1 && G.v(e1) == n2) || (G.u(e1) == n2 && G.v(e1) == n1),
"Wrong edge");
checkGraphNodeList(G, 3);
checkGraphArcList(G, 2);
checkGraphEdgeList(G, 1);
checkGraphOutArcList(G, n1, 1);
checkGraphOutArcList(G, n2, 1);
checkGraphOutArcList(G, n3, 0);
checkGraphInArcList(G, n1, 1);
checkGraphInArcList(G, n2, 1);
checkGraphInArcList(G, n3, 0);
checkGraphIncEdgeList(G, n1, 1);
checkGraphIncEdgeList(G, n2, 1);
checkGraphIncEdgeList(G, n3, 0);
checkGraphConArcList(G, 2);
checkGraphConEdgeList(G, 1);
Edge e2 = G.addEdge(n2, n1), e3 = G.addEdge(n2, n3);
checkGraphNodeList(G, 3);
checkGraphArcList(G, 6);
checkGraphEdgeList(G, 3);
checkGraphOutArcList(G, n1, 2);
checkGraphOutArcList(G, n2, 3);
checkGraphOutArcList(G, n3, 1);
checkGraphInArcList(G, n1, 2);
checkGraphInArcList(G, n2, 3);
checkGraphInArcList(G, n3, 1);
checkGraphIncEdgeList(G, n1, 2);
checkGraphIncEdgeList(G, n2, 3);
checkGraphIncEdgeList(G, n3, 1);
checkGraphConArcList(G, 6);
checkGraphConEdgeList(G, 3);
checkArcDirections(G);
checkNodeIds(G);
checkArcIds(G);
checkEdgeIds(G);
checkGraphNodeMap(G);
checkGraphArcMap(G);
checkGraphEdgeMap(G);
}
void checkConcepts() {
{ // Checking graph components
checkConcept<BaseGraphComponent, BaseGraphComponent >();
checkConcept<IDableGraphComponent<>,
IDableGraphComponent<> >();
checkConcept<IterableGraphComponent<>,
IterableGraphComponent<> >();
checkConcept<MappableGraphComponent<>,
MappableGraphComponent<> >();
}
{ // Checking skeleton graph
checkConcept<Graph, Graph>();
}
{ // Checking ListGraph
checkConcept<Graph, ListGraph>();
checkConcept<AlterableGraphComponent<>, ListGraph>();
checkConcept<ExtendableGraphComponent<>, ListGraph>();
checkConcept<ClearableGraphComponent<>, ListGraph>();
checkConcept<ErasableGraphComponent<>, ListGraph>();
}
{ // Checking SmartGraph
checkConcept<Graph, SmartGraph>();
checkConcept<AlterableGraphComponent<>, SmartGraph>();
checkConcept<ExtendableGraphComponent<>, SmartGraph>();
checkConcept<ClearableGraphComponent<>, SmartGraph>();
}
// { // Checking FullGraph
// checkConcept<Graph, FullGraph>();
// checkGraphIterators<FullGraph>();
// }
// { // Checking GridGraph
// checkConcept<Graph, GridGraph>();
// checkGraphIterators<GridGraph>();
// }
}
template <typename Graph>
void checkGraphValidity() {
TEMPLATE_GRAPH_TYPEDEFS(Graph);
Graph g;
Node
n1 = g.addNode(),
n2 = g.addNode(),
n3 = g.addNode();
Edge
e1 = g.addEdge(n1, n2),
e2 = g.addEdge(n2, n3);
check(g.valid(n1), "Wrong validity check");
check(g.valid(e1), "Wrong validity check");
check(g.valid(g.direct(e1, true)), "Wrong validity check");
check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
check(!g.valid(g.edgeFromId(-1)), "Wrong validity check");
check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
}
template <typename Graph>
void checkGraphValidityErase() {
TEMPLATE_GRAPH_TYPEDEFS(Graph);
Graph g;
Node
n1 = g.addNode(),
n2 = g.addNode(),
n3 = g.addNode();
Edge
e1 = g.addEdge(n1, n2),
e2 = g.addEdge(n2, n3);
check(g.valid(n1), "Wrong validity check");
check(g.valid(e1), "Wrong validity check");
check(g.valid(g.direct(e1, true)), "Wrong validity check");
g.erase(n1);
check(!g.valid(n1), "Wrong validity check");
check(g.valid(n2), "Wrong validity check");
check(g.valid(n3), "Wrong validity check");
check(!g.valid(e1), "Wrong validity check");
check(g.valid(e2), "Wrong validity check");
check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
check(!g.valid(g.edgeFromId(-1)), "Wrong validity check");
check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
}
// void checkGridGraph(const GridGraph& g, int w, int h) {
// check(g.width() == w, "Wrong width");
// check(g.height() == h, "Wrong height");
// for (int i = 0; i < w; ++i) {
// for (int j = 0; j < h; ++j) {
// check(g.col(g(i, j)) == i, "Wrong col");
// check(g.row(g(i, j)) == j, "Wrong row");
// }
// }
// for (int i = 0; i < w; ++i) {
// for (int j = 0; j < h - 1; ++j) {
// check(g.source(g.down(g(i, j))) == g(i, j), "Wrong down");
// check(g.target(g.down(g(i, j))) == g(i, j + 1), "Wrong down");
// }
// check(g.down(g(i, h - 1)) == INVALID, "Wrong down");
// }
// for (int i = 0; i < w; ++i) {
// for (int j = 1; j < h; ++j) {
// check(g.source(g.up(g(i, j))) == g(i, j), "Wrong up");
// check(g.target(g.up(g(i, j))) == g(i, j - 1), "Wrong up");
// }
// check(g.up(g(i, 0)) == INVALID, "Wrong up");
// }
// for (int j = 0; j < h; ++j) {
// for (int i = 0; i < w - 1; ++i) {
// check(g.source(g.right(g(i, j))) == g(i, j), "Wrong right");
// check(g.target(g.right(g(i, j))) == g(i + 1, j), "Wrong right");
// }
// check(g.right(g(w - 1, j)) == INVALID, "Wrong right");
// }
// for (int j = 0; j < h; ++j) {
// for (int i = 1; i < w; ++i) {
// check(g.source(g.left(g(i, j))) == g(i, j), "Wrong left");
// check(g.target(g.left(g(i, j))) == g(i - 1, j), "Wrong left");
// }
// check(g.left(g(0, j)) == INVALID, "Wrong left");
// }
// }
void checkGraphs() {
{ // Checking ListGraph
checkGraph<ListGraph>();
checkGraphValidityErase<ListGraph>();
}
{ // Checking SmartGraph
checkGraph<SmartGraph>();
checkGraphValidity<SmartGraph>();
}
// { // Checking FullGraph
// FullGraph g(5);
// checkGraphNodeList(g, 5);
// checkGraphEdgeList(g, 10);
// }
// { // Checking GridGraph
// GridGraph g(5, 6);
// checkGraphNodeList(g, 30);
// checkGraphEdgeList(g, 49);
// checkGridGraph(g, 5, 6);
// }
}
int main() {
checkConcepts();
checkGraphs();
return 0;
}
|