1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2013
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 ///\ingroup graph_concepts
21 ///\brief The concept of undirected graphs.
23 #ifndef LEMON_CONCEPTS_BPGRAPH_H
24 #define LEMON_CONCEPTS_BPGRAPH_H
26 #include <lemon/concepts/graph_components.h>
27 #include <lemon/concepts/maps.h>
28 #include <lemon/concept_check.h>
29 #include <lemon/core.h>
30 #include <lemon/bits/stl_iterators.h>
35 /// \ingroup graph_concepts
37 /// \brief Class describing the concept of undirected bipartite graphs.
39 /// This class describes the common interface of all undirected
42 /// Like all concept classes, it only provides an interface
43 /// without any sensible implementation. So any general algorithm for
44 /// undirected bipartite graphs should compile with this class,
45 /// but it will not run properly, of course.
46 /// An actual graph implementation like \ref ListBpGraph or
47 /// \ref SmartBpGraph may have additional functionality.
49 /// The bipartite graphs also fulfill the concept of \ref Graph
50 /// "undirected graphs". Bipartite graphs provide a bipartition of
51 /// the node set, namely a red and blue set of the nodes. The
52 /// nodes can be iterated with the RedNodeIt and BlueNodeIt in the
53 /// two node sets. With RedNodeMap and BlueNodeMap values can be
54 /// assigned to the nodes in the two sets.
56 /// The edges of the graph cannot connect two nodes of the same
57 /// set. The edges inherent orientation is from the red nodes to
63 /// BpGraphs are \e not copy constructible. Use bpGraphCopy instead.
64 BpGraph(const BpGraph&) {}
65 /// \brief Assignment of a graph to another one is \e not allowed.
66 /// Use bpGraphCopy instead.
67 void operator=(const BpGraph&) {}
70 /// Default constructor.
73 /// \brief Undirected graphs should be tagged with \c UndirectedTag.
75 /// Undirected graphs should be tagged with \c UndirectedTag.
77 /// This tag helps the \c enable_if technics to make compile time
78 /// specializations for undirected graphs.
79 typedef True UndirectedTag;
81 /// The node type of the graph
83 /// This class identifies a node of the graph. It also serves
84 /// as a base class of the node iterators,
85 /// thus they convert to this type.
88 /// Default constructor
90 /// Default constructor.
91 /// \warning It sets the object to an undefined value.
99 /// %Invalid constructor \& conversion.
101 /// Initializes the object to be invalid.
102 /// \sa Invalid for more details.
104 /// Equality operator
106 /// Equality operator.
108 /// Two iterators are equal if and only if they point to the
109 /// same object or both are \c INVALID.
110 bool operator==(Node) const { return true; }
112 /// Inequality operator
114 /// Inequality operator.
115 bool operator!=(Node) const { return true; }
117 /// Artificial ordering operator.
119 /// Artificial ordering operator.
121 /// \note This operator only has to define some strict ordering of
122 /// the items; this order has nothing to do with the iteration
123 /// ordering of the items.
124 bool operator<(Node) const { return false; }
128 /// Class to represent red nodes.
130 /// This class represents the red nodes of the graph. It does
131 /// not supposed to be used directly, because the nodes can be
132 /// represented as Node instances. This class can be used as
133 /// template parameter for special map classes.
134 class RedNode : public Node {
136 /// Default constructor
138 /// Default constructor.
139 /// \warning It sets the object to an undefined value.
141 /// Copy constructor.
143 /// Copy constructor.
145 RedNode(const RedNode&) : Node() { }
147 /// %Invalid constructor \& conversion.
149 /// Initializes the object to be invalid.
150 /// \sa Invalid for more details.
155 /// Class to represent blue nodes.
157 /// This class represents the blue nodes of the graph. It does
158 /// not supposed to be used directly, because the nodes can be
159 /// represented as Node instances. This class can be used as
160 /// template parameter for special map classes.
161 class BlueNode : public Node {
163 /// Default constructor
165 /// Default constructor.
166 /// \warning It sets the object to an undefined value.
168 /// Copy constructor.
170 /// Copy constructor.
172 BlueNode(const BlueNode&) : Node() { }
174 /// %Invalid constructor \& conversion.
176 /// Initializes the object to be invalid.
177 /// \sa Invalid for more details.
178 BlueNode(Invalid) { }
182 /// Iterator class for the red nodes.
184 /// This iterator goes through each red node of the graph.
185 /// Its usage is quite simple, for example, you can count the number
186 /// of red nodes in a graph \c g of type \c %BpGraph like this:
189 /// for (BpGraph::RedNodeIt n(g); n!=INVALID; ++n) ++count;
191 class RedNodeIt : public RedNode {
193 /// Default constructor
195 /// Default constructor.
196 /// \warning It sets the iterator to an undefined value.
198 /// Copy constructor.
200 /// Copy constructor.
202 RedNodeIt(const RedNodeIt& n) : RedNode(n) { }
203 /// %Invalid constructor \& conversion.
205 /// Initializes the iterator to be invalid.
206 /// \sa Invalid for more details.
207 RedNodeIt(Invalid) { }
208 /// Sets the iterator to the first red node.
210 /// Sets the iterator to the first red node of the given
212 explicit RedNodeIt(const BpGraph&) { }
213 /// Sets the iterator to the given red node.
215 /// Sets the iterator to the given red node of the given
217 RedNodeIt(const BpGraph&, const RedNode&) { }
220 /// Assign the iterator to the next red node.
222 RedNodeIt& operator++() { return *this; }
225 /// \brief Gets the collection of the red nodes of the graph.
227 /// This function can be used for iterating on
228 /// the red nodes of the graph. It returns a wrapped RedNodeIt,
229 /// which looks like an STL container (by having begin() and end())
230 /// which you can use in range-based for loops, stl algorithms, etc.
231 /// For example if g is a BpGraph, you can write:
233 /// for(auto v: g.redNodes())
236 LemonRangeWrapper1<RedNodeIt, BpGraph> redNodes() const {
237 return LemonRangeWrapper1<RedNodeIt, BpGraph>(*this);
241 /// Iterator class for the blue nodes.
243 /// This iterator goes through each blue node of the graph.
244 /// Its usage is quite simple, for example, you can count the number
245 /// of blue nodes in a graph \c g of type \c %BpGraph like this:
248 /// for (BpGraph::BlueNodeIt n(g); n!=INVALID; ++n) ++count;
250 class BlueNodeIt : public BlueNode {
252 /// Default constructor
254 /// Default constructor.
255 /// \warning It sets the iterator to an undefined value.
257 /// Copy constructor.
259 /// Copy constructor.
261 BlueNodeIt(const BlueNodeIt& n) : BlueNode(n) { }
262 /// %Invalid constructor \& conversion.
264 /// Initializes the iterator to be invalid.
265 /// \sa Invalid for more details.
266 BlueNodeIt(Invalid) { }
267 /// Sets the iterator to the first blue node.
269 /// Sets the iterator to the first blue node of the given
271 explicit BlueNodeIt(const BpGraph&) { }
272 /// Sets the iterator to the given blue node.
274 /// Sets the iterator to the given blue node of the given
276 BlueNodeIt(const BpGraph&, const BlueNode&) { }
279 /// Assign the iterator to the next blue node.
281 BlueNodeIt& operator++() { return *this; }
284 /// \brief Gets the collection of the blue nodes of the graph.
286 /// This function can be used for iterating on
287 /// the blue nodes of the graph. It returns a wrapped BlueNodeIt,
288 /// which looks like an STL container (by having begin() and end())
289 /// which you can use in range-based for loops, stl algorithms, etc.
290 /// For example if g is a BpGraph, you can write:
292 /// for(auto v: g.blueNodes())
295 LemonRangeWrapper1<BlueNodeIt, BpGraph> blueNodes() const {
296 return LemonRangeWrapper1<BlueNodeIt, BpGraph>(*this);
300 /// Iterator class for the nodes.
302 /// This iterator goes through each node of the graph.
303 /// Its usage is quite simple, for example, you can count the number
304 /// of nodes in a graph \c g of type \c %BpGraph like this:
307 /// for (BpGraph::NodeIt n(g); n!=INVALID; ++n) ++count;
309 class NodeIt : public Node {
311 /// Default constructor
313 /// Default constructor.
314 /// \warning It sets the iterator to an undefined value.
316 /// Copy constructor.
318 /// Copy constructor.
320 NodeIt(const NodeIt& n) : Node(n) { }
321 /// %Invalid constructor \& conversion.
323 /// Initializes the iterator to be invalid.
324 /// \sa Invalid for more details.
326 /// Sets the iterator to the first node.
328 /// Sets the iterator to the first node of the given digraph.
330 explicit NodeIt(const BpGraph&) { }
331 /// Sets the iterator to the given node.
333 /// Sets the iterator to the given node of the given digraph.
335 NodeIt(const BpGraph&, const Node&) { }
338 /// Assign the iterator to the next node.
340 NodeIt& operator++() { return *this; }
343 /// \brief Gets the collection of the nodes of the graph.
345 /// This function can be used for iterating on
346 /// the nodes of the graph. It returns a wrapped NodeIt,
347 /// which looks like an STL container (by having begin() and end())
348 /// which you can use in range-based for loops, stl algorithms, etc.
349 /// For example if g is a BpGraph, you can write:
351 /// for(auto v: g.nodes())
354 LemonRangeWrapper1<NodeIt, BpGraph> nodes() const {
355 return LemonRangeWrapper1<NodeIt, BpGraph>(*this);
360 /// The edge type of the graph
362 /// This class identifies an edge of the graph. It also serves
363 /// as a base class of the edge iterators,
364 /// thus they will convert to this type.
367 /// Default constructor
369 /// Default constructor.
370 /// \warning It sets the object to an undefined value.
372 /// Copy constructor.
374 /// Copy constructor.
376 Edge(const Edge&) { }
377 /// %Invalid constructor \& conversion.
379 /// Initializes the object to be invalid.
380 /// \sa Invalid for more details.
382 /// Equality operator
384 /// Equality operator.
386 /// Two iterators are equal if and only if they point to the
387 /// same object or both are \c INVALID.
388 bool operator==(Edge) const { return true; }
389 /// Inequality operator
391 /// Inequality operator.
392 bool operator!=(Edge) const { return true; }
394 /// Artificial ordering operator.
396 /// Artificial ordering operator.
398 /// \note This operator only has to define some strict ordering of
399 /// the edges; this order has nothing to do with the iteration
400 /// ordering of the edges.
401 bool operator<(Edge) const { return false; }
404 /// Iterator class for the edges.
406 /// This iterator goes through each edge of the graph.
407 /// Its usage is quite simple, for example, you can count the number
408 /// of edges in a graph \c g of type \c %BpGraph as follows:
411 /// for(BpGraph::EdgeIt e(g); e!=INVALID; ++e) ++count;
413 class EdgeIt : public Edge {
415 /// Default constructor
417 /// Default constructor.
418 /// \warning It sets the iterator to an undefined value.
420 /// Copy constructor.
422 /// Copy constructor.
424 EdgeIt(const EdgeIt& e) : Edge(e) { }
425 /// %Invalid constructor \& conversion.
427 /// Initializes the iterator to be invalid.
428 /// \sa Invalid for more details.
430 /// Sets the iterator to the first edge.
432 /// Sets the iterator to the first edge of the given graph.
434 explicit EdgeIt(const BpGraph&) { }
435 /// Sets the iterator to the given edge.
437 /// Sets the iterator to the given edge of the given graph.
439 EdgeIt(const BpGraph&, const Edge&) { }
442 /// Assign the iterator to the next edge.
444 EdgeIt& operator++() { return *this; }
447 /// \brief Gets the collection of the edges of the graph.
449 /// This function can be used for iterating on the
450 /// edges of the graph. It returns a wrapped
451 /// EdgeIt, which looks like an STL container
452 /// (by having begin() and end()) which you can use in range-based
453 /// for loops, stl algorithms, etc.
454 /// For example if g is a BpGraph, you can write:
456 /// for(auto e: g.edges())
459 LemonRangeWrapper1<EdgeIt, BpGraph> edges() const {
460 return LemonRangeWrapper1<EdgeIt, BpGraph>(*this);
464 /// Iterator class for the incident edges of a node.
466 /// This iterator goes trough the incident undirected edges
467 /// of a certain node of a graph.
468 /// Its usage is quite simple, for example, you can compute the
469 /// degree (i.e. the number of incident edges) of a node \c n
470 /// in a graph \c g of type \c %BpGraph as follows.
474 /// for(BpGraph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
477 /// \warning Loop edges will be iterated twice.
478 class IncEdgeIt : public Edge {
480 /// Default constructor
482 /// Default constructor.
483 /// \warning It sets the iterator to an undefined value.
485 /// Copy constructor.
487 /// Copy constructor.
489 IncEdgeIt(const IncEdgeIt& e) : Edge(e) { }
490 /// %Invalid constructor \& conversion.
492 /// Initializes the iterator to be invalid.
493 /// \sa Invalid for more details.
494 IncEdgeIt(Invalid) { }
495 /// Sets the iterator to the first incident edge.
497 /// Sets the iterator to the first incident edge of the given node.
499 IncEdgeIt(const BpGraph&, const Node&) { }
500 /// Sets the iterator to the given edge.
502 /// Sets the iterator to the given edge of the given graph.
504 IncEdgeIt(const BpGraph&, const Edge&) { }
505 /// Next incident edge
507 /// Assign the iterator to the next incident edge
508 /// of the corresponding node.
509 IncEdgeIt& operator++() { return *this; }
512 /// \brief Gets the collection of the incident edges
513 /// of a certain node of the graph.
515 /// This function can be used for iterating on the
516 /// incident undirected edges of a certain node of the graph.
517 /// It returns a wrapped
518 /// IncEdgeIt, which looks like an STL container
519 /// (by having begin() and end()) which you can use in range-based
520 /// for loops, stl algorithms, etc.
521 /// For example if g is a BpGraph and u is a Node, you can write:
523 /// for(auto e: g.incEdges(u))
526 LemonRangeWrapper2<IncEdgeIt, BpGraph, Node> incEdges(const Node& u) const {
527 return LemonRangeWrapper2<IncEdgeIt, BpGraph, Node>(*this, u);
531 /// The arc type of the graph
533 /// This class identifies a directed arc of the graph. It also serves
534 /// as a base class of the arc iterators,
535 /// thus they will convert to this type.
538 /// Default constructor
540 /// Default constructor.
541 /// \warning It sets the object to an undefined value.
543 /// Copy constructor.
545 /// Copy constructor.
548 /// %Invalid constructor \& conversion.
550 /// Initializes the object to be invalid.
551 /// \sa Invalid for more details.
553 /// Equality operator
555 /// Equality operator.
557 /// Two iterators are equal if and only if they point to the
558 /// same object or both are \c INVALID.
559 bool operator==(Arc) const { return true; }
560 /// Inequality operator
562 /// Inequality operator.
563 bool operator!=(Arc) const { return true; }
565 /// Artificial ordering operator.
567 /// Artificial ordering operator.
569 /// \note This operator only has to define some strict ordering of
570 /// the arcs; this order has nothing to do with the iteration
571 /// ordering of the arcs.
572 bool operator<(Arc) const { return false; }
574 /// Converison to \c Edge
576 /// Converison to \c Edge.
578 operator Edge() const { return Edge(); }
581 /// Iterator class for the arcs.
583 /// This iterator goes through each directed arc of the graph.
584 /// Its usage is quite simple, for example, you can count the number
585 /// of arcs in a graph \c g of type \c %BpGraph as follows:
588 /// for(BpGraph::ArcIt a(g); a!=INVALID; ++a) ++count;
590 class ArcIt : public Arc {
592 /// Default constructor
594 /// Default constructor.
595 /// \warning It sets the iterator to an undefined value.
597 /// Copy constructor.
599 /// Copy constructor.
601 ArcIt(const ArcIt& e) : Arc(e) { }
602 /// %Invalid constructor \& conversion.
604 /// Initializes the iterator to be invalid.
605 /// \sa Invalid for more details.
607 /// Sets the iterator to the first arc.
609 /// Sets the iterator to the first arc of the given graph.
611 explicit ArcIt(const BpGraph &g)
613 ::lemon::ignore_unused_variable_warning(g);
615 /// Sets the iterator to the given arc.
617 /// Sets the iterator to the given arc of the given graph.
619 ArcIt(const BpGraph&, const Arc&) { }
622 /// Assign the iterator to the next arc.
624 ArcIt& operator++() { return *this; }
627 /// \brief Gets the collection of the directed arcs of the graph.
629 /// This function can be used for iterating on the
630 /// arcs of the graph. It returns a wrapped
631 /// ArcIt, which looks like an STL container
632 /// (by having begin() and end()) which you can use in range-based
633 /// for loops, stl algorithms, etc.
634 /// For example if g is a BpGraph you can write:
636 /// for(auto a: g.arcs())
639 LemonRangeWrapper1<ArcIt, BpGraph> arcs() const {
640 return LemonRangeWrapper1<ArcIt, BpGraph>(*this);
644 /// Iterator class for the outgoing arcs of a node.
646 /// This iterator goes trough the \e outgoing directed arcs of a
647 /// certain node of a graph.
648 /// Its usage is quite simple, for example, you can count the number
649 /// of outgoing arcs of a node \c n
650 /// in a graph \c g of type \c %BpGraph as follows.
653 /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
655 class OutArcIt : public Arc {
657 /// Default constructor
659 /// Default constructor.
660 /// \warning It sets the iterator to an undefined value.
662 /// Copy constructor.
664 /// Copy constructor.
666 OutArcIt(const OutArcIt& e) : Arc(e) { }
667 /// %Invalid constructor \& conversion.
669 /// Initializes the iterator to be invalid.
670 /// \sa Invalid for more details.
671 OutArcIt(Invalid) { }
672 /// Sets the iterator to the first outgoing arc.
674 /// Sets the iterator to the first outgoing arc of the given node.
676 OutArcIt(const BpGraph& n, const Node& g) {
677 ::lemon::ignore_unused_variable_warning(n);
678 ::lemon::ignore_unused_variable_warning(g);
680 /// Sets the iterator to the given arc.
682 /// Sets the iterator to the given arc of the given graph.
684 OutArcIt(const BpGraph&, const Arc&) { }
685 /// Next outgoing arc
687 /// Assign the iterator to the next
688 /// outgoing arc of the corresponding node.
689 OutArcIt& operator++() { return *this; }
692 /// \brief Gets the collection of the outgoing directed arcs of a
693 /// certain node of the graph.
695 /// This function can be used for iterating on the
696 /// outgoing arcs of a certain node of the graph. It returns a wrapped
697 /// OutArcIt, which looks like an STL container
698 /// (by having begin() and end()) which you can use in range-based
699 /// for loops, stl algorithms, etc.
700 /// For example if g is a BpGraph and u is a Node, you can write:
702 /// for(auto a: g.outArcs(u))
705 LemonRangeWrapper2<OutArcIt, BpGraph, Node> outArcs(const Node& u) const {
706 return LemonRangeWrapper2<OutArcIt, BpGraph, Node>(*this, u);
710 /// Iterator class for the incoming arcs of a node.
712 /// This iterator goes trough the \e incoming directed arcs of a
713 /// certain node of a graph.
714 /// Its usage is quite simple, for example, you can count the number
715 /// of incoming arcs of a node \c n
716 /// in a graph \c g of type \c %BpGraph as follows.
719 /// for (Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
721 class InArcIt : public Arc {
723 /// Default constructor
725 /// Default constructor.
726 /// \warning It sets the iterator to an undefined value.
728 /// Copy constructor.
730 /// Copy constructor.
732 InArcIt(const InArcIt& e) : Arc(e) { }
733 /// %Invalid constructor \& conversion.
735 /// Initializes the iterator to be invalid.
736 /// \sa Invalid for more details.
738 /// Sets the iterator to the first incoming arc.
740 /// Sets the iterator to the first incoming arc of the given node.
742 InArcIt(const BpGraph& g, const Node& n) {
743 ::lemon::ignore_unused_variable_warning(n);
744 ::lemon::ignore_unused_variable_warning(g);
746 /// Sets the iterator to the given arc.
748 /// Sets the iterator to the given arc of the given graph.
750 InArcIt(const BpGraph&, const Arc&) { }
751 /// Next incoming arc
753 /// Assign the iterator to the next
754 /// incoming arc of the corresponding node.
755 InArcIt& operator++() { return *this; }
758 /// \brief Gets the collection of the incoming directed arcs of a
759 /// certain node of the graph.
761 /// This function can be used for iterating on the
762 /// incoming arcs of a certain node of the graph. It returns a wrapped
763 /// InArcIt, which looks like an STL container
764 /// (by having begin() and end()) which you can use in range-based
765 /// for loops, stl algorithms, etc.
766 /// For example if g is a BpGraph and u is a Node, you can write:
768 /// for(auto a: g.inArcs(u))
771 LemonRangeWrapper2<InArcIt, BpGraph, Node> inArcs(const Node& u) const {
772 return LemonRangeWrapper2<InArcIt, BpGraph, Node>(*this, u);
776 /// \brief Standard graph map type for the nodes.
778 /// Standard graph map type for the nodes.
779 /// It conforms to the ReferenceMap concept.
781 class NodeMap : public ReferenceMap<Node, T, T&, const T&>
786 explicit NodeMap(const BpGraph&) { }
787 /// Constructor with given initial value
788 NodeMap(const BpGraph&, T) { }
792 NodeMap(const NodeMap& nm) :
793 ReferenceMap<Node, T, T&, const T&>(nm) { }
794 ///Assignment operator
795 template <typename CMap>
796 NodeMap& operator=(const CMap&) {
797 checkConcept<ReadMap<Node, T>, CMap>();
802 /// \brief Standard graph map type for the red nodes.
804 /// Standard graph map type for the red nodes.
805 /// It conforms to the ReferenceMap concept.
807 class RedNodeMap : public ReferenceMap<Node, T, T&, const T&>
812 explicit RedNodeMap(const BpGraph&) { }
813 /// Constructor with given initial value
814 RedNodeMap(const BpGraph&, T) { }
818 RedNodeMap(const RedNodeMap& nm) :
819 ReferenceMap<Node, T, T&, const T&>(nm) { }
820 ///Assignment operator
821 template <typename CMap>
822 RedNodeMap& operator=(const CMap&) {
823 checkConcept<ReadMap<Node, T>, CMap>();
828 /// \brief Standard graph map type for the blue nodes.
830 /// Standard graph map type for the blue nodes.
831 /// It conforms to the ReferenceMap concept.
833 class BlueNodeMap : public ReferenceMap<Node, T, T&, const T&>
838 explicit BlueNodeMap(const BpGraph&) { }
839 /// Constructor with given initial value
840 BlueNodeMap(const BpGraph&, T) { }
844 BlueNodeMap(const BlueNodeMap& nm) :
845 ReferenceMap<Node, T, T&, const T&>(nm) { }
846 ///Assignment operator
847 template <typename CMap>
848 BlueNodeMap& operator=(const CMap&) {
849 checkConcept<ReadMap<Node, T>, CMap>();
854 /// \brief Standard graph map type for the arcs.
856 /// Standard graph map type for the arcs.
857 /// It conforms to the ReferenceMap concept.
859 class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
864 explicit ArcMap(const BpGraph&) { }
865 /// Constructor with given initial value
866 ArcMap(const BpGraph&, T) { }
870 ArcMap(const ArcMap& em) :
871 ReferenceMap<Arc, T, T&, const T&>(em) { }
872 ///Assignment operator
873 template <typename CMap>
874 ArcMap& operator=(const CMap&) {
875 checkConcept<ReadMap<Arc, T>, CMap>();
880 /// \brief Standard graph map type for the edges.
882 /// Standard graph map type for the edges.
883 /// It conforms to the ReferenceMap concept.
885 class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
890 explicit EdgeMap(const BpGraph&) { }
891 /// Constructor with given initial value
892 EdgeMap(const BpGraph&, T) { }
896 EdgeMap(const EdgeMap& em) :
897 ReferenceMap<Edge, T, T&, const T&>(em) {}
898 ///Assignment operator
899 template <typename CMap>
900 EdgeMap& operator=(const CMap&) {
901 checkConcept<ReadMap<Edge, T>, CMap>();
906 /// \brief Gives back %true for red nodes.
908 /// Gives back %true for red nodes.
909 bool red(const Node&) const { return true; }
911 /// \brief Gives back %true for blue nodes.
913 /// Gives back %true for blue nodes.
914 bool blue(const Node&) const { return true; }
916 /// \brief Converts the node to red node object.
918 /// This function converts unsafely the node to red node
919 /// object. It should be called only if the node is from the red
920 /// partition or INVALID.
921 RedNode asRedNodeUnsafe(const Node&) const { return RedNode(); }
923 /// \brief Converts the node to blue node object.
925 /// This function converts unsafely the node to blue node
926 /// object. It should be called only if the node is from the red
927 /// partition or INVALID.
928 BlueNode asBlueNodeUnsafe(const Node&) const { return BlueNode(); }
930 /// \brief Converts the node to red node object.
932 /// This function converts safely the node to red node
933 /// object. If the node is not from the red partition, then it
935 RedNode asRedNode(const Node&) const { return RedNode(); }
937 /// \brief Converts the node to blue node object.
939 /// This function converts unsafely the node to blue node
940 /// object. If the node is not from the blue partition, then it
942 BlueNode asBlueNode(const Node&) const { return BlueNode(); }
944 /// \brief Gives back the red end node of the edge.
946 /// Gives back the red end node of the edge.
947 RedNode redNode(const Edge&) const { return RedNode(); }
949 /// \brief Gives back the blue end node of the edge.
951 /// Gives back the blue end node of the edge.
952 BlueNode blueNode(const Edge&) const { return BlueNode(); }
954 /// \brief The first node of the edge.
956 /// It is a synonim for the \c redNode().
957 Node u(Edge) const { return INVALID; }
959 /// \brief The second node of the edge.
961 /// It is a synonim for the \c blueNode().
962 Node v(Edge) const { return INVALID; }
964 /// \brief The source node of the arc.
966 /// Returns the source node of the given arc.
967 Node source(Arc) const { return INVALID; }
969 /// \brief The target node of the arc.
971 /// Returns the target node of the given arc.
972 Node target(Arc) const { return INVALID; }
974 /// \brief The ID of the node.
976 /// Returns the ID of the given node.
977 int id(Node) const { return -1; }
979 /// \brief The red ID of the node.
981 /// Returns the red ID of the given node.
982 int id(RedNode) const { return -1; }
984 /// \brief The blue ID of the node.
986 /// Returns the blue ID of the given node.
987 int id(BlueNode) const { return -1; }
989 /// \brief The ID of the edge.
991 /// Returns the ID of the given edge.
992 int id(Edge) const { return -1; }
994 /// \brief The ID of the arc.
996 /// Returns the ID of the given arc.
997 int id(Arc) const { return -1; }
999 /// \brief The node with the given ID.
1001 /// Returns the node with the given ID.
1002 /// \pre The argument should be a valid node ID in the graph.
1003 Node nodeFromId(int) const { return INVALID; }
1005 /// \brief The edge with the given ID.
1007 /// Returns the edge with the given ID.
1008 /// \pre The argument should be a valid edge ID in the graph.
1009 Edge edgeFromId(int) const { return INVALID; }
1011 /// \brief The arc with the given ID.
1013 /// Returns the arc with the given ID.
1014 /// \pre The argument should be a valid arc ID in the graph.
1015 Arc arcFromId(int) const { return INVALID; }
1017 /// \brief An upper bound on the node IDs.
1019 /// Returns an upper bound on the node IDs.
1020 int maxNodeId() const { return -1; }
1022 /// \brief An upper bound on the red IDs.
1024 /// Returns an upper bound on the red IDs.
1025 int maxRedId() const { return -1; }
1027 /// \brief An upper bound on the blue IDs.
1029 /// Returns an upper bound on the blue IDs.
1030 int maxBlueId() const { return -1; }
1032 /// \brief An upper bound on the edge IDs.
1034 /// Returns an upper bound on the edge IDs.
1035 int maxEdgeId() const { return -1; }
1037 /// \brief An upper bound on the arc IDs.
1039 /// Returns an upper bound on the arc IDs.
1040 int maxArcId() const { return -1; }
1042 /// \brief The direction of the arc.
1044 /// Returns \c true if the given arc goes from a red node to a blue node.
1045 bool direction(Arc) const { return true; }
1047 /// \brief Direct the edge.
1049 /// Direct the given edge. The returned arc
1050 /// represents the given edge and its direction comes
1051 /// from the bool parameter. If it is \c true, then the source of the node
1052 /// will be a red node.
1053 Arc direct(Edge, bool) const {
1057 /// \brief Direct the edge.
1059 /// Direct the given edge. The returned arc represents the given
1060 /// edge and its source node is the given node.
1061 Arc direct(Edge, Node) const {
1065 /// \brief The oppositely directed arc.
1067 /// Returns the oppositely directed arc representing the same edge.
1068 Arc oppositeArc(Arc) const { return INVALID; }
1070 /// \brief The opposite node on the edge.
1072 /// Returns the opposite node on the given edge.
1073 Node oppositeNode(Node, Edge) const { return INVALID; }
1075 void first(Node&) const {}
1076 void next(Node&) const {}
1078 void firstRed(RedNode&) const {}
1079 void nextRed(RedNode&) const {}
1081 void firstBlue(BlueNode&) const {}
1082 void nextBlue(BlueNode&) const {}
1084 void first(Edge&) const {}
1085 void next(Edge&) const {}
1087 void first(Arc&) const {}
1088 void next(Arc&) const {}
1090 void firstOut(Arc&, Node) const {}
1091 void nextOut(Arc&) const {}
1093 void firstIn(Arc&, Node) const {}
1094 void nextIn(Arc&) const {}
1096 void firstInc(Edge &, bool &, const Node &) const {}
1097 void nextInc(Edge &, bool &) const {}
1099 // The second parameter is dummy.
1100 Node fromId(int, Node) const { return INVALID; }
1101 // The second parameter is dummy.
1102 Edge fromId(int, Edge) const { return INVALID; }
1103 // The second parameter is dummy.
1104 Arc fromId(int, Arc) const { return INVALID; }
1107 int maxId(Node) const { return -1; }
1109 int maxId(RedNode) const { return -1; }
1111 int maxId(BlueNode) const { return -1; }
1113 int maxId(Edge) const { return -1; }
1115 int maxId(Arc) const { return -1; }
1117 /// \brief The base node of the iterator.
1119 /// Returns the base node of the given incident edge iterator.
1120 Node baseNode(IncEdgeIt) const { return INVALID; }
1122 /// \brief The running node of the iterator.
1124 /// Returns the running node of the given incident edge iterator.
1125 Node runningNode(IncEdgeIt) const { return INVALID; }
1127 /// \brief The base node of the iterator.
1129 /// Returns the base node of the given outgoing arc iterator
1130 /// (i.e. the source node of the corresponding arc).
1131 Node baseNode(OutArcIt) const { return INVALID; }
1133 /// \brief The running node of the iterator.
1135 /// Returns the running node of the given outgoing arc iterator
1136 /// (i.e. the target node of the corresponding arc).
1137 Node runningNode(OutArcIt) const { return INVALID; }
1139 /// \brief The base node of the iterator.
1141 /// Returns the base node of the given incoming arc iterator
1142 /// (i.e. the target node of the corresponding arc).
1143 Node baseNode(InArcIt) const { return INVALID; }
1145 /// \brief The running node of the iterator.
1147 /// Returns the running node of the given incoming arc iterator
1148 /// (i.e. the source node of the corresponding arc).
1149 Node runningNode(InArcIt) const { return INVALID; }
1151 template <typename _BpGraph>
1152 struct Constraints {
1153 void constraints() {
1154 checkConcept<BaseBpGraphComponent, _BpGraph>();
1155 checkConcept<IterableBpGraphComponent<>, _BpGraph>();
1156 checkConcept<IDableBpGraphComponent<>, _BpGraph>();
1157 checkConcept<MappableBpGraphComponent<>, _BpGraph>();