COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/alpar/emptygraph.h @ 182:c59e450712d8

Last change on this file since 182:c59e450712d8 was 182:c59e450712d8, checked in by Alpar Juttner, 21 years ago

More comments, bug fixes, and copy constructors

File size: 8.8 KB
Line 
1// -*- c++ -*-
2#ifndef EMPTYGRAPH_H
3#define EMPTYGRAPH_H
4
5#include <invalid.h>
6
7/// The namespace of HugoLib
8namespace hugo {
9
10  // @defgroup empty_graph The GraphSkeleton class
11  // @{
12
13  /// An empty graph class.
14 
15  /// This class provides all the common features of a grapf structure,
16  /// however completely without implementations or real data structures
17  /// behind the interface.
18  /// All graph algorithms should compile with this class, but it will not
19  /// run properly, of course.
20  ///
21  /// It can be used for checking the interface compatibility,
22  /// or it can serve as a skeleton of a new graph structure.
23  ///
24  /// Also, you will find here the full documentation of a certain graph
25  /// feature, the documentation of a real graph imlementation
26  /// like @ref ListGraph or
27  /// @ref SmartGraph will just refer to this structure.
28  class GraphSkeleton
29  {
30  public:
31   
32    /// The base type of the node iterators.
33
34    /// This \c Node is the base type of each node iterators,
35    /// thus each kind of node iterator will convert to this.
36    class Node {
37    public:
38      /// @warning The default constructor sets the iterator
39      /// to an undefined value.
40      Node() {}   //FIXME
41      /// Invalid constructor \& conversion.
42
43      /// This constructor initializes the iterator to be invalid.
44      /// \sa Invalid for more details.
45
46      Node(Invalid) {}
47      //Node(const Node &) {}
48
49      /// Two iterators are equal if and only if they point to the
50      /// same object or both are invalid.
51      bool operator==(Node n) const { return true; }
52
53      /// \sa \ref operator==(Node n)
54      ///
55      bool operator!=(Node n) const { return true; }
56
57      bool operator<(Node n) const { return true; }
58    };
59   
60    /// This iterator goes through each node.
61    class NodeIt : public Node {
62    public:
63      /// @warning The default constructor sets the iterator
64      /// to an undefined value.
65      NodeIt() {} //FIXME
66      /// Invalid constructor \& conversion.
67
68      /// Initialize the iterator to be invalid
69      /// \sa Invalid for more details.
70      NodeIt(Invalid) {}
71      /// Sets the iterator to the first node of \c G.
72      NodeIt(const GraphSkeleton &G) {}
73      /// @warning The default constructor sets the iterator
74      /// to an undefined value.
75      NodeIt(const NodeIt &) {}
76    };
77   
78   
79    /// The base type of the edge iterators.
80    class Edge {
81    public:
82      /// @warning The default constructor sets the iterator
83      /// to an undefined value.
84      Edge() {}   //FIXME
85      /// Initialize the iterator to be invalid
86      Edge(Invalid) {}
87      /// Two iterators are equal if and only if they point to the
88      /// same object or both are invalid.
89      bool operator==(Edge n) const { return true; }
90      bool operator!=(Edge n) const { return true; }
91      bool operator<(Edge n) const { return true; }
92    };
93   
94    /// This iterator goes trought the outgoing edges of a certain graph.
95   
96    class OutEdgeIt : public Edge {
97    public:
98      /// @warning The default constructor sets the iterator
99      /// to an undefined value.
100      OutEdgeIt() {}
101      /// Initialize the iterator to be invalid
102      OutEdgeIt(Invalid) {}
103      /// This constructor sets the iterator to first outgoing edge.
104   
105      /// This constructor set the iterator to the first outgoing edge of
106      /// node
107      ///@param n the node
108      ///@param G the graph
109      OutEdgeIt(const GraphSkeleton & G, Node n) {}
110    };
111
112    class InEdgeIt : public Edge {
113    public:
114      /// @warning The default constructor sets the iterator
115      /// to an undefined value.
116      InEdgeIt() {}
117      /// Initialize the iterator to be invalid
118      InEdgeIt(Invalid) {}
119      InEdgeIt(const GraphSkeleton &, Node) {}   
120    };
121    //  class SymEdgeIt : public Edge {};
122    class EdgeIt : public Edge {
123    public:
124      /// @warning The default constructor sets the iterator
125      /// to an undefined value.
126      EdgeIt() {}
127      /// Initialize the iterator to be invalid
128      EdgeIt(Invalid) {}
129      EdgeIt(const GraphSkeleton &) {}
130    };
131
132    /// First node of the graph.
133
134    /// \post \c i and the return value will be the first node.
135    ///
136    NodeIt &first(NodeIt &i) const { return i;}
137
138    /// The first outgoing edge.
139    InEdgeIt &first(InEdgeIt &i, Node n) const { return i;}
140    /// The first incoming edge.
141    OutEdgeIt &first(OutEdgeIt &i, Node n) const { return i;}
142    //  SymEdgeIt &first(SymEdgeIt &, Node) const { return i;}
143    /// The first edge of the Graph.
144    EdgeIt &first(EdgeIt &i) const { return i;}
145
146//     Node getNext(Node) const {}
147//     InEdgeIt getNext(InEdgeIt) const {}
148//     OutEdgeIt getNext(OutEdgeIt) const {}
149//     //SymEdgeIt getNext(SymEdgeIt) const {}
150//     EdgeIt getNext(EdgeIt) const {}
151
152    /// Go to the next node.
153    NodeIt &next(NodeIt &i) const { return i;}
154    /// Go to the next incoming edge.
155    InEdgeIt &next(InEdgeIt &i) const { return i;}
156    /// Go to the next outgoing edge.
157    OutEdgeIt &next(OutEdgeIt &i) const { return i;}
158    //SymEdgeIt &next(SymEdgeIt &) const {}
159    /// Go to the next edge.
160    EdgeIt &next(EdgeIt &i) const { return i;}
161
162    ///Gives back the head node of an edge.
163    Node head(Edge) const { return INVALID; }
164    ///Gives back the tail node of an edge.
165    Node tail(Edge) const { return INVALID; }
166 
167    //   Node aNode(InEdgeIt) const {}
168    //   Node aNode(OutEdgeIt) const {}
169    //   Node aNode(SymEdgeIt) const {}
170
171    //   Node bNode(InEdgeIt) const {}
172    //   Node bNode(OutEdgeIt) const {}
173    //   Node bNode(SymEdgeIt) const {}
174
175    /// Checks if a node iterator is valid
176    bool valid(const Node) const { return true;}
177    /// Checks if an edge iterator is valid
178    bool valid(const Edge) const { return true;}
179
180    ///Gives back the \e id of a node.
181
182    ///\warning Not all graph structure provide this feature.
183    ///
184    int id(const Node) const { return 0;}
185    ///Gives back the \e id of an edge.
186
187    ///\warning Not all graph structure provide this feature.
188    ///
189    int id(const Edge) const { return 0;}
190
191    //void setInvalid(Node &) const {};
192    //void setInvalid(Edge &) const {};
193 
194    ///Add a new node to the graph.
195
196    /// \return the new node.
197    Node addNode() { return INVALID;}
198    ///Add a new edge to the graph.
199
200    ///Add a new edge to the graph with tail node \c tail
201    ///and head node \c head.
202    ///\return the new edge.
203    Edge addEdge(Node tail, Node head) { return INVALID;}
204   
205    /// Deletes a node.
206   
207    ///\warning Not all graph structure provide this feature.
208    ///
209    void erase(Node n) {}
210    /// Deletes an edge.
211
212    ///\warning Not all graph structure provide this feature.
213    ///
214    void erase(Edge e) {}
215
216    /// Reset the graph.
217
218    /// This function deletes all edges and nodes of the graph.
219    /// It also frees the memory allocated to store them.
220    void clear() {}
221
222    int nodeNum() const { return 0;}
223    int edgeNum() const { return 0;}
224
225    GraphSkeleton() {}
226    GraphSkeleton(const GraphSkeleton &G) {}
227 
228 
229
230    ///Read/write map of the nodes to type \c T.
231
232    /// \todo We may need copy constructor
233    /// \todo We may need conversion from other nodetype
234    /// \todo We may need operator=
235
236    template<class T> class NodeMap
237    {
238    public:
239      typedef T ValueType;
240      typedef Node KeyType;
241
242      NodeMap(const GraphSkeleton &G) {}
243      NodeMap(const GraphSkeleton &G, T t) {}
244
245      template<typename TT> NodeMap(const NodeMap<TT> &m) {}
246
247      /// Sets the value of a node.
248
249      /// Sets the value associated with node \c i to the value \c t.
250      ///
251      void set(Node i, T t) {}
252      /// Gets the value of a node.
253      T get(Node i) const {return *(T*)0;}  //FIXME: Is it necessary
254      T &operator[](Node i) {return *(T*)0;}
255      const T &operator[](Node i) const {return *(T*)0;}
256
257      /// Updates the map if the graph has been changed
258
259      /// \todo Do we need this?
260      ///
261      void update() {}
262      void update(T a) {}   //FIXME: Is it necessary
263    };
264
265    ///Read/write map of the edges to type \c T.
266
267    ///Read/write map of the edges to type \c T.
268    ///It behaves exactly the same way as \ref NodeMap.
269    template<class T> class EdgeMap
270    {
271    public:
272      typedef T ValueType;
273      typedef Edge KeyType;
274
275      EdgeMap(const GraphSkeleton &G) {}
276      EdgeMap(const GraphSkeleton &G, T t) {}
277   
278      void set(Edge i, T t) {}
279      T get(Edge i) const {return *(T*)0;}
280      T &operator[](Edge i) {return *(T*)0;}
281   
282      void update() {}
283      void update(T a) {}   //FIXME: Is it necessary
284    };
285  };
286
287  // @}
288
289} //namespace hugo
290
291
292
293// class EmptyBipGraph : public Graph Skeleton
294// {
295//   class ANode {};
296//   class BNode {};
297
298//   ANode &next(ANode &) {}
299//   BNode &next(BNode &) {}
300
301//   ANode &getFirst(ANode &) const {}
302//   BNode &getFirst(BNode &) const {}
303
304//   enum NodeClass { A = 0, B = 1 };
305//   NodeClass getClass(Node n) {}
306
307// }
308
309#endif // EMPTYGRAPH_H
Note: See TracBrowser for help on using the repository browser.