Kruskal lenyegeben kesz.
Kell meg dokumentalni, meg meg egy par jol hasznalhato wrapper fv.
Es valamit meg kene csinalni azzal, hogy nem const ref. a kimeno boolmap,
viszont sokszor "on-the-fly" akarjuk megkonstrualni (es ilyenkor persze a
const-os mapet is lehet set-elni...)
6 ///\brief Declaration of GraphSkeleturo.
10 /// The namespace of HugoLib
13 /// @defgroup empty_graph The GraphSkeleturo 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.
34 /// Defalult constructor.
38 ///\todo It is not clear, what we expect from a copy constructor.
39 ///E.g. How to assign the nodes/edges to each other? What about maps?
40 GraphSkeleturo(const GraphSkeleturo &G) {}
42 /// The base type of the node iterators.
44 /// This is the base type of each node iterators,
45 /// thus each kind of node iterator will convert to this.
48 /// @warning The default constructor sets the iterator
49 /// to an undefined value.
51 /// Invalid constructor \& conversion.
53 /// This constructor initializes the iterator to be invalid.
54 /// \sa Invalid for more details.
57 //Node(const Node &) {}
59 /// Two iterators are equal if and only if they point to the
60 /// same object or both are invalid.
61 bool operator==(Node n) const { return true; }
63 /// \sa \ref operator==(Node n)
65 bool operator!=(Node n) const { return true; }
67 bool operator<(Node n) const { return true; }
70 /// This iterator goes through each node.
72 /// This iterator goes through each node.
73 /// Its usage is quite simple, for example you can count the number
74 /// of nodes in graph \c G of type \c Graph like this:
77 ///for(Graph::NodeIt n(G);G.valid(n);G.next(n)) count++;
79 class NodeIt : public Node {
81 /// @warning The default constructor sets the iterator
82 /// to an undefined value.
84 /// Invalid constructor \& conversion.
86 /// Initialize the iterator to be invalid
87 /// \sa Invalid for more details.
89 /// Sets the iterator to the first node of \c G.
90 NodeIt(const GraphSkeleturo &G) {}
91 /// @warning The default constructor sets the iterator
92 /// to an undefined value.
93 NodeIt(const NodeIt &) {}
97 /// The base type of the edge iterators.
100 /// @warning The default constructor sets the iterator
101 /// to an undefined value.
103 /// Initialize the iterator to be invalid
105 /// Two iterators are equal if and only if they point to the
106 /// same object or both are invalid.
107 bool operator==(Edge n) const { return true; }
108 bool operator!=(Edge n) const { return true; }
109 bool operator<(Edge n) const { return true; }
112 // class SymEdgeIt : public Edge {};
114 /// This iterator goes through each edge.
116 /// This iterator goes through each edge of a graph.
117 /// Its usage is quite simple, for example you can count the number
118 /// of edges in a graph \c G of type \c Graph as follows:
121 ///for(Graph::EdgeIt e(G);G.valid(e);G.next(e)) count++;
123 class EdgeIt : public Edge {
125 /// @warning The default constructor sets the iterator
126 /// to an undefined value.
128 /// Initialize the iterator to be invalid
130 EdgeIt(const GraphSkeleturo &) {}
133 /// First node of the graph.
135 /// \post \c i and the return value will be the first node.
137 NodeIt &first(NodeIt &i) const { return i;}
139 /// The first incoming edge.
140 InEdgeIt &first(InEdgeIt &i, Node n) const { return i;}
141 /// The first outgoing edge.
142 OutEdgeIt &first(OutEdgeIt &i, Node n) const { return i;}
143 // SymEdgeIt &first(SymEdgeIt &, Node) const { return i;}
144 /// The first edge of the Graph.
145 EdgeIt &first(EdgeIt &i) const { return i;}
147 // Node getNext(Node) const {}
148 // InEdgeIt getNext(InEdgeIt) const {}
149 // OutEdgeIt getNext(OutEdgeIt) const {}
150 // //SymEdgeIt getNext(SymEdgeIt) const {}
151 // EdgeIt getNext(EdgeIt) const {}
153 /// Go to the next node.
154 NodeIt &next(NodeIt &i) const { return i;}
155 /// Go to the next incoming edge.
156 InEdgeIt &next(InEdgeIt &i) const { return i;}
157 /// Go to the next outgoing edge.
158 OutEdgeIt &next(OutEdgeIt &i) const { return i;}
159 //SymEdgeIt &next(SymEdgeIt &) const {}
160 /// Go to the next edge.
161 EdgeIt &next(EdgeIt &i) const { return i;}
163 ///Gives back the head node of an edge.
164 Node head(Edge) const { return INVALID; }
165 ///Gives back the tail node of an edge.
166 Node tail(Edge) const { return INVALID; }
168 // Node aNode(InEdgeIt) const {}
169 // Node aNode(OutEdgeIt) const {}
170 // Node aNode(SymEdgeIt) const {}
172 // Node bNode(InEdgeIt) const {}
173 // Node bNode(OutEdgeIt) const {}
174 // Node bNode(SymEdgeIt) const {}
176 /// Checks if a node iterator is valid
178 ///\todo Maybe, it would be better if iterator converted to
179 ///bool directly, as Jacint prefers.
180 bool valid(const Node&) const { return true;}
181 /// Checks if an edge iterator is valid
183 ///\todo Maybe, it would be better if iterator converted to
184 ///bool directly, as Jacint prefers.
185 bool valid(const Edge&) const { return true;}
187 ///Gives back the \e id of a node.
189 ///\warning Not all graph structures provide this feature.
191 int id(const Node&) const { return 0;}
192 ///Gives back the \e id of an edge.
194 ///\warning Not all graph structures provide this feature.
196 int id(const Edge&) const { return 0;}
198 //void setInvalid(Node &) const {};
199 //void setInvalid(Edge &) const {};
201 ///Add a new node to the graph.
203 /// \return the new node.
205 Node addNode() { return INVALID;}
206 ///Add a new edge to the graph.
208 ///Add a new edge to the graph with tail node \c tail
209 ///and head node \c head.
210 ///\return the new edge.
211 Edge addEdge(Node tail, Node head) { return INVALID;}
213 /// Resets the graph.
215 /// This function deletes all edges and nodes of the graph.
216 /// It also frees the memory allocated to store them.
219 ///Read/write/reference map of the nodes to type \c T.
221 ///Read/write/reference map of the nodes to type \c T.
222 /// \sa MemoryMapSkeleturo
223 /// \todo We may need copy constructor
224 /// \todo We may need conversion from other nodetype
225 /// \todo We may need operator=
226 /// \warning Making maps that can handle bool type (NodeMap<bool>)
227 /// needs extra attention!
229 template<class T> class NodeMap
233 typedef Node KeyType;
235 NodeMap(const GraphSkeleturo &G) {}
236 NodeMap(const GraphSkeleturo &G, T t) {}
238 template<typename TT> NodeMap(const NodeMap<TT> &m) {}
240 /// Sets the value of a node.
242 /// Sets the value associated with node \c i to the value \c t.
244 void set(Node i, T t) {}
245 /// Gets the value of a node.
246 T get(Node i) const {return *(T*)0;} //FIXME: Is it necessary
247 T &operator[](Node i) {return *(T*)0;}
248 const T &operator[](Node i) const {return *(T*)0;}
250 /// Updates the map if the graph has been changed
252 /// \todo Do we need this?
255 void update(T a) {} //FIXME: Is it necessary
258 ///Read/write/reference map of the edges to type \c T.
260 ///Read/write/reference map of the edges to type \c T.
261 ///It behaves exactly in the same way as \ref NodeMap.
263 /// \sa MemoryMapSkeleturo
264 /// \todo We may need copy constructor
265 /// \todo We may need conversion from other edgetype
266 /// \todo We may need operator=
267 template<class T> class EdgeMap
271 typedef Edge KeyType;
273 EdgeMap(const GraphSkeleturo &G) {}
274 EdgeMap(const GraphSkeleturo &G, T t) {}
276 void set(Edge i, T t) {}
277 T get(Edge i) const {return *(T*)0;}
278 T &operator[](Edge i) {return *(T*)0;}
281 void update(T a) {} //FIXME: Is it necessary
285 /// An empty eraseable graph class.
287 /// This class provides all the common features of an \e eraseable graph
289 /// however completely without implementations and real data structures
290 /// behind the interface.
291 /// All graph algorithms should compile with this class, but it will not
292 /// run properly, of course.
294 /// \todo This blabla could be replaced by a sepatate description about
297 /// It can be used for checking the interface compatibility,
298 /// or it can serve as a skeleton of a new graph structure.
300 /// Also, you will find here the full documentation of a certain graph
301 /// feature, the documentation of a real graph imlementation
302 /// like @ref ListGraph or
303 /// @ref SmartGraph will just refer to this structure.
304 class EraseableGraphSkeleturo : public GraphSkeleturo
308 void erase(Node n) {}
310 void erase(Edge e) {}
312 /// Defalult constructor.
315 GraphSkeleturo(const GraphSkeleturo &G) {}
318 /// An empty out-edge-iterable graph class.
320 /// An empty graph class which provides a function to
321 /// iterate on out-edges of any node.
322 class OutEdgeIterableGraphSkeleturo : public GraphSkeleturo
326 /// This iterator goes trough the outgoing edges of a node.
328 /// This iterator goes trough the \e outgoing edges of a certain node
330 /// Its usage is quite simple, for example you can count the number
331 /// of outgoing edges of a node \c n
332 /// in graph \c G of type \c Graph as follows.
335 ///for(Graph::OutEdgeIt e(G,n); G.valid(e); G.next(e)) ++count;
337 class OutEdgeIt : public Edge {
339 /// @warning The default constructor sets the iterator
340 /// to an undefined value.
342 /// Initialize the iterator to be invalid
343 OutEdgeIt(Invalid) {}
344 /// This constructor sets the iterator to first outgoing edge.
346 /// This constructor set the iterator to the first outgoing edge of
349 ///@param G the graph
350 OutEdgeIt(const GraphSkeleturo & G, Node n) {}
354 /// An empty in-edge-iterable graph class.
356 /// An empty graph class which provides a function to
357 /// iterate on in-edges of any node.
358 class InEdgeIterableGraphSkeleturo : public GraphSkeleturo
362 /// This iterator goes trough the incoming edges of a node.
364 /// This iterator goes trough the \e incoming edges of a certain node
366 /// Its usage is quite simple, for example you can count the number
367 /// of incoming edges of a node \c n
368 /// in graph \c G of type \c Graph as follows.
371 ///for(Graph::InEdgeIt e(G,n); G.valid(e); G.next(e)) ++count;
373 class InEdgeIt : public Edge {
375 /// @warning The default constructor sets the iterator
376 /// to an undefined value.
378 /// Initialize the iterator to be invalid
380 /// This constructor sets the iterator to first incomig edge.
382 /// This constructor set the iterator to the first incomig edge of
385 ///@param G the graph
386 InEdgeIt(const GraphSkeleturo & G, Node n) {}
391 /// An empty node-eraseable graph class.
393 /// An empty graph class which provides a function to
394 /// delete any of its nodes.
395 class NodeEraseableGraphSkeleturo : public GraphSkeleturo
399 void erase(Node n) {}
402 /// An empty edge-eraseable graph class.
404 /// An empty graph class which provides a function to delete any
406 class EdgeEraseableGraphSkeleturo : public GraphSkeleturo
410 void erase(Edge n) {}
413 /// An empty graph class which provides a function to get the number of its nodes.
415 /// This graph class provides a function for getting the number of its
417 /// Clearly, for physical graph structures it can be expected to have such a
418 /// function. For wrappers or graphs which are given in an implicit way,
419 /// the implementation can be circumstantial, that is why this composes a
420 /// separate concept.
421 class NodeCountingGraphSkeleturo : public GraphSkeleturo
424 /// Returns the number of nodes.
425 int nodeNum() const { return 0;}
428 /// An empty graph class which provides a function to get the number of its edges.
430 /// This graph class provides a function for getting the number of its
432 /// Clearly, for physical graph structures it can be expected to have such a
433 /// function. For wrappers or graphs which are given in an implicit way,
434 /// the implementation can be circumstantial, that is why this composes a
435 /// separate concept.
436 class EdgeCountingGraphSkeleturo : public GraphSkeleturo
439 /// Returns the number of edges.
440 int edgeNum() const { return 0;}
449 // class EmptyBipGraph : public Graph Skeleturo
454 // ANode &next(ANode &) {}
455 // BNode &next(BNode &) {}
457 // ANode &getFirst(ANode &) const {}
458 // BNode &getFirst(BNode &) const {}
460 // enum NodeClass { A = 0, B = 1 };
461 // NodeClass getClass(Node n) {}
465 #endif // HUGO_GRAPH_H