COIN-OR::LEMON - Graph Library

source: lemon-0.x/lemon/concept/bpugraph.h @ 1933:a876a3d6a4c7

Last change on this file since 1933:a876a3d6a4c7 was 1933:a876a3d6a4c7, checked in by Balazs Dezso, 18 years ago

Revising the bpugraph concept

We need a public but very limited ANode and BNode class
It can be used with ItemSetTraits? and with some special maps

By example:
DescriptorMap?<Graph, ANode>
InvertableMap?<Graph, ANode, string>
IterableBoolMap?<Graph, ANode>
IterableIntMap?<Graph, ANode>
IterableValueMap?<Graph, ANode, string>

File size: 32.3 KB
Line 
1/* -*- C++ -*-
2 *
3 * lemon/concept/ugraph_component.h - Part of LEMON, a generic
4 * C++ optimization library
5 *
6 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi
7 * Kutatocsoport (Egervary Research Group on Combinatorial Optimization,
8 * EGRES).
9 *
10 * Permission to use, modify and distribute this software is granted
11 * provided that this copyright notice appears in all copies. For
12 * precise terms see the accompanying LICENSE file.
13 *
14 * This software is provided "AS IS" with no warranty of any kind,
15 * express or implied, and with no claim as to its suitability for any
16 * purpose.
17 *
18 */
19
20/// \ingroup graph_concepts
21/// \file
22/// \brief Undirected bipartite graphs and components of.
23
24
25#ifndef LEMON_CONCEPT_BPUGRAPH_H
26#define LEMON_CONCEPT_BPUGRAPH_H
27
28#include <lemon/concept/graph_component.h>
29
30#include <lemon/concept/graph.h>
31#include <lemon/concept/ugraph.h>
32
33#include <lemon/utility.h>
34
35namespace lemon {
36  namespace concept {
37
38    /// \addtogroup graph_concepts
39    /// @{
40
41
42    /// \brief Class describing the concept of Bipartite Undirected Graphs.
43    ///
44    /// This class describes the common interface of all
45    /// Undirected Bipartite Graphs.
46    ///
47    /// As all concept describing classes it provides only interface
48    /// without any sensible implementation. So any algorithm for
49    /// bipartite undirected graph should compile with this class, but it
50    /// will not run properly, of course.
51    ///
52    /// In LEMON bipartite undirected graphs also fulfill the concept of
53    /// the undirected graphs (\ref lemon::concept::UGraph "UGraph Concept").
54    ///
55    /// You can assume that all undirected bipartite graph can be handled
56    /// as an undirected graph and consequently as a static graph.
57    ///
58    /// The bipartite graph stores two types of nodes which are named
59    /// ANode and BNode. The graph type contains two types ANode and BNode
60    /// which are inherited from Node type. Moreover they have
61    /// constructor which converts Node to either ANode or BNode when it is
62    /// possible. Therefor everywhere the Node type can be used instead of
63    /// ANode and BNode. So the usage of the ANode and BNode is suggested. 
64    ///
65    /// The iteration on the partition can be done with the ANodeIt and
66    /// BNodeIt classes. The node map can be used to map values to the nodes
67    /// and similarly we can use to map values for just the ANodes and
68    /// BNodes the ANodeMap and BNodeMap template classes.
69
70    class BpUGraph {
71    public:
72      /// \todo undocumented
73      ///
74      typedef True UTag;
75
76      /// \brief The base type of node iterators,
77      /// or in other words, the trivial node iterator.
78      ///
79      /// This is the base type of each node iterator,
80      /// thus each kind of node iterator converts to this.
81      /// More precisely each kind of node iterator should be inherited
82      /// from the trivial node iterator. The Node class represents
83      /// both of two types of nodes.
84      class Node {
85      public:
86        /// Default constructor
87
88        /// @warning The default constructor sets the iterator
89        /// to an undefined value.
90        Node() { }
91        /// Copy constructor.
92
93        /// Copy constructor.
94        ///
95        Node(const Node&) { }
96
97        /// Invalid constructor \& conversion.
98
99        /// This constructor initializes the iterator to be invalid.
100        /// \sa Invalid for more details.
101        Node(Invalid) { }
102        /// Equality operator
103
104        /// Two iterators are equal if and only if they point to the
105        /// same object or both are invalid.
106        bool operator==(Node) const { return true; }
107
108        /// Inequality operator
109       
110        /// \sa operator==(Node n)
111        ///
112        bool operator!=(Node) const { return true; }
113
114        /// Artificial ordering operator.
115       
116        /// To allow the use of graph descriptors as key type in std::map or
117        /// similar associative container we require this.
118        ///
119        /// \note This operator only have to define some strict ordering of
120        /// the items; this order has nothing to do with the iteration
121        /// ordering of the items.
122        ///
123        /// \bug This is a technical requirement. Do we really need this?
124        bool operator<(Node) const { return false; }
125
126      };
127
128      /// \brief The base type of anode iterators,
129      /// or in other words, the trivial anode iterator.
130      ///
131      /// This is the base type of each anode iterator,
132      /// thus each kind of anode iterator converts to this.
133      /// More precisely each kind of node iterator should be inherited
134      /// from the trivial anode iterator. The ANode class should be used
135      /// only in special cases. Usually the Node type should be used insted
136      /// of it.
137      class ANode {
138      public:
139        /// Default constructor
140
141        /// @warning The default constructor sets the iterator
142        /// to an undefined value.
143        ANode() { }
144        /// Copy constructor.
145
146        /// Copy constructor.
147        ///
148        ANode(const ANode&) { }
149
150        /// Construct the same node as ANode.
151
152        /// Construct the same node as ANode. It may throws assertion
153        /// when the given node is from the BNode set.
154        ANode(const Node&) { }
155
156        /// Invalid constructor \& conversion.
157
158        /// This constructor initializes the iterator to be invalid.
159        /// \sa Invalid for more details.
160        ANode(Invalid) { }
161        /// Equality operator
162
163        /// Two iterators are equal if and only if they point to the
164        /// same object or both are invalid.
165        bool operator==(ANode) const { return true; }
166
167        /// Inequality operator
168       
169        /// \sa operator==(ANode n)
170        ///
171        bool operator!=(ANode) const { return true; }
172
173        /// Artificial ordering operator.
174       
175        /// To allow the use of graph descriptors as key type in std::map or
176        /// similar associative container we require this.
177        ///
178        /// \note This operator only have to define some strict ordering of
179        /// the items; this order has nothing to do with the iteration
180        /// ordering of the items.
181        bool operator<(ANode) const { return false; }
182
183      };
184
185      /// \brief The base type of bnode iterators,
186      /// or in other words, the trivial bnode iterator.
187      ///
188      /// This is the base type of each anode iterator,
189      /// thus each kind of anode iterator converts to this.
190      /// More precisely each kind of node iterator should be inherited
191      /// from the trivial anode iterator. The BNode class should be used
192      /// only in special cases. Usually the Node type should be used insted
193      /// of it.
194      class BNode {
195      public:
196        /// Default constructor
197
198        /// @warning The default constructor sets the iterator
199        /// to an undefined value.
200        BNode() { }
201        /// Copy constructor.
202
203        /// Copy constructor.
204        ///
205        BNode(const BNode&) { }
206
207        /// Construct the same node as BNode.
208
209        /// Construct the same node as BNode. It may throws assertion
210        /// when the given node is from the ANode set.
211        BNode(const Node&) { }
212
213        /// Invalid constructor \& conversion.
214
215        /// This constructor initializes the iterator to be invalid.
216        /// \sa Invalid for more details.
217        BNode(Invalid) { }
218        /// Equality operator
219
220        /// Two iterators are equal if and only if they point to the
221        /// same object or both are invalid.
222        bool operator==(BNode) const { return true; }
223
224        /// Inequality operator
225       
226        /// \sa operator==(BNode n)
227        ///
228        bool operator!=(BNode) const { return true; }
229
230        /// Artificial ordering operator.
231       
232        /// To allow the use of graph descriptors as key type in std::map or
233        /// similar associative container we require this.
234        ///
235        /// \note This operator only have to define some strict ordering of
236        /// the items; this order has nothing to do with the iteration
237        /// ordering of the items.
238        bool operator<(BNode) const { return false; }
239
240      };
241   
242      /// This iterator goes through each node.
243
244      /// This iterator goes through each node.
245      /// Its usage is quite simple, for example you can count the number
246      /// of nodes in graph \c g of type \c Graph like this:
247      /// \code
248      /// int count=0;
249      /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
250      /// \endcode
251      class NodeIt : public Node {
252      public:
253        /// Default constructor
254
255        /// @warning The default constructor sets the iterator
256        /// to an undefined value.
257        NodeIt() { }
258        /// Copy constructor.
259       
260        /// Copy constructor.
261        ///
262        NodeIt(const NodeIt& n) : Node(n) { }
263        /// Invalid constructor \& conversion.
264
265        /// Initialize the iterator to be invalid.
266        /// \sa Invalid for more details.
267        NodeIt(Invalid) { }
268        /// Sets the iterator to the first node.
269
270        /// Sets the iterator to the first node of \c g.
271        ///
272        NodeIt(const BpUGraph&) { }
273        /// Node -> NodeIt conversion.
274
275        /// Sets the iterator to the node of \c the graph pointed by
276        /// the trivial iterator.
277        /// This feature necessitates that each time we
278        /// iterate the edge-set, the iteration order is the same.
279        NodeIt(const BpUGraph&, const Node&) { }
280        /// Next node.
281
282        /// Assign the iterator to the next node.
283        ///
284        NodeIt& operator++() { return *this; }
285      };
286
287      /// This iterator goes through each ANode.
288
289      /// This iterator goes through each ANode.
290      /// Its usage is quite simple, for example you can count the number
291      /// of nodes in graph \c g of type \c Graph like this:
292      /// \code
293      /// int count=0;
294      /// for (Graph::ANodeIt n(g); n!=INVALID; ++n) ++count;
295      /// \endcode
296      class ANodeIt : public ANode {
297      public:
298        /// Default constructor
299
300        /// @warning The default constructor sets the iterator
301        /// to an undefined value.
302        ANodeIt() { }
303        /// Copy constructor.
304       
305        /// Copy constructor.
306        ///
307        ANodeIt(const ANodeIt& n) : Node(n) { }
308        /// Invalid constructor \& conversion.
309
310        /// Initialize the iterator to be invalid.
311        /// \sa Invalid for more details.
312        ANodeIt(Invalid) { }
313        /// Sets the iterator to the first node.
314
315        /// Sets the iterator to the first node of \c g.
316        ///
317        ANodeIt(const BpUGraph&) { }
318        /// Node -> ANodeIt conversion.
319
320        /// Sets the iterator to the node of \c the graph pointed by
321        /// the trivial iterator.
322        /// This feature necessitates that each time we
323        /// iterate the edge-set, the iteration order is the same.
324        ANodeIt(const BpUGraph&, const Node&) { }
325        /// Next node.
326
327        /// Assign the iterator to the next node.
328        ///
329        ANodeIt& operator++() { return *this; }
330      };
331
332      /// This iterator goes through each BNode.
333
334      /// This iterator goes through each BNode.
335      /// Its usage is quite simple, for example you can count the number
336      /// of nodes in graph \c g of type \c Graph like this:
337      /// \code
338      /// int count=0;
339      /// for (Graph::BNodeIt n(g); n!=INVALID; ++n) ++count;
340      /// \endcode
341      class BNodeIt : public BNode {
342      public:
343        /// Default constructor
344
345        /// @warning The default constructor sets the iterator
346        /// to an undefined value.
347        BNodeIt() { }
348        /// Copy constructor.
349       
350        /// Copy constructor.
351        ///
352        BNodeIt(const BNodeIt& n) : Node(n) { }
353        /// Invalid constructor \& conversion.
354
355        /// Initialize the iterator to be invalid.
356        /// \sa Invalid for more details.
357        BNodeIt(Invalid) { }
358        /// Sets the iterator to the first node.
359
360        /// Sets the iterator to the first node of \c g.
361        ///
362        BNodeIt(const BpUGraph&) { }
363        /// Node -> BNodeIt conversion.
364
365        /// Sets the iterator to the node of \c the graph pointed by
366        /// the trivial iterator.
367        /// This feature necessitates that each time we
368        /// iterate the edge-set, the iteration order is the same.
369        BNodeIt(const BpUGraph&, const Node&) { }
370        /// Next node.
371
372        /// Assign the iterator to the next node.
373        ///
374        BNodeIt& operator++() { return *this; }
375      };
376   
377   
378      /// The base type of the undirected edge iterators.
379
380      /// The base type of the undirected edge iterators.
381      ///
382      class UEdge {
383      public:
384        /// Default constructor
385
386        /// @warning The default constructor sets the iterator
387        /// to an undefined value.
388        UEdge() { }
389        /// Copy constructor.
390
391        /// Copy constructor.
392        ///
393        UEdge(const UEdge&) { }
394        /// Initialize the iterator to be invalid.
395
396        /// Initialize the iterator to be invalid.
397        ///
398        UEdge(Invalid) { }
399        /// Equality operator
400
401        /// Two iterators are equal if and only if they point to the
402        /// same object or both are invalid.
403        bool operator==(UEdge) const { return true; }
404        /// Inequality operator
405
406        /// \sa operator==(UEdge n)
407        ///
408        bool operator!=(UEdge) const { return true; }
409
410        /// Artificial ordering operator.
411       
412        /// To allow the use of graph descriptors as key type in std::map or
413        /// similar associative container we require this.
414        ///
415        /// \note This operator only have to define some strict ordering of
416        /// the items; this order has nothing to do with the iteration
417        /// ordering of the items.
418        ///
419        /// \bug This is a technical requirement. Do we really need this?
420        bool operator<(UEdge) const { return false; }
421      };
422
423      /// This iterator goes through each undirected edge.
424
425      /// This iterator goes through each undirected edge of a graph.
426      /// Its usage is quite simple, for example you can count the number
427      /// of undirected edges in a graph \c g of type \c Graph as follows:
428      /// \code
429      /// int count=0;
430      /// for(Graph::UEdgeIt e(g); e!=INVALID; ++e) ++count;
431      /// \endcode
432      class UEdgeIt : public UEdge {
433      public:
434        /// Default constructor
435
436        /// @warning The default constructor sets the iterator
437        /// to an undefined value.
438        UEdgeIt() { }
439        /// Copy constructor.
440
441        /// Copy constructor.
442        ///
443        UEdgeIt(const UEdgeIt& e) : UEdge(e) { }
444        /// Initialize the iterator to be invalid.
445
446        /// Initialize the iterator to be invalid.
447        ///
448        UEdgeIt(Invalid) { }
449        /// This constructor sets the iterator to the first undirected edge.
450   
451        /// This constructor sets the iterator to the first undirected edge.
452        UEdgeIt(const BpUGraph&) { }
453        /// UEdge -> UEdgeIt conversion
454
455        /// Sets the iterator to the value of the trivial iterator.
456        /// This feature necessitates that each time we
457        /// iterate the undirected edge-set, the iteration order is the
458        /// same.
459        UEdgeIt(const BpUGraph&, const UEdge&) { }
460        /// Next undirected edge
461       
462        /// Assign the iterator to the next undirected edge.
463        UEdgeIt& operator++() { return *this; }
464      };
465
466      /// \brief This iterator goes trough the incident undirected
467      /// edges of a node.
468      ///
469      /// This iterator goes trough the incident undirected edges
470      /// of a certain node
471      /// of a graph.
472      /// Its usage is quite simple, for example you can compute the
473      /// degree (i.e. count the number
474      /// of incident edges of a node \c n
475      /// in graph \c g of type \c Graph as follows.
476      /// \code
477      /// int count=0;
478      /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
479      /// \endcode
480      class IncEdgeIt : public UEdge {
481      public:
482        /// Default constructor
483
484        /// @warning The default constructor sets the iterator
485        /// to an undefined value.
486        IncEdgeIt() { }
487        /// Copy constructor.
488
489        /// Copy constructor.
490        ///
491        IncEdgeIt(const IncEdgeIt& e) : UEdge(e) { }
492        /// Initialize the iterator to be invalid.
493
494        /// Initialize the iterator to be invalid.
495        ///
496        IncEdgeIt(Invalid) { }
497        /// This constructor sets the iterator to first incident edge.
498   
499        /// This constructor set the iterator to the first incident edge of
500        /// the node.
501        IncEdgeIt(const BpUGraph&, const Node&) { }
502        /// UEdge -> IncEdgeIt conversion
503
504        /// Sets the iterator to the value of the trivial iterator \c e.
505        /// This feature necessitates that each time we
506        /// iterate the edge-set, the iteration order is the same.
507        IncEdgeIt(const BpUGraph&, const UEdge&) { }
508        /// Next incident edge
509
510        /// Assign the iterator to the next incident edge
511        /// of the corresponding node.
512        IncEdgeIt& operator++() { return *this; }
513      };
514
515      /// The directed edge type.
516
517      /// The directed edge type. It can be converted to the
518      /// undirected edge.
519      class Edge : public UEdge {
520      public:
521        /// Default constructor
522
523        /// @warning The default constructor sets the iterator
524        /// to an undefined value.
525        Edge() { }
526        /// Copy constructor.
527
528        /// Copy constructor.
529        ///
530        Edge(const Edge& e) : UEdge(e) { }
531        /// Initialize the iterator to be invalid.
532
533        /// Initialize the iterator to be invalid.
534        ///
535        Edge(Invalid) { }
536        /// Equality operator
537
538        /// Two iterators are equal if and only if they point to the
539        /// same object or both are invalid.
540        bool operator==(Edge) const { return true; }
541        /// Inequality operator
542
543        /// \sa operator==(Edge n)
544        ///
545        bool operator!=(Edge) const { return true; }
546
547        /// Artificial ordering operator.
548       
549        /// To allow the use of graph descriptors as key type in std::map or
550        /// similar associative container we require this.
551        ///
552        /// \note This operator only have to define some strict ordering of
553        /// the items; this order has nothing to do with the iteration
554        /// ordering of the items.
555        ///
556        /// \bug This is a technical requirement. Do we really need this?
557        bool operator<(Edge) const { return false; }
558       
559      };
560      /// This iterator goes through each directed edge.
561
562      /// This iterator goes through each edge of a graph.
563      /// Its usage is quite simple, for example you can count the number
564      /// of edges in a graph \c g of type \c Graph as follows:
565      /// \code
566      /// int count=0;
567      /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
568      /// \endcode
569      class EdgeIt : public Edge {
570      public:
571        /// Default constructor
572
573        /// @warning The default constructor sets the iterator
574        /// to an undefined value.
575        EdgeIt() { }
576        /// Copy constructor.
577
578        /// Copy constructor.
579        ///
580        EdgeIt(const EdgeIt& e) : Edge(e) { }
581        /// Initialize the iterator to be invalid.
582
583        /// Initialize the iterator to be invalid.
584        ///
585        EdgeIt(Invalid) { }
586        /// This constructor sets the iterator to the first edge.
587   
588        /// This constructor sets the iterator to the first edge of \c g.
589        ///@param g the graph
590        EdgeIt(const BpUGraph &g) { ignore_unused_variable_warning(g); }
591        /// Edge -> EdgeIt conversion
592
593        /// Sets the iterator to the value of the trivial iterator \c e.
594        /// This feature necessitates that each time we
595        /// iterate the edge-set, the iteration order is the same.
596        EdgeIt(const BpUGraph&, const Edge&) { }
597        ///Next edge
598       
599        /// Assign the iterator to the next edge.
600        EdgeIt& operator++() { return *this; }
601      };
602   
603      /// This iterator goes trough the outgoing directed edges of a node.
604
605      /// This iterator goes trough the \e outgoing edges of a certain node
606      /// of a graph.
607      /// Its usage is quite simple, for example you can count the number
608      /// of outgoing edges of a node \c n
609      /// in graph \c g of type \c Graph as follows.
610      /// \code
611      /// int count=0;
612      /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
613      /// \endcode
614   
615      class OutEdgeIt : public Edge {
616      public:
617        /// Default constructor
618
619        /// @warning The default constructor sets the iterator
620        /// to an undefined value.
621        OutEdgeIt() { }
622        /// Copy constructor.
623
624        /// Copy constructor.
625        ///
626        OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
627        /// Initialize the iterator to be invalid.
628
629        /// Initialize the iterator to be invalid.
630        ///
631        OutEdgeIt(Invalid) { }
632        /// This constructor sets the iterator to the first outgoing edge.
633   
634        /// This constructor sets the iterator to the first outgoing edge of
635        /// the node.
636        ///@param n the node
637        ///@param g the graph
638        OutEdgeIt(const BpUGraph& n, const Node& g) {
639          ignore_unused_variable_warning(n);
640          ignore_unused_variable_warning(g);
641        }
642        /// Edge -> OutEdgeIt conversion
643
644        /// Sets the iterator to the value of the trivial iterator.
645        /// This feature necessitates that each time we
646        /// iterate the edge-set, the iteration order is the same.
647        OutEdgeIt(const BpUGraph&, const Edge&) { }
648        ///Next outgoing edge
649       
650        /// Assign the iterator to the next
651        /// outgoing edge of the corresponding node.
652        OutEdgeIt& operator++() { return *this; }
653      };
654
655      /// This iterator goes trough the incoming directed edges of a node.
656
657      /// This iterator goes trough the \e incoming edges of a certain node
658      /// of a graph.
659      /// Its usage is quite simple, for example you can count the number
660      /// of outgoing edges of a node \c n
661      /// in graph \c g of type \c Graph as follows.
662      /// \code
663      /// int count=0;
664      /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
665      /// \endcode
666
667      class InEdgeIt : public Edge {
668      public:
669        /// Default constructor
670
671        /// @warning The default constructor sets the iterator
672        /// to an undefined value.
673        InEdgeIt() { }
674        /// Copy constructor.
675
676        /// Copy constructor.
677        ///
678        InEdgeIt(const InEdgeIt& e) : Edge(e) { }
679        /// Initialize the iterator to be invalid.
680
681        /// Initialize the iterator to be invalid.
682        ///
683        InEdgeIt(Invalid) { }
684        /// This constructor sets the iterator to first incoming edge.
685   
686        /// This constructor set the iterator to the first incoming edge of
687        /// the node.
688        ///@param n the node
689        ///@param g the graph
690        InEdgeIt(const BpUGraph& g, const Node& n) {
691          ignore_unused_variable_warning(n);
692          ignore_unused_variable_warning(g);
693        }
694        /// Edge -> InEdgeIt conversion
695
696        /// Sets the iterator to the value of the trivial iterator \c e.
697        /// This feature necessitates that each time we
698        /// iterate the edge-set, the iteration order is the same.
699        InEdgeIt(const BpUGraph&, const Edge&) { }
700        /// Next incoming edge
701
702        /// Assign the iterator to the next inedge of the corresponding node.
703        ///
704        InEdgeIt& operator++() { return *this; }
705      };
706
707      /// \brief Read write map of the nodes to type \c T.
708      ///
709      /// ReadWrite map of the nodes to type \c T.
710      /// \sa Reference
711      /// \warning Making maps that can handle bool type (NodeMap<bool>)
712      /// needs some extra attention!
713      /// \todo Wrong documentation
714      template<class T>
715      class NodeMap : public ReadWriteMap< Node, T >
716      {
717      public:
718
719        ///\e
720        NodeMap(const BpUGraph&) { }
721        ///\e
722        NodeMap(const BpUGraph&, T) { }
723
724        ///Copy constructor
725        NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
726        ///Assignment operator
727        NodeMap& operator=(const NodeMap&) { return *this; }
728        // \todo fix this concept
729      };
730
731      /// \brief Read write map of the ANodes to type \c T.
732      ///
733      /// ReadWrite map of the ANodes to type \c T.
734      /// \sa Reference
735      /// \warning Making maps that can handle bool type (NodeMap<bool>)
736      /// needs some extra attention!
737      /// \todo Wrong documentation
738      template<class T>
739      class ANodeMap : public ReadWriteMap< Node, T >
740      {
741      public:
742
743        ///\e
744        ANodeMap(const BpUGraph&) { }
745        ///\e
746        ANodeMap(const BpUGraph&, T) { }
747
748        ///Copy constructor
749        ANodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
750        ///Assignment operator
751        ANodeMap& operator=(const NodeMap&) { return *this; }
752        // \todo fix this concept
753      };
754
755      /// \brief Read write map of the BNodes to type \c T.
756      ///
757      /// ReadWrite map of the BNodes to type \c T.
758      /// \sa Reference
759      /// \warning Making maps that can handle bool type (NodeMap<bool>)
760      /// needs some extra attention!
761      /// \todo Wrong documentation
762      template<class T>
763      class BNodeMap : public ReadWriteMap< Node, T >
764      {
765      public:
766
767        ///\e
768        BNodeMap(const BpUGraph&) { }
769        ///\e
770        BNodeMap(const BpUGraph&, T) { }
771
772        ///Copy constructor
773        BNodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
774        ///Assignment operator
775        BNodeMap& operator=(const NodeMap&) { return *this; }
776        // \todo fix this concept
777      };
778
779      /// \brief Read write map of the directed edges to type \c T.
780      ///
781      /// Reference map of the directed edges to type \c T.
782      /// \sa Reference
783      /// \warning Making maps that can handle bool type (EdgeMap<bool>)
784      /// needs some extra attention!
785      /// \todo Wrong documentation
786      template<class T>
787      class EdgeMap : public ReadWriteMap<Edge,T>
788      {
789      public:
790
791        ///\e
792        EdgeMap(const BpUGraph&) { }
793        ///\e
794        EdgeMap(const BpUGraph&, T) { }
795        ///Copy constructor
796        EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
797        ///Assignment operator
798        EdgeMap& operator=(const EdgeMap&) { return *this; }
799        // \todo fix this concept   
800      };
801
802      /// Read write map of the undirected edges to type \c T.
803
804      /// Reference map of the edges to type \c T.
805      /// \sa Reference
806      /// \warning Making maps that can handle bool type (UEdgeMap<bool>)
807      /// needs some extra attention!
808      /// \todo Wrong documentation
809      template<class T>
810      class UEdgeMap : public ReadWriteMap<UEdge,T>
811      {
812      public:
813
814        ///\e
815        UEdgeMap(const BpUGraph&) { }
816        ///\e
817        UEdgeMap(const BpUGraph&, T) { }
818        ///Copy constructor
819        UEdgeMap(const UEdgeMap& em) : ReadWriteMap<UEdge,T>(em) {}
820        ///Assignment operator
821        UEdgeMap &operator=(const UEdgeMap&) { return *this; }
822        // \todo fix this concept   
823      };
824
825      /// \brief Direct the given undirected edge.
826      ///
827      /// Direct the given undirected edge. The returned edge source
828      /// will be the given edge.
829      Edge direct(const UEdge&, const Node&) const {
830        return INVALID;
831      }
832
833      /// \brief Direct the given undirected edge.
834      ///
835      /// Direct the given undirected edge. The returned edge source
836      /// will be the source of the undirected edge if the given bool
837      /// is true.
838      Edge direct(const UEdge&, bool) const {
839        return INVALID;
840      }
841
842      /// \brief Returns true when the given node is an ANode.
843      ///
844      /// Returns true when the given node is an ANode.
845      bool aNode(Node) const { return true;}
846
847      /// \brief Returns true when the given node is an BNode.
848      ///
849      /// Returns true when the given node is an BNode.
850      bool bNode(Node) const { return true;}
851
852      /// \brief Returns the edge's end node which is in the ANode set.
853      ///
854      /// Returns the edge's end node which is in the ANode set.
855      Node aNode(UEdge) const { return INVALID;}
856
857      /// \brief Returns the edge's end node which is in the BNode set.
858      ///
859      /// Returns the edge's end node which is in the BNode set.
860      Node bNode(UEdge) const { return INVALID;}
861
862      /// \brief Returns true if the edge has default orientation.
863      ///
864      /// Returns whether the given directed edge is same orientation as
865      /// the corresponding undirected edge.
866      bool direction(Edge) const { return true; }
867
868      /// \brief Returns the opposite directed edge.
869      ///
870      /// Returns the opposite directed edge.
871      Edge oppositeEdge(Edge) const { return INVALID; }
872
873      /// \brief Opposite node on an edge
874      ///
875      /// \return the opposite of the given Node on the given Edge
876      Node oppositeNode(Node, UEdge) const { return INVALID; }
877
878      /// \brief First node of the undirected edge.
879      ///
880      /// \return the first node of the given UEdge.
881      ///
882      /// Naturally uectected edges don't have direction and thus
883      /// don't have source and target node. But we use these two methods
884      /// to query the two endnodes of the edge. The direction of the edge
885      /// which arises this way is called the inherent direction of the
886      /// undirected edge, and is used to define the "default" direction
887      /// of the directed versions of the edges.
888      /// \sa direction
889      Node source(UEdge) const { return INVALID; }
890
891      /// \brief Second node of the undirected edge.
892      Node target(UEdge) const { return INVALID; }
893
894      /// \brief Source node of the directed edge.
895      Node source(Edge) const { return INVALID; }
896
897      /// \brief Target node of the directed edge.
898      Node target(Edge) const { return INVALID; }
899
900      /// \brief Base node of the iterator
901      ///
902      /// Returns the base node (the source in this case) of the iterator
903      Node baseNode(OutEdgeIt e) const {
904        return source(e);
905      }
906
907      /// \brief Running node of the iterator
908      ///
909      /// Returns the running node (the target in this case) of the
910      /// iterator
911      Node runningNode(OutEdgeIt e) const {
912        return target(e);
913      }
914
915      /// \brief Base node of the iterator
916      ///
917      /// Returns the base node (the target in this case) of the iterator
918      Node baseNode(InEdgeIt e) const {
919        return target(e);
920      }
921      /// \brief Running node of the iterator
922      ///
923      /// Returns the running node (the source in this case) of the
924      /// iterator
925      Node runningNode(InEdgeIt e) const {
926        return source(e);
927      }
928
929      /// \brief Base node of the iterator
930      ///
931      /// Returns the base node of the iterator
932      Node baseNode(IncEdgeIt) const {
933        return INVALID;
934      }
935     
936      /// \brief Running node of the iterator
937      ///
938      /// Returns the running node of the iterator
939      Node runningNode(IncEdgeIt) const {
940        return INVALID;
941      }
942
943      template <typename Graph>
944      struct Constraints {
945        void constraints() {
946        }
947      };
948
949    };
950
951    /// \brief An empty non-static undirected graph class.
952    ///   
953    /// This class provides everything that \ref BpUGraph does.
954    /// Additionally it enables building graphs from scratch.
955    class ExtendableBpUGraph : public BpUGraph {
956    public:
957     
958      /// \brief Add a new ANode to the graph.
959      ///
960      /// Add a new ANode to the graph.
961      /// \return the new node.
962      Node addANode();
963
964      /// \brief Add a new ANode to the graph.
965      ///
966      /// Add a new ANode to the graph.
967      /// \return the new node.
968      Node addBNode();
969
970      /// \brief Add a new undirected edge to the graph.
971      ///
972      /// Add a new undirected edge to the graph. One of the nodes
973      /// should be ANode and the other should be BNode.
974      /// \pre The nodes are not in the same nodeset.
975      /// \return the new edge.
976      UEdge addEdge(const Node& from, const Node& to);
977
978      /// \brief Resets the graph.
979      ///
980      /// This function deletes all undirected edges and nodes of the graph.
981      /// It also frees the memory allocated to store them.
982      void clear() { }
983
984      template <typename Graph>
985      struct Constraints {
986        void constraints() {}
987      };
988
989    };
990
991    /// \brief An empty erasable undirected graph class.
992    ///
993    /// This class is an extension of \ref ExtendableBpUGraph. It makes it
994    /// possible to erase undirected edges or nodes.
995    class ErasableBpUGraph : public ExtendableBpUGraph {
996    public:
997
998      /// \brief Deletes a node.
999      ///
1000      /// Deletes a node.
1001      ///
1002      void erase(Node) { }
1003      /// \brief Deletes an undirected edge.
1004      ///
1005      /// Deletes an undirected edge.
1006      ///
1007      void erase(UEdge) { }
1008
1009      template <typename Graph>
1010      struct Constraints {
1011        void constraints() {}
1012      };
1013
1014    };
1015
1016    /// @}
1017
1018  }
1019
1020}
1021
1022#endif
Note: See TracBrowser for help on using the repository browser.