CMake improvements.
- documentation generation with Doxygen
- installation support
1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
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
19 #include <lemon/concepts/graph.h>
20 #include <lemon/list_graph.h>
21 #include <lemon/smart_graph.h>
22 // #include <lemon/full_graph.h>
23 // #include <lemon/grid_graph.h>
25 #include "test_tools.h"
26 #include "graph_test.h"
27 #include "graph_maps_test.h"
29 using namespace lemon;
30 using namespace lemon::concepts;
32 void check_concepts() {
33 { // Checking graph components
34 checkConcept<BaseGraphComponent, BaseGraphComponent >();
36 checkConcept<IDableGraphComponent<>,
37 IDableGraphComponent<> >();
39 checkConcept<IterableGraphComponent<>,
40 IterableGraphComponent<> >();
42 checkConcept<MappableGraphComponent<>,
43 MappableGraphComponent<> >();
45 { // Checking skeleton graph
46 checkConcept<Graph, Graph>();
48 { // Checking ListGraph
49 checkConcept<Graph, ListGraph>();
50 checkConcept<AlterableGraphComponent<>, ListGraph>();
51 checkConcept<ExtendableGraphComponent<>, ListGraph>();
52 checkConcept<ClearableGraphComponent<>, ListGraph>();
53 checkConcept<ErasableGraphComponent<>, ListGraph>();
54 checkGraphIterators<ListGraph>();
56 { // Checking SmartGraph
57 checkConcept<Graph, SmartGraph>();
58 checkConcept<AlterableGraphComponent<>, SmartGraph>();
59 checkConcept<ExtendableGraphComponent<>, SmartGraph>();
60 checkConcept<ClearableGraphComponent<>, SmartGraph>();
61 checkGraphIterators<SmartGraph>();
63 // { // Checking FullGraph
64 // checkConcept<Graph, FullGraph>();
65 // checkGraphIterators<FullGraph>();
67 // { // Checking GridGraph
68 // checkConcept<Graph, GridGraph>();
69 // checkGraphIterators<GridGraph>();
73 template <typename Graph>
74 void check_graph_validity() {
75 TEMPLATE_GRAPH_TYPEDEFS(Graph);
84 e1 = g.addEdge(n1, n2),
85 e2 = g.addEdge(n2, n3);
87 check(g.valid(n1), "Wrong validity check");
88 check(g.valid(e1), "Wrong validity check");
89 check(g.valid(g.direct(e1, true)), "Wrong validity check");
91 check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
92 check(!g.valid(g.edgeFromId(-1)), "Wrong validity check");
93 check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
96 template <typename Graph>
97 void check_graph_validity_erase() {
98 TEMPLATE_GRAPH_TYPEDEFS(Graph);
107 e1 = g.addEdge(n1, n2),
108 e2 = g.addEdge(n2, n3);
110 check(g.valid(n1), "Wrong validity check");
111 check(g.valid(e1), "Wrong validity check");
112 check(g.valid(g.direct(e1, true)), "Wrong validity check");
116 check(!g.valid(n1), "Wrong validity check");
117 check(g.valid(n2), "Wrong validity check");
118 check(g.valid(n3), "Wrong validity check");
119 check(!g.valid(e1), "Wrong validity check");
120 check(g.valid(e2), "Wrong validity check");
122 check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
123 check(!g.valid(g.edgeFromId(-1)), "Wrong validity check");
124 check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
127 // void checkGridGraph(const GridGraph& g, int w, int h) {
128 // check(g.width() == w, "Wrong width");
129 // check(g.height() == h, "Wrong height");
131 // for (int i = 0; i < w; ++i) {
132 // for (int j = 0; j < h; ++j) {
133 // check(g.col(g(i, j)) == i, "Wrong col");
134 // check(g.row(g(i, j)) == j, "Wrong row");
138 // for (int i = 0; i < w; ++i) {
139 // for (int j = 0; j < h - 1; ++j) {
140 // check(g.source(g.down(g(i, j))) == g(i, j), "Wrong down");
141 // check(g.target(g.down(g(i, j))) == g(i, j + 1), "Wrong down");
143 // check(g.down(g(i, h - 1)) == INVALID, "Wrong down");
146 // for (int i = 0; i < w; ++i) {
147 // for (int j = 1; j < h; ++j) {
148 // check(g.source(g.up(g(i, j))) == g(i, j), "Wrong up");
149 // check(g.target(g.up(g(i, j))) == g(i, j - 1), "Wrong up");
151 // check(g.up(g(i, 0)) == INVALID, "Wrong up");
154 // for (int j = 0; j < h; ++j) {
155 // for (int i = 0; i < w - 1; ++i) {
156 // check(g.source(g.right(g(i, j))) == g(i, j), "Wrong right");
157 // check(g.target(g.right(g(i, j))) == g(i + 1, j), "Wrong right");
159 // check(g.right(g(w - 1, j)) == INVALID, "Wrong right");
162 // for (int j = 0; j < h; ++j) {
163 // for (int i = 1; i < w; ++i) {
164 // check(g.source(g.left(g(i, j))) == g(i, j), "Wrong left");
165 // check(g.target(g.left(g(i, j))) == g(i - 1, j), "Wrong left");
167 // check(g.left(g(0, j)) == INVALID, "Wrong left");
171 void check_graphs() {
172 { // Checking ListGraph
173 checkGraph<ListGraph>();
174 checkGraphNodeMap<ListGraph>();
175 checkGraphEdgeMap<ListGraph>();
177 check_graph_validity_erase<ListGraph>();
179 { // Checking SmartGraph
180 checkGraph<SmartGraph>();
181 checkGraphNodeMap<SmartGraph>();
182 checkGraphEdgeMap<SmartGraph>();
184 check_graph_validity<SmartGraph>();
186 // { // Checking FullGraph
188 // checkGraphNodeList(g, 5);
189 // checkGraphEdgeList(g, 10);
191 // { // Checking GridGraph
192 // GridGraph g(5, 6);
193 // checkGraphNodeList(g, 30);
194 // checkGraphEdgeList(g, 49);
195 // checkGridGraph(g, 5, 6);