Fix many doxygen command bugs.
2 * src/hugo/skeletons/graph.h - Part of HUGOlib, a generic C++ optimization library
4 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Combinatorial Optimization Research Group, EGRES).
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
17 #ifndef HUGO_SKELETON_GRAPH_H
18 #define HUGO_SKELETON_GRAPH_H
22 ///\brief Declaration of Graph.
24 #include <hugo/invalid.h>
25 #include <hugo/skeletons/maps.h>
30 /// \addtogroup skeletons
33 /// An empty static graph class.
35 /// This class provides all the common features of a graph structure,
36 /// however completely without implementations and real data structures
37 /// behind the interface.
38 /// All graph algorithms should compile with this class, but it will not
39 /// run properly, of course.
41 /// It can be used for checking the interface compatibility,
42 /// or it can serve as a skeleton of a new graph structure.
44 /// Also, you will find here the full documentation of a certain graph
45 /// feature, the documentation of a real graph imlementation
46 /// like @ref ListGraph or
47 /// @ref SmartGraph will just refer to this structure.
51 /// Defalult constructor.
53 /// Defalult constructor.
58 // ///\todo It is not clear, what we expect from a copy constructor.
59 // ///E.g. How to assign the nodes/edges to each other? What about maps?
60 // StaticGraph(const StaticGraph& g) { }
62 /// The base type of node iterators,
63 /// or in other words, the trivial node iterator.
65 /// This is the base type of each node iterator,
66 /// thus each kind of node iterator converts to this.
67 /// More precisely each kind of node iterator should be inherited
68 /// from the trivial node iterator.
71 /// Default constructor
73 /// @warning The default constructor sets the iterator
74 /// to an undefined value.
82 /// Invalid constructor \& conversion.
84 /// This constructor initializes the iterator to be invalid.
85 /// \sa Invalid for more details.
89 /// Two iterators are equal if and only if they point to the
90 /// same object or both are invalid.
91 bool operator==(Node) const { return true; }
93 /// Inequality operator
95 /// \sa operator==(Node n)
97 bool operator!=(Node) const { return true; }
99 ///Comparison operator.
101 ///This is a strict ordering between the nodes.
103 ///This ordering can be different from the order in which NodeIt
104 ///goes through the nodes.
105 ///\todo Possibly we don't need it.
106 bool operator<(Node) const { return true; }
109 /// This iterator goes through each node.
111 /// This iterator goes through each node.
112 /// Its usage is quite simple, for example you can count the number
113 /// of nodes in graph \c g of type \c Graph like this:
116 /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
118 class NodeIt : public Node {
120 /// Default constructor
122 /// @warning The default constructor sets the iterator
123 /// to an undefined value.
125 /// Copy constructor.
127 /// Copy constructor.
129 NodeIt(const NodeIt&) { }
130 /// Invalid constructor \& conversion.
132 /// Initialize the iterator to be invalid.
133 /// \sa Invalid for more details.
135 /// Sets the iterator to the first node.
137 /// Sets the iterator to the first node of \c g.
139 NodeIt(const StaticGraph& g) { }
140 /// Node -> NodeIt conversion.
142 /// Sets the iterator to the node of \c g pointed by the trivial
144 /// This feature necessitates that each time we
145 /// iterate the edge-set, the iteration order is the same.
146 NodeIt(const StaticGraph& g, const Node& n) { }
149 /// Assign the iterator to the next node.
151 NodeIt& operator++() { return *this; }
155 /// The base type of the edge iterators.
157 /// The base type of the edge iterators.
161 /// Default constructor
163 /// @warning The default constructor sets the iterator
164 /// to an undefined value.
166 /// Copy constructor.
168 /// Copy constructor.
170 Edge(const Edge&) { }
171 /// Initialize the iterator to be invalid.
173 /// Initialize the iterator to be invalid.
176 /// Equality operator
178 /// Two iterators are equal if and only if they point to the
179 /// same object or both are invalid.
180 bool operator==(Edge) const { return true; }
181 /// Inequality operator
183 /// \sa operator==(Node n)
185 bool operator!=(Edge) const { return true; }
186 ///Comparison operator.
188 ///This is a strict ordering between the nodes.
190 ///This ordering can be different from the order in which NodeIt
191 ///goes through the nodes.
192 ///\todo Possibly we don't need it.
193 bool operator<(Edge) const { return true; }
196 /// This iterator goes trough the outgoing edges of a node.
198 /// This iterator goes trough the \e outgoing edges of a certain node
200 /// Its usage is quite simple, for example you can count the number
201 /// of outgoing edges of a node \c n
202 /// in graph \c g of type \c Graph as follows.
205 /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
208 class OutEdgeIt : public Edge {
210 /// Default constructor
212 /// @warning The default constructor sets the iterator
213 /// to an undefined value.
215 /// Copy constructor.
217 /// Copy constructor.
219 OutEdgeIt(const OutEdgeIt&) { }
220 /// Initialize the iterator to be invalid.
222 /// Initialize the iterator to be invalid.
224 OutEdgeIt(Invalid) { }
225 /// This constructor sets the iterator to first outgoing edge.
227 /// This constructor set the iterator to the first outgoing edge of
230 ///@param g the graph
231 OutEdgeIt(const StaticGraph& g, const Node& n) { }
232 /// Edge -> OutEdgeIt conversion
234 /// Sets the iterator to the value of the trivial iterator \c e.
235 /// This feature necessitates that each time we
236 /// iterate the edge-set, the iteration order is the same.
237 OutEdgeIt(const StaticGraph& g, const Edge& e) { }
238 ///Next outgoing edge
240 /// Assign the iterator to the next
241 /// outgoing edge of the corresponding node.
242 OutEdgeIt& operator++() { return *this; }
245 /// This iterator goes trough the incoming edges of a node.
247 /// This iterator goes trough the \e incoming edges of a certain node
249 /// Its usage is quite simple, for example you can count the number
250 /// of outgoing edges of a node \c n
251 /// in graph \c g of type \c Graph as follows.
254 /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
257 class InEdgeIt : public Edge {
259 /// Default constructor
261 /// @warning The default constructor sets the iterator
262 /// to an undefined value.
264 /// Copy constructor.
266 /// Copy constructor.
268 InEdgeIt(const InEdgeIt&) { }
269 /// Initialize the iterator to be invalid.
271 /// Initialize the iterator to be invalid.
273 InEdgeIt(Invalid) { }
274 /// This constructor sets the iterator to first incoming edge.
276 /// This constructor set the iterator to the first incoming edge of
279 ///@param g the graph
280 InEdgeIt(const StaticGraph& g, const Node& n) { }
281 /// Edge -> InEdgeIt conversion
283 /// Sets the iterator to the value of the trivial iterator \c e.
284 /// This feature necessitates that each time we
285 /// iterate the edge-set, the iteration order is the same.
286 InEdgeIt(const StaticGraph& g, const Edge& n) { }
287 /// Next incoming edge
289 /// Assign the iterator to the next inedge of the corresponding node.
291 InEdgeIt& operator++() { return *this; }
293 /// This iterator goes through each edge.
295 /// This iterator goes through each edge of a graph.
296 /// Its usage is quite simple, for example you can count the number
297 /// of edges in a graph \c g of type \c Graph as follows:
300 /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
302 class EdgeIt : public Edge {
304 /// Default constructor
306 /// @warning The default constructor sets the iterator
307 /// to an undefined value.
309 /// Copy constructor.
311 /// Copy constructor.
313 EdgeIt(const EdgeIt&) { }
314 /// Initialize the iterator to be invalid.
316 /// Initialize the iterator to be invalid.
319 /// This constructor sets the iterator to first edge.
321 /// This constructor set the iterator to the first edge of
323 ///@param g the graph
324 EdgeIt(const StaticGraph& g) { }
325 /// Edge -> EdgeIt conversion
327 /// Sets the iterator to the value of the trivial iterator \c e.
328 /// This feature necessitates that each time we
329 /// iterate the edge-set, the iteration order is the same.
330 EdgeIt(const StaticGraph&, const Edge&) { }
333 /// Assign the iterator to the next
334 /// edge of the corresponding node.
335 EdgeIt& operator++() { return *this; }
338 /// First node of the graph.
340 /// \retval i the first node.
341 /// \return the first node.
343 NodeIt& first(NodeIt& i) const { return i; }
345 /// The first incoming edge.
347 /// The first incoming edge.
349 InEdgeIt& first(InEdgeIt &i, Node) const { return i; }
350 /// The first outgoing edge.
352 /// The first outgoing edge.
354 OutEdgeIt& first(OutEdgeIt& i, Node) const { return i; }
355 /// The first edge of the Graph.
357 /// The first edge of the Graph.
359 EdgeIt& first(EdgeIt& i) const { return i; }
361 ///Gives back the head node of an edge.
363 ///Gives back the head node of an edge.
365 Node head(Edge) const { return INVALID; }
366 ///Gives back the tail node of an edge.
368 ///Gives back the tail node of an edge.
370 Node tail(Edge) const { return INVALID; }
372 ///Gives back the \e id of a node.
374 ///\warning Not all graph structures provide this feature.
376 ///\todo Should each graph provide \c id?
377 int id(const Node&) const { return 0; }
378 ///Gives back the \e id of an edge.
380 ///\warning Not all graph structures provide this feature.
382 ///\todo Should each graph provide \c id?
383 int id(const Edge&) const { return 0; }
387 ///\todo Should it be in the concept?
389 int nodeNum() const { return 0; }
392 ///\todo Should it be in the concept?
394 int edgeNum() const { return 0; }
397 ///Reference map of the nodes to type \c T.
399 /// \ingroup skeletons
400 ///Reference map of the nodes to type \c T.
402 /// \warning Making maps that can handle bool type (NodeMap<bool>)
403 /// needs some extra attention!
404 template<class T> class NodeMap : public ReferenceMap< Node, T >
409 NodeMap(const StaticGraph&) { }
411 NodeMap(const StaticGraph&, T) { }
414 template<typename TT> NodeMap(const NodeMap<TT>&) { }
415 ///Assignment operator
416 template<typename TT> NodeMap& operator=(const NodeMap<TT>&)
420 ///Reference map of the edges to type \c T.
422 /// \ingroup skeletons
423 ///Reference map of the edges to type \c T.
425 /// \warning Making maps that can handle bool type (EdgeMap<bool>)
426 /// needs some extra attention!
427 template<class T> class EdgeMap
428 : public ReferenceMap<Edge,T>
433 EdgeMap(const StaticGraph&) { }
435 EdgeMap(const StaticGraph&, T) { }
438 template<typename TT> EdgeMap(const EdgeMap<TT>&) { }
439 ///Assignment operator
440 template<typename TT> EdgeMap &operator=(const EdgeMap<TT>&)
447 /// An empty non-static graph class.
449 /// This class provides everything that \ref StaticGraph
450 /// with additional functionality which enables to build a
451 /// graph from scratch.
452 class ExtendableGraph : public StaticGraph
455 /// Defalult constructor.
457 /// Defalult constructor.
459 ExtendableGraph() { }
460 ///Add a new node to the graph.
462 /// \return the new node.
464 Node addNode() { return INVALID; }
465 ///Add a new edge to the graph.
467 ///Add a new edge to the graph with tail node \c t
468 ///and head node \c h.
469 ///\return the new edge.
470 Edge addEdge(Node h, Node t) { return INVALID; }
472 /// Resets the graph.
474 /// This function deletes all edges and nodes of the graph.
475 /// It also frees the memory allocated to store them.
476 /// \todo It might belong to \ref ErasableGraph.
480 /// An empty erasable graph class.
482 /// This class is an extension of \ref ExtendableGraph. It also makes it
483 /// possible to erase edges or nodes.
484 class ErasableGraph : public ExtendableGraph
487 /// Defalult constructor.
489 /// Defalult constructor.
494 /// Deletes node \c n node.
496 void erase(Node n) { }
499 /// Deletes edge \c e edge.
501 void erase(Edge e) { }
505 } //namespace skeleton
510 #endif // HUGO_SKELETON_GRAPH_H