klao@962
|
1 |
/* -*- C++ -*-
|
klao@962
|
2 |
*
|
klao@962
|
3 |
* src/lemon/concept/undir_graph_component.h - Part of LEMON, a generic
|
klao@962
|
4 |
* C++ optimization library
|
klao@962
|
5 |
*
|
klao@962
|
6 |
* Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi
|
klao@962
|
7 |
* Kutatocsoport (Egervary Combinatorial Optimization Research Group,
|
klao@962
|
8 |
* EGRES).
|
klao@962
|
9 |
*
|
klao@962
|
10 |
* Permission to use, modify and distribute this software is granted
|
klao@962
|
11 |
* provided that this copyright notice appears in all copies. For
|
klao@962
|
12 |
* precise terms see the accompanying LICENSE file.
|
klao@962
|
13 |
*
|
klao@962
|
14 |
* This software is provided "AS IS" with no warranty of any kind,
|
klao@962
|
15 |
* express or implied, and with no claim as to its suitability for any
|
klao@962
|
16 |
* purpose.
|
klao@962
|
17 |
*
|
klao@962
|
18 |
*/
|
klao@962
|
19 |
|
klao@962
|
20 |
///\ingroup concept
|
klao@962
|
21 |
///\file
|
klao@962
|
22 |
///\brief Undirected graphs and components of.
|
klao@962
|
23 |
|
klao@962
|
24 |
|
klao@962
|
25 |
#ifndef LEMON_CONCEPT_UNDIR_GRAPH_H
|
klao@962
|
26 |
#define LEMON_CONCEPT_UNDIR_GRAPH_H
|
klao@962
|
27 |
|
klao@962
|
28 |
#include <lemon/concept/graph_component.h>
|
klao@962
|
29 |
|
klao@962
|
30 |
namespace lemon {
|
klao@962
|
31 |
namespace concept {
|
klao@962
|
32 |
|
klao@962
|
33 |
/// \todo to be done
|
klao@962
|
34 |
|
klao@962
|
35 |
struct BaseIterableUndirGraphConcept {
|
deba@989
|
36 |
|
klao@1022
|
37 |
template <typename Graph>
|
klao@1022
|
38 |
struct Constraints {
|
klao@962
|
39 |
|
klao@1022
|
40 |
typedef typename Graph::UndirEdge UndirEdge;
|
klao@1022
|
41 |
typedef typename Graph::Edge Edge;
|
klao@1022
|
42 |
typedef typename Graph::Node Node;
|
klao@962
|
43 |
|
klao@1022
|
44 |
void constraints() {
|
klao@1022
|
45 |
checkConcept<BaseIterableGraphComponent, Graph>();
|
klao@1022
|
46 |
checkConcept<GraphItem<'u'>, UndirEdge >();
|
klao@962
|
47 |
|
klao@1022
|
48 |
/// \bug this should be base_and_derived:
|
klao@1022
|
49 |
UndirEdge ue = e;
|
klao@1022
|
50 |
ue = e;
|
klao@1022
|
51 |
|
klao@1022
|
52 |
Node n;
|
klao@1022
|
53 |
n = graph.target(ue);
|
klao@1022
|
54 |
n = graph.source(ue);
|
klao@1022
|
55 |
|
klao@1022
|
56 |
graph.first(ue);
|
klao@1022
|
57 |
graph.next(ue);
|
klao@1022
|
58 |
}
|
klao@1022
|
59 |
const Graph &graph;
|
klao@1022
|
60 |
Edge e;
|
klao@1022
|
61 |
};
|
klao@1022
|
62 |
|
klao@962
|
63 |
};
|
klao@962
|
64 |
|
klao@1022
|
65 |
|
klao@962
|
66 |
struct IterableUndirGraphConcept {
|
klao@962
|
67 |
|
klao@1022
|
68 |
template <typename Graph>
|
klao@1022
|
69 |
struct Constraints {
|
klao@1022
|
70 |
void constraints() {
|
klao@1022
|
71 |
/// \todo we don't need the iterable component to be base iterable
|
klao@1022
|
72 |
/// Don't we really???
|
klao@1022
|
73 |
//checkConcept< BaseIterableUndirGraphConcept, Graph > ();
|
klao@962
|
74 |
|
klao@1022
|
75 |
checkConcept<IterableGraphComponent, Graph> ();
|
klao@1021
|
76 |
|
klao@1022
|
77 |
typedef typename Graph::UndirEdge UndirEdge;
|
klao@1022
|
78 |
typedef typename Graph::UndirEdgeIt UndirEdgeIt;
|
klao@1022
|
79 |
typedef typename Graph::UndirIncEdgeIt UndirIncEdgeIt;
|
klao@1022
|
80 |
|
klao@1022
|
81 |
checkConcept<GraphIterator<Graph, UndirEdge>, UndirEdgeIt>();
|
klao@1022
|
82 |
checkConcept<GraphIncIterator<Graph, UndirEdge>, UndirIncEdgeIt>();
|
klao@1022
|
83 |
}
|
klao@1022
|
84 |
};
|
klao@1022
|
85 |
|
klao@1022
|
86 |
};
|
klao@1022
|
87 |
|
klao@1022
|
88 |
struct MappableUndirGraphConcept {
|
klao@1022
|
89 |
|
klao@1022
|
90 |
template <typename Graph>
|
klao@1022
|
91 |
struct Constraints {
|
klao@1022
|
92 |
|
klao@1022
|
93 |
struct Dummy {
|
klao@1022
|
94 |
int value;
|
klao@1022
|
95 |
Dummy() : value(0) {}
|
klao@1022
|
96 |
Dummy(int _v) : value(_v) {}
|
klao@1022
|
97 |
};
|
klao@1022
|
98 |
|
klao@1022
|
99 |
void constraints() {
|
klao@1022
|
100 |
checkConcept<MappableGraphComponent, Graph>();
|
klao@1022
|
101 |
|
klao@1022
|
102 |
typedef typename Graph::template UndirEdgeMap<int> IntMap;
|
klao@1022
|
103 |
checkConcept<GraphMap<Graph, typename Graph::UndirEdge, int>,
|
klao@1022
|
104 |
IntMap >();
|
klao@1022
|
105 |
|
klao@1022
|
106 |
typedef typename Graph::template UndirEdgeMap<bool> BoolMap;
|
klao@1022
|
107 |
checkConcept<GraphMap<Graph, typename Graph::UndirEdge, bool>,
|
klao@1022
|
108 |
BoolMap >();
|
klao@1022
|
109 |
|
klao@1022
|
110 |
typedef typename Graph::template UndirEdgeMap<Dummy> DummyMap;
|
klao@1022
|
111 |
checkConcept<GraphMap<Graph, typename Graph::UndirEdge, Dummy>,
|
klao@1022
|
112 |
DummyMap >();
|
klao@1022
|
113 |
}
|
klao@1022
|
114 |
};
|
klao@1022
|
115 |
|
klao@1022
|
116 |
};
|
klao@1022
|
117 |
|
klao@1022
|
118 |
struct ExtendableUndirGraphConcept {
|
klao@1022
|
119 |
|
klao@1022
|
120 |
template <typename Graph>
|
klao@1022
|
121 |
struct Constraints {
|
klao@1022
|
122 |
void constraints() {
|
klao@1022
|
123 |
node_a = graph.addNode();
|
klao@1022
|
124 |
uedge = graph.addEdge(node_a, node_b);
|
klao@1022
|
125 |
}
|
klao@1022
|
126 |
typename Graph::Node node_a, node_b;
|
klao@1022
|
127 |
typename Graph::UndirEdge uedge;
|
klao@1022
|
128 |
Graph graph;
|
klao@1022
|
129 |
};
|
klao@1022
|
130 |
|
klao@1022
|
131 |
};
|
klao@1022
|
132 |
|
klao@1022
|
133 |
struct ErasableUndirGraphConcept {
|
klao@1022
|
134 |
|
klao@1022
|
135 |
template <typename Graph>
|
klao@1022
|
136 |
struct Constraints {
|
klao@1022
|
137 |
void constraints() {
|
klao@1022
|
138 |
graph.erase(n);
|
klao@1022
|
139 |
graph.erase(e);
|
klao@1022
|
140 |
}
|
klao@1022
|
141 |
Graph graph;
|
klao@1022
|
142 |
typename Graph::Node n;
|
klao@1022
|
143 |
typename Graph::UndirEdge e;
|
klao@1022
|
144 |
};
|
klao@1022
|
145 |
|
klao@1022
|
146 |
};
|
klao@1022
|
147 |
|
klao@1022
|
148 |
class UndirGraph {
|
klao@1022
|
149 |
public:
|
klao@1022
|
150 |
|
klao@1022
|
151 |
template <typename Graph>
|
klao@1022
|
152 |
struct Constraints {
|
klao@1022
|
153 |
void constraints() {
|
klao@1022
|
154 |
checkConcept<BaseIterableUndirGraphConcept, Graph>();
|
klao@1022
|
155 |
checkConcept<IterableUndirGraphConcept, Graph>();
|
klao@1022
|
156 |
checkConcept<MappableUndirGraphConcept, Graph>();
|
klao@1022
|
157 |
}
|
klao@1022
|
158 |
};
|
klao@1022
|
159 |
|
klao@1022
|
160 |
};
|
klao@1022
|
161 |
|
klao@1022
|
162 |
class ExtendableUndirGraph : public UndirGraph {
|
klao@1022
|
163 |
public:
|
klao@1022
|
164 |
|
klao@1022
|
165 |
template <typename Graph>
|
klao@1022
|
166 |
struct Constraints {
|
klao@1022
|
167 |
void constraints() {
|
klao@1022
|
168 |
checkConcept<BaseIterableUndirGraphConcept, Graph>();
|
klao@1022
|
169 |
checkConcept<IterableUndirGraphConcept, Graph>();
|
klao@1022
|
170 |
checkConcept<MappableUndirGraphConcept, Graph>();
|
klao@1022
|
171 |
|
klao@1022
|
172 |
checkConcept<UndirGraph, Graph>();
|
klao@1022
|
173 |
checkConcept<ExtendableUndirGraphConcept, Graph>();
|
klao@1022
|
174 |
checkConcept<ClearableGraphComponent, Graph>();
|
klao@1022
|
175 |
}
|
klao@1022
|
176 |
};
|
klao@1022
|
177 |
|
klao@1022
|
178 |
};
|
klao@1022
|
179 |
|
klao@1022
|
180 |
class ErasableUndirGraph : public ExtendableUndirGraph {
|
klao@1022
|
181 |
public:
|
klao@1022
|
182 |
|
klao@1022
|
183 |
template <typename Graph>
|
klao@1022
|
184 |
struct Constraints {
|
klao@1022
|
185 |
void constraints() {
|
klao@1022
|
186 |
checkConcept<ExtendableUndirGraph, Graph>();
|
klao@1022
|
187 |
checkConcept<ErasableUndirGraphConcept, Graph>();
|
klao@1022
|
188 |
}
|
klao@1022
|
189 |
};
|
klao@1022
|
190 |
|
klao@962
|
191 |
};
|
klao@962
|
192 |
|
klao@962
|
193 |
}
|
klao@962
|
194 |
|
klao@962
|
195 |
}
|
klao@962
|
196 |
|
klao@962
|
197 |
#endif
|