COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/alpar/emptygraph.h @ 165:9b078bc3ce13

Last change on this file since 165:9b078bc3ce13 was 165:9b078bc3ce13, checked in by Alpar Juttner, 20 years ago

Some mod in the doc

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