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