6 ///\brief Declaration of GraphSkeleton.
10 /// The namespace of HugoLib
13 // @defgroup empty_graph The GraphSkeleton class
16 /// An empty graph class.
18 /// This class provides all the common features of a graph structure,
19 /// however completely without implementations and real data structures
20 /// behind the interface.
21 /// All graph algorithms should compile with this class, but it will not
22 /// run properly, of course.
24 /// It can be used for checking the interface compatibility,
25 /// or it can serve as a skeleton of a new graph structure.
27 /// Also, you will find here the full documentation of a certain graph
28 /// feature, the documentation of a real graph imlementation
29 /// like @ref ListGraph or
30 /// @ref SmartGraph will just refer to this structure.
35 /// The base type of the node iterators.
37 /// This is the base type of each node iterators,
38 /// thus each kind of node iterator will convert to this.
41 /// @warning The default constructor sets the iterator
42 /// to an undefined value.
44 /// Invalid constructor \& conversion.
46 /// This constructor initializes the iterator to be invalid.
47 /// \sa Invalid for more details.
50 //Node(const Node &) {}
52 /// Two iterators are equal if and only if they point to the
53 /// same object or both are invalid.
54 bool operator==(Node n) const { return true; }
56 /// \sa \ref operator==(Node n)
58 bool operator!=(Node n) const { return true; }
60 bool operator<(Node n) const { return true; }
63 /// This iterator goes through each node.
65 /// This iterator goes through each node.
66 /// Its usage is quite simple, for example you can count the number
67 /// of nodes in graph \c G of type \c Graph like this:
70 ///for(Graph::NodeIt n(G);G.valid(n);G.next(n)) count++;
72 class NodeIt : public Node {
74 /// @warning The default constructor sets the iterator
75 /// to an undefined value.
77 /// Invalid constructor \& conversion.
79 /// Initialize the iterator to be invalid
80 /// \sa Invalid for more details.
82 /// Sets the iterator to the first node of \c G.
83 NodeIt(const GraphSkeleton &G) {}
84 /// @warning The default constructor sets the iterator
85 /// to an undefined value.
86 NodeIt(const NodeIt &) {}
90 /// The base type of the edge iterators.
93 /// @warning The default constructor sets the iterator
94 /// to an undefined value.
96 /// Initialize the iterator to be invalid
98 /// Two iterators are equal if and only if they point to the
99 /// same object or both are invalid.
100 bool operator==(Edge n) const { return true; }
101 bool operator!=(Edge n) const { return true; }
102 bool operator<(Edge n) const { return true; }
105 /// This iterator goes trough the outgoing edges of a node.
107 /// This iterator goes trough the \e outgoing edges of a certain node
109 /// Its usage is quite simple, for example you can count the number
110 /// of outgoing edges of a node \c n
111 /// in graph \c G of type \c Graph as follows.
114 ///for(Graph::OutEdgeIt e(G,n);G.valid(e);G.next(e)) count++;
117 class OutEdgeIt : public Edge {
119 /// @warning The default constructor sets the iterator
120 /// to an undefined value.
122 /// Initialize the iterator to be invalid
123 OutEdgeIt(Invalid) {}
124 /// This constructor sets the iterator to first outgoing edge.
126 /// This constructor set the iterator to the first outgoing edge of
129 ///@param G the graph
130 OutEdgeIt(const GraphSkeleton & G, Node n) {}
133 /// This iterator goes trough the incoming edges of a node.
135 /// This iterator goes trough the \e incoming edges of a certain node
137 /// Its usage is quite simple, for example you can count the number
138 /// of outgoing edges of a node \c n
139 /// in graph \c G of type \c Graph as follows.
142 ///for(Graph::InEdgeIt e(G,n);G.valid(e);G.next(e)) count++;
145 class InEdgeIt : public Edge {
147 /// @warning The default constructor sets the iterator
148 /// to an undefined value.
150 /// Initialize the iterator to be invalid
152 InEdgeIt(const GraphSkeleton &, Node) {}
154 // class SymEdgeIt : public Edge {};
156 /// This iterator goes through each edge.
158 /// This iterator goes through each edge of a graph.
159 /// Its usage is quite simple, for example you can count the number
160 /// of edges in a graph \c G of type \c Graph as follows:
163 ///for(Graph::EdgeIt e(G);G.valid(e);G.next(e)) count++;
165 class EdgeIt : public Edge {
167 /// @warning The default constructor sets the iterator
168 /// to an undefined value.
170 /// Initialize the iterator to be invalid
172 EdgeIt(const GraphSkeleton &) {}
175 /// First node of the graph.
177 /// \post \c i and the return value will be the first node.
179 NodeIt &first(NodeIt &i) const { return i;}
181 /// The first incoming edge.
182 InEdgeIt &first(InEdgeIt &i, Node n) const { return i;}
183 /// The first outgoing edge.
184 OutEdgeIt &first(OutEdgeIt &i, Node n) const { return i;}
185 // SymEdgeIt &first(SymEdgeIt &, Node) const { return i;}
186 /// The first edge of the Graph.
187 EdgeIt &first(EdgeIt &i) const { return i;}
189 // Node getNext(Node) const {}
190 // InEdgeIt getNext(InEdgeIt) const {}
191 // OutEdgeIt getNext(OutEdgeIt) const {}
192 // //SymEdgeIt getNext(SymEdgeIt) const {}
193 // EdgeIt getNext(EdgeIt) const {}
195 /// Go to the next node.
196 NodeIt &next(NodeIt &i) const { return i;}
197 /// Go to the next incoming edge.
198 InEdgeIt &next(InEdgeIt &i) const { return i;}
199 /// Go to the next outgoing edge.
200 OutEdgeIt &next(OutEdgeIt &i) const { return i;}
201 //SymEdgeIt &next(SymEdgeIt &) const {}
202 /// Go to the next edge.
203 EdgeIt &next(EdgeIt &i) const { return i;}
205 ///Gives back the head node of an edge.
206 Node head(Edge) const { return INVALID; }
207 ///Gives back the tail node of an edge.
208 Node tail(Edge) const { return INVALID; }
210 // Node aNode(InEdgeIt) const {}
211 // Node aNode(OutEdgeIt) const {}
212 // Node aNode(SymEdgeIt) const {}
214 // Node bNode(InEdgeIt) const {}
215 // Node bNode(OutEdgeIt) const {}
216 // Node bNode(SymEdgeIt) const {}
218 /// Checks if a node iterator is valid
220 ///\todo Maybe, it would be better if iterator converted to
221 ///bool directly, as Jacint prefers.
222 bool valid(const Node) const { return true;}
223 /// Checks if an edge iterator is valid
225 ///\todo Maybe, it would be better if iterator converted to
226 ///bool directly, as Jacint prefers.
227 bool valid(const Edge) const { return true;}
229 ///Gives back the \e id of a node.
231 ///\warning Not all graph structures provide this feature.
233 int id(const Node) const { return 0;}
234 ///Gives back the \e id of an edge.
236 ///\warning Not all graph structures provide this feature.
238 int id(const Edge) const { return 0;}
240 //void setInvalid(Node &) const {};
241 //void setInvalid(Edge &) const {};
243 ///Add a new node to the graph.
245 /// \return the new node.
247 Node addNode() { return INVALID;}
248 ///Add a new edge to the graph.
250 ///Add a new edge to the graph with tail node \c tail
251 ///and head node \c head.
252 ///\return the new edge.
253 Edge addEdge(Node tail, Node head) { return INVALID;}
255 /// Resets the graph.
257 /// This function deletes all edges and nodes of the graph.
258 /// It also frees the memory allocated to store them.
261 int nodeNum() const { return 0;}
262 int edgeNum() const { return 0;}
264 /// Defalult constructor.
267 GraphSkeleton(const GraphSkeleton &G) {}
271 ///Read/write/reference map of the nodes to type \c T.
273 ///Read/write/reference map of the nodes to type \c T.
274 /// \sa MemoryMapSkeleton
275 /// \todo We may need copy constructor
276 /// \todo We may need conversion from other nodetype
277 /// \todo We may need operator=
278 /// \warning Making maps that can handle bool type (NodeMap<bool>)
279 /// needs extra attention!
281 template<class T> class NodeMap
285 typedef Node KeyType;
287 NodeMap(const GraphSkeleton &G) {}
288 NodeMap(const GraphSkeleton &G, T t) {}
290 template<typename TT> NodeMap(const NodeMap<TT> &m) {}
292 /// Sets the value of a node.
294 /// Sets the value associated with node \c i to the value \c t.
296 void set(Node i, T t) {}
297 /// Gets the value of a node.
298 T get(Node i) const {return *(T*)0;} //FIXME: Is it necessary
299 T &operator[](Node i) {return *(T*)0;}
300 const T &operator[](Node i) const {return *(T*)0;}
302 /// Updates the map if the graph has been changed
304 /// \todo Do we need this?
307 void update(T a) {} //FIXME: Is it necessary
310 ///Read/write/reference map of the edges to type \c T.
312 ///Read/write/reference map of the edges to type \c T.
313 ///It behaves exactly in the same way as \ref NodeMap.
315 /// \sa MemoryMapSkeleton
316 /// \todo We may need copy constructor
317 /// \todo We may need conversion from other edgetype
318 /// \todo We may need operator=
319 template<class T> class EdgeMap
323 typedef Edge KeyType;
325 EdgeMap(const GraphSkeleton &G) {}
326 EdgeMap(const GraphSkeleton &G, T t) {}
328 void set(Edge i, T t) {}
329 T get(Edge i) const {return *(T*)0;}
330 T &operator[](Edge i) {return *(T*)0;}
333 void update(T a) {} //FIXME: Is it necessary
337 /// An empty eraseable graph class.
339 /// This class provides all the common features of an \e eraseable graph
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.
346 /// \todo This blabla could be replaced by a sepatate description about
349 /// It can be used for checking the interface compatibility,
350 /// or it can serve as a skeleton of a new graph structure.
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
360 void erase(Node n) {}
362 void erase(Edge e) {}
364 /// Defalult constructor.
367 GraphSkeleton(const GraphSkeleton &G) {}
377 // class EmptyBipGraph : public Graph Skeleton
382 // ANode &next(ANode &) {}
383 // BNode &next(BNode &) {}
385 // ANode &getFirst(ANode &) const {}
386 // BNode &getFirst(BNode &) const {}
388 // enum NodeClass { A = 0, B = 1 };
389 // NodeClass getClass(Node n) {}
393 #endif // HUGO_GRAPH_H