1 // -*- c++ -*- |
1 // -*- c++ -*- |
2 #ifndef HUGO_EMPTYGRAPH_H |
2 #ifndef HUGO_EMPTYGRAPH_H |
3 #define HUGO_EMPTYGRAPH_H |
3 #define HUGO_EMPTYGRAPH_H |
4 |
4 |
|
5 ///\file |
|
6 ///\brief Declaration of GraphSkeleton. |
|
7 |
5 #include <invalid.h> |
8 #include <invalid.h> |
6 |
9 |
7 /// The namespace of HugoLib |
10 /// The namespace of HugoLib |
8 namespace hugo { |
11 namespace hugo { |
9 |
12 |
10 // @defgroup empty_graph The GraphSkeleton class |
13 // @defgroup empty_graph The GraphSkeleton class |
11 // @{ |
14 // @{ |
12 |
15 |
13 /// An empty graph class. |
16 /// An empty graph class. |
14 |
17 |
15 /// When you read this for the first time, |
|
16 /// please send an e-mail to alpar\@cs.elte.hu. |
|
17 /// |
|
18 /// This class provides all the common features of a graph structure, |
18 /// This class provides all the common features of a graph structure, |
19 /// however completely without implementations and real data structures |
19 /// however completely without implementations and real data structures |
20 /// behind the interface. |
20 /// behind the interface. |
21 /// All graph algorithms should compile with this class, but it will not |
21 /// All graph algorithms should compile with this class, but it will not |
22 /// run properly, of course. |
22 /// run properly, of course. |
100 bool operator==(Edge n) const { return true; } |
100 bool operator==(Edge n) const { return true; } |
101 bool operator!=(Edge n) const { return true; } |
101 bool operator!=(Edge n) const { return true; } |
102 bool operator<(Edge n) const { return true; } |
102 bool operator<(Edge n) const { return true; } |
103 }; |
103 }; |
104 |
104 |
105 /// This iterator goes trought the outgoing edges of a node. |
105 /// This iterator goes trough the outgoing edges of a node. |
106 |
106 |
107 /// This iterator goes trought the \e outgoing edges of a certain node |
107 /// This iterator goes trough the \e outgoing edges of a certain node |
108 /// of a graph. |
108 /// of a graph. |
109 /// Its usage is quite simple, for example you can count the number |
109 /// Its usage is quite simple, for example you can count the number |
110 /// of outgoing edges of a node \c n |
110 /// of outgoing edges of a node \c n |
111 /// in graph \c G of type \c Graph as follows. |
111 /// in graph \c G of type \c Graph as follows. |
112 /// \code |
112 /// \code |
128 ///@param n the node |
128 ///@param n the node |
129 ///@param G the graph |
129 ///@param G the graph |
130 OutEdgeIt(const GraphSkeleton & G, Node n) {} |
130 OutEdgeIt(const GraphSkeleton & G, Node n) {} |
131 }; |
131 }; |
132 |
132 |
133 /// This iterator goes trought the incoming edges of a node. |
133 /// This iterator goes trough the incoming edges of a node. |
134 |
134 |
135 /// This iterator goes trought the \e incoming edges of a certain node |
135 /// This iterator goes trough the \e incoming edges of a certain node |
136 /// of a graph. |
136 /// of a graph. |
137 /// Its usage is quite simple, for example you can count the number |
137 /// Its usage is quite simple, for example you can count the number |
138 /// of outgoing edges of a node \c n |
138 /// of outgoing edges of a node \c n |
139 /// in graph \c G of type \c Graph as follows. |
139 /// in graph \c G of type \c Graph as follows. |
140 /// \code |
140 /// \code |
176 |
176 |
177 /// \post \c i and the return value will be the first node. |
177 /// \post \c i and the return value will be the first node. |
178 /// |
178 /// |
179 NodeIt &first(NodeIt &i) const { return i;} |
179 NodeIt &first(NodeIt &i) const { return i;} |
180 |
180 |
|
181 /// The first incoming edge. |
|
182 InEdgeIt &first(InEdgeIt &i, Node n) const { return i;} |
181 /// The first outgoing edge. |
183 /// The first outgoing edge. |
182 InEdgeIt &first(InEdgeIt &i, Node n) const { return i;} |
|
183 /// The first incoming edge. |
|
184 OutEdgeIt &first(OutEdgeIt &i, Node n) const { return i;} |
184 OutEdgeIt &first(OutEdgeIt &i, Node n) const { return i;} |
185 // SymEdgeIt &first(SymEdgeIt &, Node) const { return i;} |
185 // SymEdgeIt &first(SymEdgeIt &, Node) const { return i;} |
186 /// The first edge of the Graph. |
186 /// The first edge of the Graph. |
187 EdgeIt &first(EdgeIt &i) const { return i;} |
187 EdgeIt &first(EdgeIt &i) const { return i;} |
188 |
188 |
226 ///bool directly, as Jacint prefers. |
226 ///bool directly, as Jacint prefers. |
227 bool valid(const Edge) const { return true;} |
227 bool valid(const Edge) const { return true;} |
228 |
228 |
229 ///Gives back the \e id of a node. |
229 ///Gives back the \e id of a node. |
230 |
230 |
231 ///\warning Not all graph structure provide this feature. |
231 ///\warning Not all graph structures provide this feature. |
232 /// |
232 /// |
233 int id(const Node) const { return 0;} |
233 int id(const Node) const { return 0;} |
234 ///Gives back the \e id of an edge. |
234 ///Gives back the \e id of an edge. |
235 |
235 |
236 ///\warning Not all graph structure provide this feature. |
236 ///\warning Not all graph structures provide this feature. |
237 /// |
237 /// |
238 int id(const Edge) const { return 0;} |
238 int id(const Edge) const { return 0;} |
239 |
239 |
240 //void setInvalid(Node &) const {}; |
240 //void setInvalid(Node &) const {}; |
241 //void setInvalid(Edge &) const {}; |
241 //void setInvalid(Edge &) const {}; |
250 ///Add a new edge to the graph with tail node \c tail |
250 ///Add a new edge to the graph with tail node \c tail |
251 ///and head node \c head. |
251 ///and head node \c head. |
252 ///\return the new edge. |
252 ///\return the new edge. |
253 Edge addEdge(Node tail, Node head) { return INVALID;} |
253 Edge addEdge(Node tail, Node head) { return INVALID;} |
254 |
254 |
255 /// Deletes a node. |
255 /// Resets the graph. |
256 |
|
257 ///\warning Not all graph structure provide this feature. |
|
258 /// |
|
259 void erase(Node n) {} |
|
260 /// Deletes an edge. |
|
261 |
|
262 ///\warning Not all graph structure provide this feature. |
|
263 /// |
|
264 void erase(Edge e) {} |
|
265 |
|
266 /// Reset the graph. |
|
267 |
256 |
268 /// This function deletes all edges and nodes of the graph. |
257 /// This function deletes all edges and nodes of the graph. |
269 /// It also frees the memory allocated to store them. |
258 /// It also frees the memory allocated to store them. |
270 void clear() {} |
259 void clear() {} |
271 |
260 |
272 int nodeNum() const { return 0;} |
261 int nodeNum() const { return 0;} |
273 int edgeNum() const { return 0;} |
262 int edgeNum() const { return 0;} |
274 |
263 |
|
264 /// Defalult constructor. |
275 GraphSkeleton() {} |
265 GraphSkeleton() {} |
|
266 ///Copy consructor. |
276 GraphSkeleton(const GraphSkeleton &G) {} |
267 GraphSkeleton(const GraphSkeleton &G) {} |
277 |
268 |
278 |
269 |
279 |
270 |
280 ///Read/write/reference map of the nodes to type \c T. |
271 ///Read/write/reference map of the nodes to type \c T. |
281 |
272 |
282 ///Read/write/reference map of the nodes to type \c T. |
273 ///Read/write/reference map of the nodes to type \c T. |
283 /// \sa MemoryMapSkeleton |
274 /// \sa MemoryMapSkeleton |
341 void update() {} |
332 void update() {} |
342 void update(T a) {} //FIXME: Is it necessary |
333 void update(T a) {} //FIXME: Is it necessary |
343 }; |
334 }; |
344 }; |
335 }; |
345 |
336 |
|
337 /// An empty eraseable graph class. |
|
338 |
|
339 /// This class provides all the common features of an \e eraseable graph |
|
340 /// structure, |
|
341 /// however completely without implementations and real data structures |
|
342 /// behind the interface. |
|
343 /// All graph algorithms should compile with this class, but it will not |
|
344 /// run properly, of course. |
|
345 /// |
|
346 /// \todo This blabla could be replaced by a sepatate description about |
|
347 /// Skeletons. |
|
348 /// |
|
349 /// It can be used for checking the interface compatibility, |
|
350 /// or it can serve as a skeleton of a new graph structure. |
|
351 /// |
|
352 /// Also, you will find here the full documentation of a certain graph |
|
353 /// feature, the documentation of a real graph imlementation |
|
354 /// like @ref ListGraph or |
|
355 /// @ref SmartGraph will just refer to this structure. |
|
356 class EraseableGraphSkeleton : public GraphSkeleton |
|
357 { |
|
358 public: |
|
359 /// Deletes a node. |
|
360 void erase(Node n) {} |
|
361 /// Deletes an edge. |
|
362 void erase(Edge e) {} |
|
363 |
|
364 /// Defalult constructor. |
|
365 GraphSkeleton() {} |
|
366 ///Copy consructor. |
|
367 GraphSkeleton(const GraphSkeleton &G) {} |
|
368 }; |
|
369 |
|
370 |
346 // @} |
371 // @} |
347 |
372 |
348 } //namespace hugo |
373 } //namespace hugo |
349 |
374 |
350 |
375 |