alpar@52
|
1 |
// -*-mode: c++; -*-
|
alpar@52
|
2 |
|
alpar@163
|
3 |
#include <invalid.h>
|
alpar@145
|
4 |
|
alpar@163
|
5 |
/// The namespace of HugoLib
|
alpar@163
|
6 |
namespace hugo {
|
alpar@163
|
7 |
|
alpar@163
|
8 |
// @defgroup empty_graph The EmptyGraph class
|
alpar@163
|
9 |
// @{
|
alpar@163
|
10 |
|
alpar@163
|
11 |
/// An empty graph class.
|
alpar@163
|
12 |
|
alpar@163
|
13 |
/// This class provides all the common features of a grapf structure,
|
alpar@163
|
14 |
/// however completely without implementations or real data structures
|
alpar@163
|
15 |
/// behind the interface.
|
alpar@163
|
16 |
/// All graph algorithms should compile with this class, but it will not
|
alpar@163
|
17 |
/// run properly, of course.
|
alpar@163
|
18 |
///
|
alpar@163
|
19 |
/// It can be used for checking the interface compatibility,
|
alpar@163
|
20 |
/// or it can serve as a skeleton of a new graph structure.
|
alpar@165
|
21 |
///
|
alpar@165
|
22 |
/// Also, you will find here the full documentation of a certain graph
|
alpar@165
|
23 |
/// feature, the documentation of a real graph imlementation
|
alpar@165
|
24 |
/// like @ref ListGraph or
|
alpar@165
|
25 |
/// @ref SmartGraph will just refer to this structure.
|
alpar@163
|
26 |
class EmptyGraph
|
alpar@163
|
27 |
{
|
alpar@147
|
28 |
public:
|
alpar@147
|
29 |
|
alpar@163
|
30 |
/// The base type of the node iterators.
|
alpar@163
|
31 |
class Node {
|
alpar@163
|
32 |
public:
|
alpar@163
|
33 |
/// @warning The default constructor sets the iterator
|
alpar@163
|
34 |
/// to an undefined value.
|
alpar@163
|
35 |
Node() {} //FIXME
|
alpar@163
|
36 |
/// Initialize the iterator to be invalid
|
alpar@163
|
37 |
Node(Invalid) {};
|
alpar@163
|
38 |
//Node(const Node &) {}
|
alpar@163
|
39 |
bool operator==(Node n) const { return true; } //FIXME
|
alpar@163
|
40 |
bool operator!=(Node n) const { return true; } //FIXME
|
alpar@163
|
41 |
};
|
alpar@147
|
42 |
|
alpar@163
|
43 |
/// This iterator goes through each node.
|
alpar@163
|
44 |
class NodeIt : public Node {
|
alpar@163
|
45 |
public:
|
alpar@163
|
46 |
/// @warning The default constructor sets the iterator
|
alpar@163
|
47 |
/// to an undefined value.
|
alpar@163
|
48 |
NodeIt() {} //FIXME
|
alpar@163
|
49 |
/// Initialize the iterator to be invalid
|
alpar@163
|
50 |
NodeIt(Invalid) {};
|
alpar@163
|
51 |
/// Sets the iterator to the first node of \c G.
|
alpar@163
|
52 |
NodeIt(const EmptyGraph &G) {}
|
alpar@163
|
53 |
NodeIt(const NodeIt &) {} //FIXME
|
alpar@163
|
54 |
};
|
alpar@163
|
55 |
|
alpar@163
|
56 |
|
alpar@163
|
57 |
/// The base type of the edge iterators.
|
alpar@163
|
58 |
class Edge {
|
alpar@163
|
59 |
public:
|
alpar@163
|
60 |
/// @warning The default constructor sets the iterator
|
alpar@163
|
61 |
/// to an undefined value.
|
alpar@163
|
62 |
Edge() {} //FIXME
|
alpar@163
|
63 |
/// Initialize the iterator to be invalid
|
alpar@163
|
64 |
Edge(Invalid) {};
|
alpar@163
|
65 |
//Edge(const Edge &) {}
|
alpar@163
|
66 |
bool operator==(Edge n) const { return true; } //FIXME
|
alpar@163
|
67 |
bool operator!=(Edge n) const { return true; } //FIXME
|
alpar@163
|
68 |
};
|
alpar@163
|
69 |
|
alpar@163
|
70 |
/// This iterator goes trought the outgoing edges of a certain graph.
|
alpar@163
|
71 |
|
alpar@163
|
72 |
class OutEdgeIt : public Edge {
|
alpar@163
|
73 |
public:
|
alpar@163
|
74 |
/// @warning The default constructor sets the iterator
|
alpar@163
|
75 |
/// to an undefined value.
|
alpar@163
|
76 |
OutEdgeIt() {}
|
alpar@163
|
77 |
/// Initialize the iterator to be invalid
|
alpar@163
|
78 |
OutEdgeIt(Invalid) {};
|
alpar@163
|
79 |
/// This constructor sets the iterator to first outgoing edge.
|
alpar@163
|
80 |
|
alpar@163
|
81 |
/// This constructor set the iterator to the first outgoing edge of
|
alpar@163
|
82 |
/// node
|
alpar@163
|
83 |
///@param n the node
|
alpar@163
|
84 |
///@param G the graph
|
alpar@163
|
85 |
OutEdgeIt(const EmptyGraph & G, Node n) {}
|
alpar@163
|
86 |
};
|
alpar@163
|
87 |
|
alpar@163
|
88 |
class InEdgeIt : public Edge {
|
alpar@163
|
89 |
public:
|
alpar@163
|
90 |
/// @warning The default constructor sets the iterator
|
alpar@163
|
91 |
/// to an undefined value.
|
alpar@163
|
92 |
InEdgeIt() {}
|
alpar@163
|
93 |
/// Initialize the iterator to be invalid
|
alpar@163
|
94 |
InEdgeIt(Invalid) {};
|
alpar@163
|
95 |
InEdgeIt(const EmptyGraph &, Node) {}
|
alpar@163
|
96 |
};
|
alpar@163
|
97 |
// class SymEdgeIt : public Edge {};
|
alpar@163
|
98 |
class EdgeIt : public Edge {
|
alpar@163
|
99 |
public:
|
alpar@163
|
100 |
/// @warning The default constructor sets the iterator
|
alpar@163
|
101 |
/// to an undefined value.
|
alpar@163
|
102 |
EdgeIt() {}
|
alpar@163
|
103 |
/// Initialize the iterator to be invalid
|
alpar@163
|
104 |
EdgeIt(Invalid) {};
|
alpar@163
|
105 |
EdgeIt(const EmptyGraph &) {}
|
alpar@163
|
106 |
};
|
alpar@163
|
107 |
|
alpar@163
|
108 |
/// First node of the graph.
|
alpar@163
|
109 |
|
alpar@163
|
110 |
/// \post \c i and the return value will be the first node.
|
alpar@163
|
111 |
///
|
alpar@163
|
112 |
NodeIt &first(NodeIt &i) const { return i;}
|
alpar@163
|
113 |
|
alpar@163
|
114 |
/// The first outgoing edge.
|
alpar@163
|
115 |
InEdgeIt &first(InEdgeIt &i, Node n) const { return i;}
|
alpar@163
|
116 |
/// The first incoming edge.
|
alpar@163
|
117 |
OutEdgeIt &first(OutEdgeIt &i, Node n) const { return i;}
|
alpar@163
|
118 |
// SymEdgeIt &first(SymEdgeIt &, Node) const { return i;}
|
alpar@163
|
119 |
/// The first edge of the Graph.
|
alpar@163
|
120 |
EdgeIt &first(EdgeIt &i) const { return i;}
|
alpar@163
|
121 |
|
alpar@163
|
122 |
// Node getNext(Node) const {}
|
alpar@163
|
123 |
// InEdgeIt getNext(InEdgeIt) const {}
|
alpar@163
|
124 |
// OutEdgeIt getNext(OutEdgeIt) const {}
|
alpar@163
|
125 |
// //SymEdgeIt getNext(SymEdgeIt) const {}
|
alpar@163
|
126 |
// EdgeIt getNext(EdgeIt) const {}
|
alpar@163
|
127 |
|
alpar@163
|
128 |
/// Go to the next node.
|
alpar@163
|
129 |
Node &next(Node &i) const { return i;}
|
alpar@163
|
130 |
/// Go to the next incoming edge.
|
alpar@163
|
131 |
InEdgeIt &next(InEdgeIt &i) const { return i;}
|
alpar@163
|
132 |
/// Go to the next outgoing edge.
|
alpar@163
|
133 |
OutEdgeIt &next(OutEdgeIt &i) const { return i;}
|
alpar@163
|
134 |
//SymEdgeIt &next(SymEdgeIt &) const {}
|
alpar@163
|
135 |
/// Go to the next edge.
|
alpar@163
|
136 |
EdgeIt &next(EdgeIt &i) const { return i;}
|
alpar@163
|
137 |
|
alpar@163
|
138 |
///Gives back the head node of an edge.
|
alpar@163
|
139 |
Node head(Edge) const { return INVALID; }
|
alpar@163
|
140 |
///Gives back the tail node of an edge.
|
alpar@163
|
141 |
Node tail(Edge) const { return INVALID; }
|
alpar@52
|
142 |
|
alpar@163
|
143 |
// Node aNode(InEdgeIt) const {}
|
alpar@163
|
144 |
// Node aNode(OutEdgeIt) const {}
|
alpar@163
|
145 |
// Node aNode(SymEdgeIt) const {}
|
alpar@163
|
146 |
|
alpar@163
|
147 |
// Node bNode(InEdgeIt) const {}
|
alpar@163
|
148 |
// Node bNode(OutEdgeIt) const {}
|
alpar@163
|
149 |
// Node bNode(SymEdgeIt) const {}
|
alpar@163
|
150 |
|
alpar@163
|
151 |
/// Checks if a node iterator is valid
|
alpar@163
|
152 |
bool valid(const Node) const { return true;};
|
alpar@163
|
153 |
/// Checks if an edge iterator is valid
|
alpar@163
|
154 |
bool valid(const Edge) const { return true;};
|
alpar@163
|
155 |
|
alpar@163
|
156 |
///Gives back the \e id of a node.
|
alpar@163
|
157 |
int id(const Node) const { return 0;};
|
alpar@163
|
158 |
///Gives back the \e id of an edge.
|
alpar@163
|
159 |
int id(const Edge) const { return 0;};
|
alpar@163
|
160 |
|
alpar@163
|
161 |
//void setInvalid(Node &) const {};
|
alpar@163
|
162 |
//void setInvalid(Edge &) const {};
|
alpar@163
|
163 |
|
alpar@163
|
164 |
Node addNode() { return INVALID;}
|
alpar@163
|
165 |
Edge addEdge(Node tail, Node head) { return INVALID;}
|
alpar@163
|
166 |
|
alpar@163
|
167 |
void erase(Node n) {}
|
alpar@163
|
168 |
void erase(Edge e) {}
|
alpar@163
|
169 |
|
alpar@163
|
170 |
void clear() {}
|
alpar@163
|
171 |
|
alpar@163
|
172 |
int nodeNum() { return 0;}
|
alpar@163
|
173 |
int edgeNum() { return 0;}
|
alpar@163
|
174 |
|
alpar@163
|
175 |
EmptyGraph() {};
|
alpar@163
|
176 |
EmptyGraph(const EmptyGraph &G) {};
|
alpar@163
|
177 |
|
alpar@163
|
178 |
|
alpar@163
|
179 |
|
alpar@163
|
180 |
///Read/write map from the nodes to type \c T.
|
alpar@163
|
181 |
template<class T> class NodeMap
|
alpar@163
|
182 |
{
|
alpar@163
|
183 |
public:
|
alpar@163
|
184 |
typedef T ValueType;
|
alpar@163
|
185 |
typedef Node KeyType;
|
alpar@163
|
186 |
|
alpar@163
|
187 |
NodeMap(const EmptyGraph &G) {}
|
alpar@163
|
188 |
NodeMap(const EmptyGraph &G, T t) {}
|
alpar@163
|
189 |
|
alpar@163
|
190 |
void set(Node i, T t) {}
|
alpar@163
|
191 |
T get(Node i) const {return *(T*)NULL;} //FIXME: Is it necessary
|
alpar@163
|
192 |
T &operator[](Node i) {return *(T*)NULL;}
|
alpar@163
|
193 |
const T &operator[](Node i) const {return *(T*)NULL;}
|
alpar@163
|
194 |
|
alpar@163
|
195 |
void update() {}
|
alpar@163
|
196 |
void update(T a) {} //FIXME: Is it necessary
|
alpar@163
|
197 |
};
|
alpar@163
|
198 |
|
alpar@163
|
199 |
///Read/write map from the edges to type \c T.
|
alpar@163
|
200 |
template<class T> class EdgeMap
|
alpar@163
|
201 |
{
|
alpar@163
|
202 |
public:
|
alpar@163
|
203 |
typedef T ValueType;
|
alpar@163
|
204 |
typedef Edge KeyType;
|
alpar@163
|
205 |
|
alpar@163
|
206 |
EdgeMap(const EmptyGraph &G) {}
|
alpar@163
|
207 |
EdgeMap(const EmptyGraph &G, T t) {}
|
alpar@163
|
208 |
|
alpar@163
|
209 |
void set(Edge i, T t) {}
|
alpar@163
|
210 |
T get(Edge i) const {return *(T*)NULL;}
|
alpar@163
|
211 |
T &operator[](Edge i) {return *(T*)NULL;}
|
alpar@163
|
212 |
|
alpar@163
|
213 |
void update() {}
|
alpar@163
|
214 |
void update(T a) {} //FIXME: Is it necessary
|
alpar@163
|
215 |
};
|
alpar@147
|
216 |
};
|
alpar@52
|
217 |
|
alpar@163
|
218 |
// @}
|
alpar@147
|
219 |
|
alpar@163
|
220 |
};
|
alpar@52
|
221 |
|
alpar@145
|
222 |
|
alpar@145
|
223 |
|
alpar@147
|
224 |
// class EmptyBipGraph : public EmptyGraph
|
alpar@147
|
225 |
// {
|
alpar@163
|
226 |
// class ANode {};
|
alpar@163
|
227 |
// class BNode {};
|
alpar@145
|
228 |
|
alpar@163
|
229 |
// ANode &next(ANode &) {}
|
alpar@163
|
230 |
// BNode &next(BNode &) {}
|
alpar@145
|
231 |
|
alpar@163
|
232 |
// ANode &getFirst(ANode &) const {}
|
alpar@163
|
233 |
// BNode &getFirst(BNode &) const {}
|
alpar@145
|
234 |
|
alpar@147
|
235 |
// enum NodeClass { A = 0, B = 1 };
|
alpar@163
|
236 |
// NodeClass getClass(Node n) {}
|
alpar@147
|
237 |
|
alpar@147
|
238 |
// }
|