1 | /* -*- C++ -*- |
---|
2 | * lemon/concept/graph.h - Part of LEMON, a generic C++ optimization library |
---|
3 | * |
---|
4 | * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
---|
5 | * (Egervary Research Group on Combinatorial Optimization, EGRES). |
---|
6 | * |
---|
7 | * Permission to use, modify and distribute this software is granted |
---|
8 | * provided that this copyright notice appears in all copies. For |
---|
9 | * precise terms see the accompanying LICENSE file. |
---|
10 | * |
---|
11 | * This software is provided "AS IS" with no warranty of any kind, |
---|
12 | * express or implied, and with no claim as to its suitability for any |
---|
13 | * purpose. |
---|
14 | * |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef LEMON_CONCEPT_GRAPH_H |
---|
18 | #define LEMON_CONCEPT_GRAPH_H |
---|
19 | |
---|
20 | ///\ingroup graph_concepts |
---|
21 | ///\file |
---|
22 | ///\brief Declaration of Graph. |
---|
23 | |
---|
24 | #include <lemon/invalid.h> |
---|
25 | #include <lemon/utility.h> |
---|
26 | #include <lemon/concept/maps.h> |
---|
27 | #include <lemon/concept_check.h> |
---|
28 | #include <lemon/concept/graph_component.h> |
---|
29 | |
---|
30 | namespace lemon { |
---|
31 | namespace concept { |
---|
32 | |
---|
33 | |
---|
34 | /**************** The full-featured graph concepts ****************/ |
---|
35 | |
---|
36 | |
---|
37 | /// \brief Modular static graph class. |
---|
38 | /// |
---|
39 | /// It should be the same as the \c StaticGraph class. |
---|
40 | class _StaticGraph |
---|
41 | : virtual public BaseGraphComponent, |
---|
42 | public IterableGraphComponent, public MappableGraphComponent { |
---|
43 | public: |
---|
44 | ///\e |
---|
45 | |
---|
46 | ///\todo undocumented |
---|
47 | /// |
---|
48 | typedef False UndirTag; |
---|
49 | |
---|
50 | typedef BaseGraphComponent::Node Node; |
---|
51 | typedef BaseGraphComponent::Edge Edge; |
---|
52 | |
---|
53 | template <typename _Graph> |
---|
54 | struct Constraints { |
---|
55 | void constraints() { |
---|
56 | checkConcept<IterableGraphComponent, _Graph>(); |
---|
57 | checkConcept<MappableGraphComponent, _Graph>(); |
---|
58 | } |
---|
59 | }; |
---|
60 | }; |
---|
61 | |
---|
62 | /// \brief Modular extendable graph class. |
---|
63 | /// |
---|
64 | /// It should be the same as the \c ExtendableGraph class. |
---|
65 | class _ExtendableGraph |
---|
66 | : virtual public BaseGraphComponent, public _StaticGraph, |
---|
67 | public ExtendableGraphComponent, public ClearableGraphComponent { |
---|
68 | public: |
---|
69 | typedef BaseGraphComponent::Node Node; |
---|
70 | typedef BaseGraphComponent::Edge Edge; |
---|
71 | |
---|
72 | template <typename _Graph> |
---|
73 | struct Constraints { |
---|
74 | void constraints() { |
---|
75 | checkConcept<_StaticGraph, _Graph >(); |
---|
76 | checkConcept<ExtendableGraphComponent, _Graph >(); |
---|
77 | checkConcept<ClearableGraphComponent, _Graph >(); |
---|
78 | } |
---|
79 | }; |
---|
80 | }; |
---|
81 | |
---|
82 | /// \brief Modular erasable graph class. |
---|
83 | /// |
---|
84 | /// It should be the same as the \c ErasableGraph class. |
---|
85 | class _ErasableGraph |
---|
86 | : virtual public BaseGraphComponent, public _ExtendableGraph, |
---|
87 | public ErasableGraphComponent { |
---|
88 | public: |
---|
89 | typedef BaseGraphComponent::Node Node; |
---|
90 | typedef BaseGraphComponent::Edge Edge; |
---|
91 | |
---|
92 | template <typename _Graph> |
---|
93 | struct Constraints { |
---|
94 | void constraints() { |
---|
95 | checkConcept<_ExtendableGraph, _Graph >(); |
---|
96 | checkConcept<ErasableGraphComponent, _Graph >(); |
---|
97 | } |
---|
98 | }; |
---|
99 | }; |
---|
100 | |
---|
101 | /// \addtogroup graph_concepts |
---|
102 | /// @{ |
---|
103 | |
---|
104 | /// An empty static graph class. |
---|
105 | |
---|
106 | /// This class provides all the common features of a graph structure, |
---|
107 | /// however completely without implementations and real data structures |
---|
108 | /// behind the interface. |
---|
109 | /// All graph algorithms should compile with this class, but it will not |
---|
110 | /// run properly, of course. |
---|
111 | /// |
---|
112 | /// It can be used for checking the interface compatibility, |
---|
113 | /// or it can serve as a skeleton of a new graph structure. |
---|
114 | /// |
---|
115 | /// Also, you will find here the full documentation of a certain graph |
---|
116 | /// feature, the documentation of a real graph imlementation |
---|
117 | /// like @ref ListGraph or |
---|
118 | /// @ref SmartGraph will just refer to this structure. |
---|
119 | /// |
---|
120 | /// \todo A pages describing the concept of concept description would |
---|
121 | /// be nice. |
---|
122 | class StaticGraph |
---|
123 | { |
---|
124 | public: |
---|
125 | ///\e |
---|
126 | |
---|
127 | ///\todo undocumented |
---|
128 | /// |
---|
129 | typedef False UndirTag; |
---|
130 | |
---|
131 | /// Defalult constructor. |
---|
132 | |
---|
133 | /// Defalult constructor. |
---|
134 | /// |
---|
135 | StaticGraph() { } |
---|
136 | ///Copy consructor. |
---|
137 | |
---|
138 | // ///\todo It is not clear, what we expect from a copy constructor. |
---|
139 | // ///E.g. How to assign the nodes/edges to each other? What about maps? |
---|
140 | // StaticGraph(const StaticGraph& g) { } |
---|
141 | |
---|
142 | /// The base type of node iterators, |
---|
143 | /// or in other words, the trivial node iterator. |
---|
144 | |
---|
145 | /// This is the base type of each node iterator, |
---|
146 | /// thus each kind of node iterator converts to this. |
---|
147 | /// More precisely each kind of node iterator should be inherited |
---|
148 | /// from the trivial node iterator. |
---|
149 | class Node { |
---|
150 | public: |
---|
151 | /// Default constructor |
---|
152 | |
---|
153 | /// @warning The default constructor sets the iterator |
---|
154 | /// to an undefined value. |
---|
155 | Node() { } |
---|
156 | /// Copy constructor. |
---|
157 | |
---|
158 | /// Copy constructor. |
---|
159 | /// |
---|
160 | Node(const Node&) { } |
---|
161 | |
---|
162 | /// Invalid constructor \& conversion. |
---|
163 | |
---|
164 | /// This constructor initializes the iterator to be invalid. |
---|
165 | /// \sa Invalid for more details. |
---|
166 | Node(Invalid) { } |
---|
167 | /// Equality operator |
---|
168 | |
---|
169 | /// Two iterators are equal if and only if they point to the |
---|
170 | /// same object or both are invalid. |
---|
171 | bool operator==(Node) const { return true; } |
---|
172 | |
---|
173 | /// Inequality operator |
---|
174 | |
---|
175 | /// \sa operator==(Node n) |
---|
176 | /// |
---|
177 | bool operator!=(Node) const { return true; } |
---|
178 | |
---|
179 | /// Artificial ordering operator. |
---|
180 | |
---|
181 | /// To allow the use of graph descriptors as key type in std::map or |
---|
182 | /// similar associative container we require this. |
---|
183 | /// |
---|
184 | /// \note This operator only have to define some strict ordering of |
---|
185 | /// the items; this order has nothing to do with the iteration |
---|
186 | /// ordering of the items. |
---|
187 | /// |
---|
188 | /// \bug This is a technical requirement. Do we really need this? |
---|
189 | bool operator<(Node) const { return false; } |
---|
190 | |
---|
191 | }; |
---|
192 | |
---|
193 | /// This iterator goes through each node. |
---|
194 | |
---|
195 | /// This iterator goes through each node. |
---|
196 | /// Its usage is quite simple, for example you can count the number |
---|
197 | /// of nodes in graph \c g of type \c Graph like this: |
---|
198 | /// \code |
---|
199 | /// int count=0; |
---|
200 | /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count; |
---|
201 | /// \endcode |
---|
202 | class NodeIt : public Node { |
---|
203 | public: |
---|
204 | /// Default constructor |
---|
205 | |
---|
206 | /// @warning The default constructor sets the iterator |
---|
207 | /// to an undefined value. |
---|
208 | NodeIt() { } |
---|
209 | /// Copy constructor. |
---|
210 | |
---|
211 | /// Copy constructor. |
---|
212 | /// |
---|
213 | NodeIt(const NodeIt& n) : Node(n) { } |
---|
214 | /// Invalid constructor \& conversion. |
---|
215 | |
---|
216 | /// Initialize the iterator to be invalid. |
---|
217 | /// \sa Invalid for more details. |
---|
218 | NodeIt(Invalid) { } |
---|
219 | /// Sets the iterator to the first node. |
---|
220 | |
---|
221 | /// Sets the iterator to the first node of \c g. |
---|
222 | /// |
---|
223 | NodeIt(const StaticGraph&) { } |
---|
224 | /// Node -> NodeIt conversion. |
---|
225 | |
---|
226 | /// Sets the iterator to the node of \c the graph pointed by |
---|
227 | /// the trivial iterator. |
---|
228 | /// This feature necessitates that each time we |
---|
229 | /// iterate the edge-set, the iteration order is the same. |
---|
230 | NodeIt(const StaticGraph&, const Node&) { } |
---|
231 | /// Next node. |
---|
232 | |
---|
233 | /// Assign the iterator to the next node. |
---|
234 | /// |
---|
235 | NodeIt& operator++() { return *this; } |
---|
236 | }; |
---|
237 | |
---|
238 | |
---|
239 | /// The base type of the edge iterators. |
---|
240 | |
---|
241 | /// The base type of the edge iterators. |
---|
242 | /// |
---|
243 | class Edge { |
---|
244 | public: |
---|
245 | /// Default constructor |
---|
246 | |
---|
247 | /// @warning The default constructor sets the iterator |
---|
248 | /// to an undefined value. |
---|
249 | Edge() { } |
---|
250 | /// Copy constructor. |
---|
251 | |
---|
252 | /// Copy constructor. |
---|
253 | /// |
---|
254 | Edge(const Edge&) { } |
---|
255 | /// Initialize the iterator to be invalid. |
---|
256 | |
---|
257 | /// Initialize the iterator to be invalid. |
---|
258 | /// |
---|
259 | Edge(Invalid) { } |
---|
260 | /// Equality operator |
---|
261 | |
---|
262 | /// Two iterators are equal if and only if they point to the |
---|
263 | /// same object or both are invalid. |
---|
264 | bool operator==(Edge) const { return true; } |
---|
265 | /// Inequality operator |
---|
266 | |
---|
267 | /// \sa operator==(Edge n) |
---|
268 | /// |
---|
269 | bool operator!=(Edge) const { return true; } |
---|
270 | |
---|
271 | /// Artificial ordering operator. |
---|
272 | |
---|
273 | /// To allow the use of graph descriptors as key type in std::map or |
---|
274 | /// similar associative container we require this. |
---|
275 | /// |
---|
276 | /// \note This operator only have to define some strict ordering of |
---|
277 | /// the items; this order has nothing to do with the iteration |
---|
278 | /// ordering of the items. |
---|
279 | /// |
---|
280 | /// \bug This is a technical requirement. Do we really need this? |
---|
281 | bool operator<(Edge) const { return false; } |
---|
282 | }; |
---|
283 | |
---|
284 | /// This iterator goes trough the outgoing edges of a node. |
---|
285 | |
---|
286 | /// This iterator goes trough the \e outgoing edges of a certain node |
---|
287 | /// of a graph. |
---|
288 | /// Its usage is quite simple, for example you can count the number |
---|
289 | /// of outgoing edges of a node \c n |
---|
290 | /// in graph \c g of type \c Graph as follows. |
---|
291 | /// \code |
---|
292 | /// int count=0; |
---|
293 | /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
---|
294 | /// \endcode |
---|
295 | |
---|
296 | class OutEdgeIt : public Edge { |
---|
297 | public: |
---|
298 | /// Default constructor |
---|
299 | |
---|
300 | /// @warning The default constructor sets the iterator |
---|
301 | /// to an undefined value. |
---|
302 | OutEdgeIt() { } |
---|
303 | /// Copy constructor. |
---|
304 | |
---|
305 | /// Copy constructor. |
---|
306 | /// |
---|
307 | OutEdgeIt(const OutEdgeIt& e) : Edge(e) { } |
---|
308 | /// Initialize the iterator to be invalid. |
---|
309 | |
---|
310 | /// Initialize the iterator to be invalid. |
---|
311 | /// |
---|
312 | OutEdgeIt(Invalid) { } |
---|
313 | /// This constructor sets the iterator to the first outgoing edge. |
---|
314 | |
---|
315 | /// This constructor sets the iterator to the first outgoing edge of |
---|
316 | /// the node. |
---|
317 | OutEdgeIt(const StaticGraph&, const Node&) { } |
---|
318 | /// Edge -> OutEdgeIt conversion |
---|
319 | |
---|
320 | /// Sets the iterator to the value of the trivial iterator. |
---|
321 | /// This feature necessitates that each time we |
---|
322 | /// iterate the edge-set, the iteration order is the same. |
---|
323 | OutEdgeIt(const StaticGraph&, const Edge&) { } |
---|
324 | ///Next outgoing edge |
---|
325 | |
---|
326 | /// Assign the iterator to the next |
---|
327 | /// outgoing edge of the corresponding node. |
---|
328 | OutEdgeIt& operator++() { return *this; } |
---|
329 | }; |
---|
330 | |
---|
331 | /// This iterator goes trough the incoming edges of a node. |
---|
332 | |
---|
333 | /// This iterator goes trough the \e incoming edges of a certain node |
---|
334 | /// of a graph. |
---|
335 | /// Its usage is quite simple, for example you can count the number |
---|
336 | /// of outgoing edges of a node \c n |
---|
337 | /// in graph \c g of type \c Graph as follows. |
---|
338 | /// \code |
---|
339 | /// int count=0; |
---|
340 | /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
---|
341 | /// \endcode |
---|
342 | |
---|
343 | class InEdgeIt : public Edge { |
---|
344 | public: |
---|
345 | /// Default constructor |
---|
346 | |
---|
347 | /// @warning The default constructor sets the iterator |
---|
348 | /// to an undefined value. |
---|
349 | InEdgeIt() { } |
---|
350 | /// Copy constructor. |
---|
351 | |
---|
352 | /// Copy constructor. |
---|
353 | /// |
---|
354 | InEdgeIt(const InEdgeIt& e) : Edge(e) { } |
---|
355 | /// Initialize the iterator to be invalid. |
---|
356 | |
---|
357 | /// Initialize the iterator to be invalid. |
---|
358 | /// |
---|
359 | InEdgeIt(Invalid) { } |
---|
360 | /// This constructor sets the iterator to first incoming edge. |
---|
361 | |
---|
362 | /// This constructor set the iterator to the first incoming edge of |
---|
363 | /// the node. |
---|
364 | InEdgeIt(const StaticGraph&, const Node&) { } |
---|
365 | /// Edge -> InEdgeIt conversion |
---|
366 | |
---|
367 | /// Sets the iterator to the value of the trivial iterator \c e. |
---|
368 | /// This feature necessitates that each time we |
---|
369 | /// iterate the edge-set, the iteration order is the same. |
---|
370 | InEdgeIt(const StaticGraph&, const Edge&) { } |
---|
371 | /// Next incoming edge |
---|
372 | |
---|
373 | /// Assign the iterator to the next inedge of the corresponding node. |
---|
374 | /// |
---|
375 | InEdgeIt& operator++() { return *this; } |
---|
376 | }; |
---|
377 | /// This iterator goes through each edge. |
---|
378 | |
---|
379 | /// This iterator goes through each edge of a graph. |
---|
380 | /// Its usage is quite simple, for example you can count the number |
---|
381 | /// of edges in a graph \c g of type \c Graph as follows: |
---|
382 | /// \code |
---|
383 | /// int count=0; |
---|
384 | /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count; |
---|
385 | /// \endcode |
---|
386 | class EdgeIt : public Edge { |
---|
387 | public: |
---|
388 | /// Default constructor |
---|
389 | |
---|
390 | /// @warning The default constructor sets the iterator |
---|
391 | /// to an undefined value. |
---|
392 | EdgeIt() { } |
---|
393 | /// Copy constructor. |
---|
394 | |
---|
395 | /// Copy constructor. |
---|
396 | /// |
---|
397 | EdgeIt(const EdgeIt& e) : Edge(e) { } |
---|
398 | /// Initialize the iterator to be invalid. |
---|
399 | |
---|
400 | /// Initialize the iterator to be invalid. |
---|
401 | /// |
---|
402 | EdgeIt(Invalid) { } |
---|
403 | /// This constructor sets the iterator to the first edge. |
---|
404 | |
---|
405 | /// This constructor sets the iterator to the first edge of \c g. |
---|
406 | ///@param g the graph |
---|
407 | EdgeIt(const StaticGraph&) { } |
---|
408 | /// Edge -> EdgeIt conversion |
---|
409 | |
---|
410 | /// Sets the iterator to the value of the trivial iterator \c e. |
---|
411 | /// This feature necessitates that each time we |
---|
412 | /// iterate the edge-set, the iteration order is the same. |
---|
413 | EdgeIt(const StaticGraph&, const Edge&) { } |
---|
414 | ///Next edge |
---|
415 | |
---|
416 | /// Assign the iterator to the next edge. |
---|
417 | EdgeIt& operator++() { return *this; } |
---|
418 | }; |
---|
419 | ///Gives back the target node of an edge. |
---|
420 | |
---|
421 | ///Gives back the target node of an edge. |
---|
422 | /// |
---|
423 | Node target(Edge) const { return INVALID; } |
---|
424 | ///Gives back the source node of an edge. |
---|
425 | |
---|
426 | ///Gives back the source node of an edge. |
---|
427 | /// |
---|
428 | Node source(Edge) const { return INVALID; } |
---|
429 | |
---|
430 | /// Gives back the first Node in the iterating order. |
---|
431 | |
---|
432 | /// Gives back the first Node in the iterating order. |
---|
433 | /// |
---|
434 | void first(Node&) const {} |
---|
435 | |
---|
436 | /// Gives back the next Node in the iterating order. |
---|
437 | |
---|
438 | /// Gives back the next Node in the iterating order. |
---|
439 | /// |
---|
440 | void next(Node&) const {} |
---|
441 | |
---|
442 | /// Gives back the first Edge in the iterating order. |
---|
443 | |
---|
444 | /// Gives back the first Edge in the iterating order. |
---|
445 | /// |
---|
446 | void first(Edge&) const {} |
---|
447 | /// Gives back the next Edge in the iterating order. |
---|
448 | |
---|
449 | /// Gives back the next Edge in the iterating order. |
---|
450 | /// |
---|
451 | void next(Edge&) const {} |
---|
452 | |
---|
453 | |
---|
454 | /// Gives back the first of the Edges point to the given Node. |
---|
455 | |
---|
456 | /// Gives back the first of the Edges point to the given Node. |
---|
457 | /// |
---|
458 | void firstIn(Edge&, const Node&) const {} |
---|
459 | |
---|
460 | /// Gives back the next of the Edges points to the given Node. |
---|
461 | |
---|
462 | |
---|
463 | /// Gives back the next of the Edges points to the given Node. |
---|
464 | /// |
---|
465 | void nextIn(Edge&) const {} |
---|
466 | |
---|
467 | /// Gives back the first of the Edges start from the given Node. |
---|
468 | |
---|
469 | /// Gives back the first of the Edges start from the given Node. |
---|
470 | /// |
---|
471 | void firstOut(Edge&, const Node&) const {} |
---|
472 | |
---|
473 | /// Gives back the next of the Edges start from the given Node. |
---|
474 | |
---|
475 | /// Gives back the next of the Edges start from the given Node. |
---|
476 | /// |
---|
477 | void nextOut(Edge&) const {} |
---|
478 | |
---|
479 | /// \brief The base node of the iterator. |
---|
480 | /// |
---|
481 | /// Gives back the base node of the iterator. |
---|
482 | Node baseNode(const InEdgeIt&) const { return INVALID; } |
---|
483 | |
---|
484 | /// \brief The running node of the iterator. |
---|
485 | /// |
---|
486 | /// Gives back the running node of the iterator. |
---|
487 | Node runningNode(const InEdgeIt&) const { return INVALID; } |
---|
488 | |
---|
489 | /// \brief The base node of the iterator. |
---|
490 | /// |
---|
491 | /// Gives back the base node of the iterator. |
---|
492 | Node baseNode(const OutEdgeIt&) const { return INVALID; } |
---|
493 | |
---|
494 | /// \brief The running node of the iterator. |
---|
495 | /// |
---|
496 | /// Gives back the running node of the iterator. |
---|
497 | Node runningNode(const OutEdgeIt&) const { return INVALID; } |
---|
498 | /// Read write map of the nodes to type \c T. |
---|
499 | |
---|
500 | /// \ingroup concept |
---|
501 | /// ReadWrite map of the nodes to type \c T. |
---|
502 | /// \sa Reference |
---|
503 | /// \warning Making maps that can handle bool type (NodeMap<bool>) |
---|
504 | /// needs some extra attention! |
---|
505 | template<class T> |
---|
506 | class NodeMap : public ReadWriteMap< Node, T > |
---|
507 | { |
---|
508 | public: |
---|
509 | |
---|
510 | ///\e |
---|
511 | NodeMap(const StaticGraph&) { } |
---|
512 | ///\e |
---|
513 | NodeMap(const StaticGraph&, T) { } |
---|
514 | |
---|
515 | ///Copy constructor |
---|
516 | NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } |
---|
517 | ///Assignment operator |
---|
518 | NodeMap& operator=(const NodeMap&) { return *this; } |
---|
519 | // \todo fix this concept |
---|
520 | }; |
---|
521 | |
---|
522 | /// Read write map of the edges to type \c T. |
---|
523 | |
---|
524 | /// \ingroup concept |
---|
525 | ///Reference map of the edges to type \c T. |
---|
526 | /// \sa Reference |
---|
527 | /// \warning Making maps that can handle bool type (EdgeMap<bool>) |
---|
528 | /// needs some extra attention! |
---|
529 | template<class T> |
---|
530 | class EdgeMap : public ReadWriteMap<Edge,T> |
---|
531 | { |
---|
532 | public: |
---|
533 | |
---|
534 | ///\e |
---|
535 | EdgeMap(const StaticGraph&) { } |
---|
536 | ///\e |
---|
537 | EdgeMap(const StaticGraph&, T) { } |
---|
538 | ///Copy constructor |
---|
539 | EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { } |
---|
540 | ///Assignment operator |
---|
541 | EdgeMap& operator=(const EdgeMap&) { return *this; } |
---|
542 | // \todo fix this concept |
---|
543 | }; |
---|
544 | |
---|
545 | template <typename _Graph> |
---|
546 | struct Constraints : public _StaticGraph::Constraints<_Graph> {}; |
---|
547 | |
---|
548 | }; |
---|
549 | |
---|
550 | /// An empty non-static graph class. |
---|
551 | |
---|
552 | /// This class provides everything that \ref StaticGraph does. |
---|
553 | /// Additionally it enables building graphs from scratch. |
---|
554 | class ExtendableGraph : public StaticGraph |
---|
555 | { |
---|
556 | public: |
---|
557 | /// Defalult constructor. |
---|
558 | |
---|
559 | /// Defalult constructor. |
---|
560 | /// |
---|
561 | ExtendableGraph() { } |
---|
562 | ///Add a new node to the graph. |
---|
563 | |
---|
564 | /// \return the new node. |
---|
565 | /// |
---|
566 | Node addNode() { return INVALID; } |
---|
567 | ///Add a new edge to the graph. |
---|
568 | |
---|
569 | ///Add a new edge to the graph with source node \c s |
---|
570 | ///and target node \c t. |
---|
571 | ///\return the new edge. |
---|
572 | Edge addEdge(Node, Node) { return INVALID; } |
---|
573 | |
---|
574 | /// Resets the graph. |
---|
575 | |
---|
576 | /// This function deletes all edges and nodes of the graph. |
---|
577 | /// It also frees the memory allocated to store them. |
---|
578 | /// \todo It might belong to \ref ErasableGraph. |
---|
579 | void clear() { } |
---|
580 | |
---|
581 | template <typename _Graph> |
---|
582 | struct Constraints : public _ExtendableGraph::Constraints<_Graph> {}; |
---|
583 | |
---|
584 | }; |
---|
585 | |
---|
586 | /// An empty erasable graph class. |
---|
587 | |
---|
588 | /// This class is an extension of \ref ExtendableGraph. It makes it |
---|
589 | /// possible to erase edges or nodes. |
---|
590 | class ErasableGraph : public ExtendableGraph |
---|
591 | { |
---|
592 | public: |
---|
593 | /// Defalult constructor. |
---|
594 | |
---|
595 | /// Defalult constructor. |
---|
596 | /// |
---|
597 | ErasableGraph() { } |
---|
598 | /// Deletes a node. |
---|
599 | |
---|
600 | /// Deletes node \c n node. |
---|
601 | /// |
---|
602 | void erase(Node) { } |
---|
603 | /// Deletes an edge. |
---|
604 | |
---|
605 | /// Deletes edge \c e edge. |
---|
606 | /// |
---|
607 | void erase(Edge) { } |
---|
608 | |
---|
609 | template <typename _Graph> |
---|
610 | struct Constraints : public _ErasableGraph::Constraints<_Graph> {}; |
---|
611 | |
---|
612 | }; |
---|
613 | |
---|
614 | |
---|
615 | /************* New GraphBase stuff **************/ |
---|
616 | |
---|
617 | |
---|
618 | // /// A minimal GraphBase concept |
---|
619 | |
---|
620 | // /// This class describes a minimal concept which can be extended to a |
---|
621 | // /// full-featured graph with \ref GraphFactory. |
---|
622 | // class GraphBase { |
---|
623 | // public: |
---|
624 | |
---|
625 | // GraphBase() {} |
---|
626 | |
---|
627 | // /// \bug Should we demand that Node and Edge be subclasses of the |
---|
628 | // /// Graph class??? |
---|
629 | |
---|
630 | // typedef GraphItem<'n'> Node; |
---|
631 | // typedef GraphItem<'e'> Edge; |
---|
632 | |
---|
633 | // // class Node : public BaseGraphItem<'n'> {}; |
---|
634 | // // class Edge : public BaseGraphItem<'e'> {}; |
---|
635 | |
---|
636 | // // Graph operation |
---|
637 | // void firstNode(Node &n) const { } |
---|
638 | // void firstEdge(Edge &e) const { } |
---|
639 | |
---|
640 | // void firstOutEdge(Edge &e, Node) const { } |
---|
641 | // void firstInEdge(Edge &e, Node) const { } |
---|
642 | |
---|
643 | // void nextNode(Node &n) const { } |
---|
644 | // void nextEdge(Edge &e) const { } |
---|
645 | |
---|
646 | |
---|
647 | // // Question: isn't it reasonable if this methods have a Node |
---|
648 | // // parameter? Like this: |
---|
649 | // // Edge& nextOut(Edge &e, Node) const { return e; } |
---|
650 | // void nextOutEdge(Edge &e) const { } |
---|
651 | // void nextInEdge(Edge &e) const { } |
---|
652 | |
---|
653 | // Node target(Edge) const { return Node(); } |
---|
654 | // Node source(Edge) const { return Node(); } |
---|
655 | |
---|
656 | |
---|
657 | // // Do we need id, nodeNum, edgeNum and co. in this basic graphbase |
---|
658 | // // concept? |
---|
659 | |
---|
660 | |
---|
661 | // // Maps. |
---|
662 | // // |
---|
663 | // // We need a special slimer concept which does not provide maps (it |
---|
664 | // // wouldn't be strictly slimer, cause for map-factory id() & friends |
---|
665 | // // a required...) |
---|
666 | |
---|
667 | // template<typename T> |
---|
668 | // class NodeMap : public GraphMap<GraphBase, Node, T> {}; |
---|
669 | |
---|
670 | // template<typename T> |
---|
671 | // class EdgeMap : public GraphMap<GraphBase, Node, T> {}; |
---|
672 | // }; |
---|
673 | |
---|
674 | // @} |
---|
675 | } //namespace concept |
---|
676 | } //namespace lemon |
---|
677 | |
---|
678 | |
---|
679 | |
---|
680 | #endif // LEMON_CONCEPT_GRAPH_H |
---|