1 | // -*- c++ -*- |
---|
2 | #ifndef EMPTYGRAPH_H |
---|
3 | #define EMPTYGRAPH_H |
---|
4 | |
---|
5 | #include <invalid.h> |
---|
6 | |
---|
7 | /// The namespace of HugoLib |
---|
8 | namespace hugo { |
---|
9 | |
---|
10 | // @defgroup empty_graph The EmptyGraph 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 EmptyGraph |
---|
29 | { |
---|
30 | public: |
---|
31 | |
---|
32 | /// The base type of the node iterators. |
---|
33 | class Node { |
---|
34 | public: |
---|
35 | /// @warning The default constructor sets the iterator |
---|
36 | /// to an undefined value. |
---|
37 | Node() {} //FIXME |
---|
38 | /// Initialize the iterator to be invalid |
---|
39 | Node(Invalid) {} |
---|
40 | //Node(const Node &) {} |
---|
41 | bool operator==(Node n) const { return true; } //FIXME |
---|
42 | bool operator!=(Node n) const { return true; } //FIXME |
---|
43 | }; |
---|
44 | |
---|
45 | /// This iterator goes through each node. |
---|
46 | class NodeIt : public Node { |
---|
47 | public: |
---|
48 | /// @warning The default constructor sets the iterator |
---|
49 | /// to an undefined value. |
---|
50 | NodeIt() {} //FIXME |
---|
51 | /// Initialize the iterator to be invalid |
---|
52 | NodeIt(Invalid) {} |
---|
53 | /// Sets the iterator to the first node of \c G. |
---|
54 | NodeIt(const EmptyGraph &G) {} |
---|
55 | NodeIt(const NodeIt &) {} //FIXME |
---|
56 | }; |
---|
57 | |
---|
58 | |
---|
59 | /// The base type of the edge iterators. |
---|
60 | class Edge { |
---|
61 | public: |
---|
62 | /// @warning The default constructor sets the iterator |
---|
63 | /// to an undefined value. |
---|
64 | Edge() {} //FIXME |
---|
65 | /// Initialize the iterator to be invalid |
---|
66 | Edge(Invalid) {} |
---|
67 | //Edge(const Edge &) {} |
---|
68 | bool operator==(Edge n) const { return true; } //FIXME |
---|
69 | bool operator!=(Edge n) const { return true; } //FIXME |
---|
70 | }; |
---|
71 | |
---|
72 | /// This iterator goes trought the outgoing edges of a certain graph. |
---|
73 | |
---|
74 | class OutEdgeIt : public Edge { |
---|
75 | public: |
---|
76 | /// @warning The default constructor sets the iterator |
---|
77 | /// to an undefined value. |
---|
78 | OutEdgeIt() {} |
---|
79 | /// Initialize the iterator to be invalid |
---|
80 | OutEdgeIt(Invalid) {} |
---|
81 | /// This constructor sets the iterator to first outgoing edge. |
---|
82 | |
---|
83 | /// This constructor set the iterator to the first outgoing edge of |
---|
84 | /// node |
---|
85 | ///@param n the node |
---|
86 | ///@param G the graph |
---|
87 | OutEdgeIt(const EmptyGraph & G, Node n) {} |
---|
88 | }; |
---|
89 | |
---|
90 | class InEdgeIt : public Edge { |
---|
91 | public: |
---|
92 | /// @warning The default constructor sets the iterator |
---|
93 | /// to an undefined value. |
---|
94 | InEdgeIt() {} |
---|
95 | /// Initialize the iterator to be invalid |
---|
96 | InEdgeIt(Invalid) {} |
---|
97 | InEdgeIt(const EmptyGraph &, Node) {} |
---|
98 | }; |
---|
99 | // class SymEdgeIt : public Edge {}; |
---|
100 | class EdgeIt : public Edge { |
---|
101 | public: |
---|
102 | /// @warning The default constructor sets the iterator |
---|
103 | /// to an undefined value. |
---|
104 | EdgeIt() {} |
---|
105 | /// Initialize the iterator to be invalid |
---|
106 | EdgeIt(Invalid) {} |
---|
107 | EdgeIt(const EmptyGraph &) {} |
---|
108 | }; |
---|
109 | |
---|
110 | /// First node of the graph. |
---|
111 | |
---|
112 | /// \post \c i and the return value will be the first node. |
---|
113 | /// |
---|
114 | NodeIt &first(NodeIt &i) const { return i;} |
---|
115 | |
---|
116 | /// The first outgoing edge. |
---|
117 | InEdgeIt &first(InEdgeIt &i, Node n) const { return i;} |
---|
118 | /// The first incoming edge. |
---|
119 | OutEdgeIt &first(OutEdgeIt &i, Node n) const { return i;} |
---|
120 | // SymEdgeIt &first(SymEdgeIt &, Node) const { return i;} |
---|
121 | /// The first edge of the Graph. |
---|
122 | EdgeIt &first(EdgeIt &i) const { return i;} |
---|
123 | |
---|
124 | // Node getNext(Node) const {} |
---|
125 | // InEdgeIt getNext(InEdgeIt) const {} |
---|
126 | // OutEdgeIt getNext(OutEdgeIt) const {} |
---|
127 | // //SymEdgeIt getNext(SymEdgeIt) const {} |
---|
128 | // EdgeIt getNext(EdgeIt) const {} |
---|
129 | |
---|
130 | /// Go to the next node. |
---|
131 | NodeIt &next(NodeIt &i) const { return i;} |
---|
132 | /// Go to the next incoming edge. |
---|
133 | InEdgeIt &next(InEdgeIt &i) const { return i;} |
---|
134 | /// Go to the next outgoing edge. |
---|
135 | OutEdgeIt &next(OutEdgeIt &i) const { return i;} |
---|
136 | //SymEdgeIt &next(SymEdgeIt &) const {} |
---|
137 | /// Go to the next edge. |
---|
138 | EdgeIt &next(EdgeIt &i) const { return i;} |
---|
139 | |
---|
140 | ///Gives back the head node of an edge. |
---|
141 | Node head(Edge) const { return INVALID; } |
---|
142 | ///Gives back the tail node of an edge. |
---|
143 | Node tail(Edge) const { return INVALID; } |
---|
144 | |
---|
145 | // Node aNode(InEdgeIt) const {} |
---|
146 | // Node aNode(OutEdgeIt) const {} |
---|
147 | // Node aNode(SymEdgeIt) const {} |
---|
148 | |
---|
149 | // Node bNode(InEdgeIt) const {} |
---|
150 | // Node bNode(OutEdgeIt) const {} |
---|
151 | // Node bNode(SymEdgeIt) const {} |
---|
152 | |
---|
153 | /// Checks if a node iterator is valid |
---|
154 | bool valid(const Node) const { return true;} |
---|
155 | /// Checks if an edge iterator is valid |
---|
156 | bool valid(const Edge) const { return true;} |
---|
157 | |
---|
158 | ///Gives back the \e id of a node. |
---|
159 | int id(const Node) const { return 0;} |
---|
160 | ///Gives back the \e id of an edge. |
---|
161 | int id(const Edge) const { return 0;} |
---|
162 | |
---|
163 | //void setInvalid(Node &) const {}; |
---|
164 | //void setInvalid(Edge &) const {}; |
---|
165 | |
---|
166 | Node addNode() { return INVALID;} |
---|
167 | Edge addEdge(Node tail, Node head) { return INVALID;} |
---|
168 | |
---|
169 | void erase(Node n) {} |
---|
170 | void erase(Edge e) {} |
---|
171 | |
---|
172 | void clear() {} |
---|
173 | |
---|
174 | int nodeNum() const { return 0;} |
---|
175 | int edgeNum() const { return 0;} |
---|
176 | |
---|
177 | EmptyGraph() {} |
---|
178 | EmptyGraph(const EmptyGraph &G) {} |
---|
179 | |
---|
180 | |
---|
181 | |
---|
182 | ///Read/write map from the nodes to type \c T. |
---|
183 | template<class T> class NodeMap |
---|
184 | { |
---|
185 | public: |
---|
186 | typedef T ValueType; |
---|
187 | typedef Node KeyType; |
---|
188 | |
---|
189 | NodeMap(const EmptyGraph &G) {} |
---|
190 | NodeMap(const EmptyGraph &G, T t) {} |
---|
191 | |
---|
192 | void set(Node i, T t) {} |
---|
193 | T get(Node i) const {return *(T*)NULL;} //FIXME: Is it necessary |
---|
194 | T &operator[](Node i) {return *(T*)NULL;} |
---|
195 | const T &operator[](Node i) const {return *(T*)NULL;} |
---|
196 | |
---|
197 | void update() {} |
---|
198 | void update(T a) {} //FIXME: Is it necessary |
---|
199 | }; |
---|
200 | |
---|
201 | ///Read/write map from the edges to type \c T. |
---|
202 | template<class T> class EdgeMap |
---|
203 | { |
---|
204 | public: |
---|
205 | typedef T ValueType; |
---|
206 | typedef Edge KeyType; |
---|
207 | |
---|
208 | EdgeMap(const EmptyGraph &G) {} |
---|
209 | EdgeMap(const EmptyGraph &G, T t) {} |
---|
210 | |
---|
211 | void set(Edge i, T t) {} |
---|
212 | T get(Edge i) const {return *(T*)NULL;} |
---|
213 | T &operator[](Edge i) {return *(T*)NULL;} |
---|
214 | |
---|
215 | void update() {} |
---|
216 | void update(T a) {} //FIXME: Is it necessary |
---|
217 | }; |
---|
218 | }; |
---|
219 | |
---|
220 | // @} |
---|
221 | |
---|
222 | } //namespace hugo |
---|
223 | |
---|
224 | |
---|
225 | |
---|
226 | // class EmptyBipGraph : public EmptyGraph |
---|
227 | // { |
---|
228 | // class ANode {}; |
---|
229 | // class BNode {}; |
---|
230 | |
---|
231 | // ANode &next(ANode &) {} |
---|
232 | // BNode &next(BNode &) {} |
---|
233 | |
---|
234 | // ANode &getFirst(ANode &) const {} |
---|
235 | // BNode &getFirst(BNode &) const {} |
---|
236 | |
---|
237 | // enum NodeClass { A = 0, B = 1 }; |
---|
238 | // NodeClass getClass(Node n) {} |
---|
239 | |
---|
240 | // } |
---|
241 | |
---|
242 | #endif // EMPTYGRAPH_H |
---|