Fix wrong iteration in ListGraph snapshot, part II. (#598)
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 concepts of graph components.
23 #ifndef LEMON_CONCEPTS_GRAPH_COMPONENTS_H
24 #define LEMON_CONCEPTS_GRAPH_COMPONENTS_H
26 #include <lemon/core.h>
27 #include <lemon/concepts/maps.h>
29 #include <lemon/bits/alteration_notifier.h>
34 /// \brief Concept class for \c Node, \c Arc and \c Edge types.
36 /// This class describes the concept of \c Node, \c Arc and \c Edge
37 /// subtypes of digraph and graph types.
39 /// \note This class is a template class so that we can use it to
40 /// create graph skeleton classes. The reason for this is that \c Node
41 /// and \c Arc (or \c Edge) types should \e not derive from the same
42 /// base class. For \c Node you should instantiate it with character
43 /// \c 'n', for \c Arc with \c 'a' and for \c Edge with \c 'e'.
45 template <char sel = '0'>
49 /// \brief Default constructor.
51 /// Default constructor.
52 /// \warning The default constructor is not required to set
53 /// the item to some well-defined value. So you should consider it
57 /// \brief Copy constructor.
60 GraphItem(const GraphItem &) {}
62 /// \brief Constructor for conversion from \c INVALID.
64 /// Constructor for conversion from \c INVALID.
65 /// It initializes the item to be invalid.
66 /// \sa Invalid for more details.
69 /// \brief Assignment operator.
71 /// Assignment operator for the item.
72 GraphItem& operator=(const GraphItem&) { return *this; }
74 /// \brief Assignment operator for INVALID.
76 /// This operator makes the item invalid.
77 GraphItem& operator=(Invalid) { return *this; }
79 /// \brief Equality operator.
81 /// Equality operator.
82 bool operator==(const GraphItem&) const { return false; }
84 /// \brief Inequality operator.
86 /// Inequality operator.
87 bool operator!=(const GraphItem&) const { return false; }
89 /// \brief Ordering operator.
91 /// This operator defines an ordering of the items.
92 /// It makes possible to use graph item types as key types in
93 /// associative containers (e.g. \c std::map).
95 /// \note This operator only has to define some strict ordering of
96 /// the items; this order has nothing to do with the iteration
97 /// ordering of the items.
98 bool operator<(const GraphItem&) const { return false; }
100 template<typename _GraphItem>
106 _GraphItem i3 = INVALID;
111 ::lemon::ignore_unused_variable_warning(b);
113 b = (ia == ib) && (ia != ib);
114 b = (ia == INVALID) && (ib != INVALID);
118 const _GraphItem &ia;
119 const _GraphItem &ib;
124 /// \brief Base skeleton class for directed graphs.
126 /// This class describes the base interface of directed graph types.
127 /// All digraph %concepts have to conform to this class.
128 /// It just provides types for nodes and arcs and functions
129 /// to get the source and the target nodes of arcs.
130 class BaseDigraphComponent {
133 typedef BaseDigraphComponent Digraph;
135 /// \brief Node class of the digraph.
137 /// This class represents the nodes of the digraph.
138 typedef GraphItem<'n'> Node;
140 /// \brief Arc class of the digraph.
142 /// This class represents the arcs of the digraph.
143 typedef GraphItem<'a'> Arc;
145 /// \brief Return the source node of an arc.
147 /// This function returns the source node of an arc.
148 Node source(const Arc&) const { return INVALID; }
150 /// \brief Return the target node of an arc.
152 /// This function returns the target node of an arc.
153 Node target(const Arc&) const { return INVALID; }
155 /// \brief Return the opposite node on the given arc.
157 /// This function returns the opposite node on the given arc.
158 Node oppositeNode(const Node&, const Arc&) const {
162 template <typename _Digraph>
164 typedef typename _Digraph::Node Node;
165 typedef typename _Digraph::Arc Arc;
168 checkConcept<GraphItem<'n'>, Node>();
169 checkConcept<GraphItem<'a'>, Arc>();
173 n = digraph.source(e);
174 n = digraph.target(e);
175 n = digraph.oppositeNode(n, e);
179 const _Digraph& digraph;
184 /// \brief Base skeleton class for undirected graphs.
186 /// This class describes the base interface of undirected graph types.
187 /// All graph %concepts have to conform to this class.
188 /// It extends the interface of \ref BaseDigraphComponent with an
189 /// \c Edge type and functions to get the end nodes of edges,
190 /// to convert from arcs to edges and to get both direction of edges.
191 class BaseGraphComponent : public BaseDigraphComponent {
194 typedef BaseGraphComponent Graph;
196 typedef BaseDigraphComponent::Node Node;
197 typedef BaseDigraphComponent::Arc Arc;
199 /// \brief Undirected edge class of the graph.
201 /// This class represents the undirected edges of the graph.
202 /// Undirected graphs can be used as directed graphs, each edge is
203 /// represented by two opposite directed arcs.
204 class Edge : public GraphItem<'e'> {
205 typedef GraphItem<'e'> Parent;
208 /// \brief Default constructor.
210 /// Default constructor.
211 /// \warning The default constructor is not required to set
212 /// the item to some well-defined value. So you should consider it
213 /// as uninitialized.
216 /// \brief Copy constructor.
218 /// Copy constructor.
219 Edge(const Edge &) : Parent() {}
221 /// \brief Constructor for conversion from \c INVALID.
223 /// Constructor for conversion from \c INVALID.
224 /// It initializes the item to be invalid.
225 /// \sa Invalid for more details.
228 /// \brief Constructor for conversion from an arc.
230 /// Constructor for conversion from an arc.
231 /// Besides the core graph item functionality each arc should
232 /// be convertible to the represented edge.
236 /// \brief Return one end node of an edge.
238 /// This function returns one end node of an edge.
239 Node u(const Edge&) const { return INVALID; }
241 /// \brief Return the other end node of an edge.
243 /// This function returns the other end node of an edge.
244 Node v(const Edge&) const { return INVALID; }
246 /// \brief Return a directed arc related to an edge.
248 /// This function returns a directed arc from its direction and the
249 /// represented edge.
250 Arc direct(const Edge&, bool) const { return INVALID; }
252 /// \brief Return a directed arc related to an edge.
254 /// This function returns a directed arc from its source node and the
255 /// represented edge.
256 Arc direct(const Edge&, const Node&) const { return INVALID; }
258 /// \brief Return the direction of the arc.
260 /// Returns the direction of the arc. Each arc represents an
261 /// edge with a direction. It gives back the
263 bool direction(const Arc&) const { return true; }
265 /// \brief Return the opposite arc.
267 /// This function returns the opposite arc, i.e. the arc representing
268 /// the same edge and has opposite direction.
269 Arc oppositeArc(const Arc&) const { return INVALID; }
271 template <typename _Graph>
273 typedef typename _Graph::Node Node;
274 typedef typename _Graph::Arc Arc;
275 typedef typename _Graph::Edge Edge;
278 checkConcept<BaseDigraphComponent, _Graph>();
279 checkConcept<GraphItem<'e'>, Edge>();
286 e = graph.direct(ue, true);
287 e = graph.direct(ue, false);
288 e = graph.direct(ue, n);
289 e = graph.oppositeArc(e);
291 bool d = graph.direction(e);
292 ::lemon::ignore_unused_variable_warning(d);
302 /// \brief Base skeleton class for undirected bipartite graphs.
304 /// This class describes the base interface of undirected
305 /// bipartite graph types. All bipartite graph %concepts have to
306 /// conform to this class. It extends the interface of \ref
307 /// BaseGraphComponent with an \c Edge type and functions to get
308 /// the end nodes of edges, to convert from arcs to edges and to
309 /// get both direction of edges.
310 class BaseBpGraphComponent : public BaseGraphComponent {
313 typedef BaseBpGraphComponent BpGraph;
315 typedef BaseDigraphComponent::Node Node;
316 typedef BaseDigraphComponent::Arc Arc;
318 /// \brief Class to represent red nodes.
320 /// This class represents the red nodes of the graph. The red
321 /// nodes can also be used as normal nodes.
322 class RedNode : public Node {
326 /// \brief Default constructor.
328 /// Default constructor.
329 /// \warning The default constructor is not required to set
330 /// the item to some well-defined value. So you should consider it
331 /// as uninitialized.
334 /// \brief Copy constructor.
336 /// Copy constructor.
337 RedNode(const RedNode &) : Parent() {}
339 /// \brief Constructor for conversion from \c INVALID.
341 /// Constructor for conversion from \c INVALID.
342 /// It initializes the item to be invalid.
343 /// \sa Invalid for more details.
347 /// \brief Class to represent blue nodes.
349 /// This class represents the blue nodes of the graph. The blue
350 /// nodes can also be used as normal nodes.
351 class BlueNode : public Node {
355 /// \brief Default constructor.
357 /// Default constructor.
358 /// \warning The default constructor is not required to set
359 /// the item to some well-defined value. So you should consider it
360 /// as uninitialized.
363 /// \brief Copy constructor.
365 /// Copy constructor.
366 BlueNode(const BlueNode &) : Parent() {}
368 /// \brief Constructor for conversion from \c INVALID.
370 /// Constructor for conversion from \c INVALID.
371 /// It initializes the item to be invalid.
372 /// \sa Invalid for more details.
375 /// \brief Constructor for conversion from a node.
377 /// Constructor for conversion from a node. The conversion can
378 /// be invalid, since the Node can be member of the red
380 BlueNode(const Node&) {}
383 /// \brief Gives back %true for red nodes.
385 /// Gives back %true for red nodes.
386 bool red(const Node&) const { return true; }
388 /// \brief Gives back %true for blue nodes.
390 /// Gives back %true for blue nodes.
391 bool blue(const Node&) const { return true; }
393 /// \brief Gives back the red end node of the edge.
395 /// Gives back the red end node of the edge.
396 RedNode redNode(const Edge&) const { return RedNode(); }
398 /// \brief Gives back the blue end node of the edge.
400 /// Gives back the blue end node of the edge.
401 BlueNode blueNode(const Edge&) const { return BlueNode(); }
403 /// \brief Converts the node to red node object.
405 /// This function converts unsafely the node to red node
406 /// object. It should be called only if the node is from the red
407 /// partition or INVALID.
408 RedNode asRedNodeUnsafe(const Node&) const { return RedNode(); }
410 /// \brief Converts the node to blue node object.
412 /// This function converts unsafely the node to blue node
413 /// object. It should be called only if the node is from the red
414 /// partition or INVALID.
415 BlueNode asBlueNodeUnsafe(const Node&) const { return BlueNode(); }
417 /// \brief Converts the node to red node object.
419 /// This function converts safely the node to red node
420 /// object. If the node is not from the red partition, then it
422 RedNode asRedNode(const Node&) const { return RedNode(); }
424 /// \brief Converts the node to blue node object.
426 /// This function converts unsafely the node to blue node
427 /// object. If the node is not from the blue partition, then it
429 BlueNode asBlueNode(const Node&) const { return BlueNode(); }
431 template <typename _BpGraph>
433 typedef typename _BpGraph::Node Node;
434 typedef typename _BpGraph::RedNode RedNode;
435 typedef typename _BpGraph::BlueNode BlueNode;
436 typedef typename _BpGraph::Arc Arc;
437 typedef typename _BpGraph::Edge Edge;
440 checkConcept<BaseGraphComponent, _BpGraph>();
441 checkConcept<GraphItem<'n'>, RedNode>();
442 checkConcept<GraphItem<'n'>, BlueNode>();
451 b = bpgraph.red(rnan);
452 b = bpgraph.blue(bnan);
453 rn = bpgraph.redNode(e);
454 bn = bpgraph.blueNode(e);
455 rn = bpgraph.asRedNodeUnsafe(rnan);
456 bn = bpgraph.asBlueNodeUnsafe(bnan);
457 rn = bpgraph.asRedNode(rnan);
458 bn = bpgraph.asBlueNode(bnan);
459 ::lemon::ignore_unused_variable_warning(b);
463 const _BpGraph& bpgraph;
468 /// \brief Skeleton class for \e idable directed graphs.
470 /// This class describes the interface of \e idable directed graphs.
471 /// It extends \ref BaseDigraphComponent with the core ID functions.
472 /// The ids of the items must be unique and immutable.
473 /// This concept is part of the Digraph concept.
474 template <typename BAS = BaseDigraphComponent>
475 class IDableDigraphComponent : public BAS {
479 typedef typename Base::Node Node;
480 typedef typename Base::Arc Arc;
482 /// \brief Return a unique integer id for the given node.
484 /// This function returns a unique integer id for the given node.
485 int id(const Node&) const { return -1; }
487 /// \brief Return the node by its unique id.
489 /// This function returns the node by its unique id.
490 /// If the digraph does not contain a node with the given id,
491 /// then the result of the function is undefined.
492 Node nodeFromId(int) const { return INVALID; }
494 /// \brief Return a unique integer id for the given arc.
496 /// This function returns a unique integer id for the given arc.
497 int id(const Arc&) const { return -1; }
499 /// \brief Return the arc by its unique id.
501 /// This function returns the arc by its unique id.
502 /// If the digraph does not contain an arc with the given id,
503 /// then the result of the function is undefined.
504 Arc arcFromId(int) const { return INVALID; }
506 /// \brief Return an integer greater or equal to the maximum
509 /// This function returns an integer greater or equal to the
511 int maxNodeId() const { return -1; }
513 /// \brief Return an integer greater or equal to the maximum
516 /// This function returns an integer greater or equal to the
518 int maxArcId() const { return -1; }
520 template <typename _Digraph>
524 checkConcept<Base, _Digraph >();
525 typename _Digraph::Node node;
527 int nid = digraph.id(node);
528 nid = digraph.id(node);
529 node = digraph.nodeFromId(nid);
530 typename _Digraph::Arc arc;
532 int eid = digraph.id(arc);
533 eid = digraph.id(arc);
534 arc = digraph.arcFromId(eid);
536 nid = digraph.maxNodeId();
537 ::lemon::ignore_unused_variable_warning(nid);
538 eid = digraph.maxArcId();
539 ::lemon::ignore_unused_variable_warning(eid);
542 const _Digraph& digraph;
547 /// \brief Skeleton class for \e idable undirected graphs.
549 /// This class describes the interface of \e idable undirected
550 /// graphs. It extends \ref IDableDigraphComponent with the core ID
551 /// functions of undirected graphs.
552 /// The ids of the items must be unique and immutable.
553 /// This concept is part of the Graph concept.
554 template <typename BAS = BaseGraphComponent>
555 class IDableGraphComponent : public IDableDigraphComponent<BAS> {
559 typedef typename Base::Edge Edge;
561 using IDableDigraphComponent<Base>::id;
563 /// \brief Return a unique integer id for the given edge.
565 /// This function returns a unique integer id for the given edge.
566 int id(const Edge&) const { return -1; }
568 /// \brief Return the edge by its unique id.
570 /// This function returns the edge by its unique id.
571 /// If the graph does not contain an edge with the given id,
572 /// then the result of the function is undefined.
573 Edge edgeFromId(int) const { return INVALID; }
575 /// \brief Return an integer greater or equal to the maximum
578 /// This function returns an integer greater or equal to the
580 int maxEdgeId() const { return -1; }
582 template <typename _Graph>
586 checkConcept<IDableDigraphComponent<Base>, _Graph >();
587 typename _Graph::Edge edge;
588 int ueid = graph.id(edge);
589 ueid = graph.id(edge);
590 edge = graph.edgeFromId(ueid);
591 ueid = graph.maxEdgeId();
592 ::lemon::ignore_unused_variable_warning(ueid);
600 /// \brief Skeleton class for \e idable undirected bipartite graphs.
602 /// This class describes the interface of \e idable undirected
603 /// bipartite graphs. It extends \ref IDableGraphComponent with
604 /// the core ID functions of undirected bipartite graphs. Beside
605 /// the regular node ids, this class also provides ids within the
606 /// the red and blue sets of the nodes. This concept is part of
607 /// the BpGraph concept.
608 template <typename BAS = BaseBpGraphComponent>
609 class IDableBpGraphComponent : public IDableGraphComponent<BAS> {
613 typedef IDableGraphComponent<BAS> Parent;
614 typedef typename Base::Node Node;
615 typedef typename Base::RedNode RedNode;
616 typedef typename Base::BlueNode BlueNode;
620 /// \brief Return a unique integer id for the given node in the red set.
622 /// Return a unique integer id for the given node in the red set.
623 int id(const RedNode&) const { return -1; }
625 /// \brief Return a unique integer id for the given node in the blue set.
627 /// Return a unique integer id for the given node in the blue set.
628 int id(const BlueNode&) const { return -1; }
630 /// \brief Return an integer greater or equal to the maximum
631 /// node id in the red set.
633 /// Return an integer greater or equal to the maximum
634 /// node id in the red set.
635 int maxRedId() const { return -1; }
637 /// \brief Return an integer greater or equal to the maximum
638 /// node id in the blue set.
640 /// Return an integer greater or equal to the maximum
641 /// node id in the blue set.
642 int maxBlueId() const { return -1; }
644 template <typename _BpGraph>
648 checkConcept<IDableGraphComponent<Base>, _BpGraph>();
649 typename _BpGraph::Node node;
650 typename _BpGraph::RedNode red;
651 typename _BpGraph::BlueNode blue;
652 int rid = bpgraph.id(red);
653 int bid = bpgraph.id(blue);
654 rid = bpgraph.maxRedId();
655 bid = bpgraph.maxBlueId();
656 ::lemon::ignore_unused_variable_warning(rid);
657 ::lemon::ignore_unused_variable_warning(bid);
660 const _BpGraph& bpgraph;
664 /// \brief Concept class for \c NodeIt, \c ArcIt and \c EdgeIt types.
666 /// This class describes the concept of \c NodeIt, \c ArcIt and
667 /// \c EdgeIt subtypes of digraph and graph types.
668 template <typename GR, typename Item>
669 class GraphItemIt : public Item {
671 /// \brief Default constructor.
673 /// Default constructor.
674 /// \warning The default constructor is not required to set
675 /// the iterator to some well-defined value. So you should consider it
676 /// as uninitialized.
679 /// \brief Copy constructor.
681 /// Copy constructor.
682 GraphItemIt(const GraphItemIt& it) : Item(it) {}
684 /// \brief Constructor that sets the iterator to the first item.
686 /// Constructor that sets the iterator to the first item.
687 explicit GraphItemIt(const GR&) {}
689 /// \brief Constructor for conversion from \c INVALID.
691 /// Constructor for conversion from \c INVALID.
692 /// It initializes the iterator to be invalid.
693 /// \sa Invalid for more details.
694 GraphItemIt(Invalid) {}
696 /// \brief Assignment operator.
698 /// Assignment operator for the iterator.
699 GraphItemIt& operator=(const GraphItemIt&) { return *this; }
701 /// \brief Increment the iterator.
703 /// This operator increments the iterator, i.e. assigns it to the
705 GraphItemIt& operator++() { return *this; }
707 /// \brief Equality operator
709 /// Equality operator.
710 /// Two iterators are equal if and only if they point to the
711 /// same object or both are invalid.
712 bool operator==(const GraphItemIt&) const { return true;}
714 /// \brief Inequality operator
716 /// Inequality operator.
717 /// Two iterators are equal if and only if they point to the
718 /// same object or both are invalid.
719 bool operator!=(const GraphItemIt&) const { return true;}
721 template<typename _GraphItemIt>
724 checkConcept<GraphItem<>, _GraphItemIt>();
727 _GraphItemIt it3 = it1;
728 _GraphItemIt it4 = INVALID;
729 ::lemon::ignore_unused_variable_warning(it3);
730 ::lemon::ignore_unused_variable_warning(it4);
744 /// \brief Concept class for \c InArcIt, \c OutArcIt and
745 /// \c IncEdgeIt types.
747 /// This class describes the concept of \c InArcIt, \c OutArcIt
748 /// and \c IncEdgeIt subtypes of digraph and graph types.
750 /// \note Since these iterator classes do not inherit from the same
751 /// base class, there is an additional template parameter (selector)
752 /// \c sel. For \c InArcIt you should instantiate it with character
753 /// \c 'i', for \c OutArcIt with \c 'o' and for \c IncEdgeIt with \c 'e'.
754 template <typename GR,
755 typename Item = typename GR::Arc,
756 typename Base = typename GR::Node,
758 class GraphIncIt : public Item {
760 /// \brief Default constructor.
762 /// Default constructor.
763 /// \warning The default constructor is not required to set
764 /// the iterator to some well-defined value. So you should consider it
765 /// as uninitialized.
768 /// \brief Copy constructor.
770 /// Copy constructor.
771 GraphIncIt(const GraphIncIt& it) : Item(it) {}
773 /// \brief Constructor that sets the iterator to the first
774 /// incoming or outgoing arc.
776 /// Constructor that sets the iterator to the first arc
777 /// incoming to or outgoing from the given node.
778 explicit GraphIncIt(const GR&, const Base&) {}
780 /// \brief Constructor for conversion from \c INVALID.
782 /// Constructor for conversion from \c INVALID.
783 /// It initializes the iterator to be invalid.
784 /// \sa Invalid for more details.
785 GraphIncIt(Invalid) {}
787 /// \brief Assignment operator.
789 /// Assignment operator for the iterator.
790 GraphIncIt& operator=(const GraphIncIt&) { return *this; }
792 /// \brief Increment the iterator.
794 /// This operator increments the iterator, i.e. assigns it to the
795 /// next arc incoming to or outgoing from the given node.
796 GraphIncIt& operator++() { return *this; }
798 /// \brief Equality operator
800 /// Equality operator.
801 /// Two iterators are equal if and only if they point to the
802 /// same object or both are invalid.
803 bool operator==(const GraphIncIt&) const { return true;}
805 /// \brief Inequality operator
807 /// Inequality operator.
808 /// Two iterators are equal if and only if they point to the
809 /// same object or both are invalid.
810 bool operator!=(const GraphIncIt&) const { return true;}
812 template <typename _GraphIncIt>
815 checkConcept<GraphItem<sel>, _GraphIncIt>();
816 _GraphIncIt it1(graph, node);
818 _GraphIncIt it3 = it1;
819 _GraphIncIt it4 = INVALID;
820 ::lemon::ignore_unused_variable_warning(it3);
821 ::lemon::ignore_unused_variable_warning(it4);
835 /// \brief Skeleton class for iterable directed graphs.
837 /// This class describes the interface of iterable directed
838 /// graphs. It extends \ref BaseDigraphComponent with the core
839 /// iterable interface.
840 /// This concept is part of the Digraph concept.
841 template <typename BAS = BaseDigraphComponent>
842 class IterableDigraphComponent : public BAS {
847 typedef typename Base::Node Node;
848 typedef typename Base::Arc Arc;
850 typedef IterableDigraphComponent Digraph;
852 /// \name Base Iteration
854 /// This interface provides functions for iteration on digraph items.
858 /// \brief Return the first node.
860 /// This function gives back the first node in the iteration order.
861 void first(Node&) const {}
863 /// \brief Return the next node.
865 /// This function gives back the next node in the iteration order.
866 void next(Node&) const {}
868 /// \brief Return the first arc.
870 /// This function gives back the first arc in the iteration order.
871 void first(Arc&) const {}
873 /// \brief Return the next arc.
875 /// This function gives back the next arc in the iteration order.
876 void next(Arc&) const {}
878 /// \brief Return the first arc incoming to the given node.
880 /// This function gives back the first arc incoming to the
882 void firstIn(Arc&, const Node&) const {}
884 /// \brief Return the next arc incoming to the given node.
886 /// This function gives back the next arc incoming to the
888 void nextIn(Arc&) const {}
890 /// \brief Return the first arc outgoing form the given node.
892 /// This function gives back the first arc outgoing form the
894 void firstOut(Arc&, const Node&) const {}
896 /// \brief Return the next arc outgoing form the given node.
898 /// This function gives back the next arc outgoing form the
900 void nextOut(Arc&) const {}
904 /// \name Class Based Iteration
906 /// This interface provides iterator classes for digraph items.
910 /// \brief This iterator goes through each node.
912 /// This iterator goes through each node.
914 typedef GraphItemIt<Digraph, Node> NodeIt;
916 /// \brief This iterator goes through each arc.
918 /// This iterator goes through each arc.
920 typedef GraphItemIt<Digraph, Arc> ArcIt;
922 /// \brief This iterator goes trough the incoming arcs of a node.
924 /// This iterator goes trough the \e incoming arcs of a certain node
926 typedef GraphIncIt<Digraph, Arc, Node, 'i'> InArcIt;
928 /// \brief This iterator goes trough the outgoing arcs of a node.
930 /// This iterator goes trough the \e outgoing arcs of a certain node
932 typedef GraphIncIt<Digraph, Arc, Node, 'o'> OutArcIt;
934 /// \brief The base node of the iterator.
936 /// This function gives back the base node of the iterator.
937 /// It is always the target node of the pointed arc.
938 Node baseNode(const InArcIt&) const { return INVALID; }
940 /// \brief The running node of the iterator.
942 /// This function gives back the running node of the iterator.
943 /// It is always the source node of the pointed arc.
944 Node runningNode(const InArcIt&) const { return INVALID; }
946 /// \brief The base node of the iterator.
948 /// This function gives back the base node of the iterator.
949 /// It is always the source node of the pointed arc.
950 Node baseNode(const OutArcIt&) const { return INVALID; }
952 /// \brief The running node of the iterator.
954 /// This function gives back the running node of the iterator.
955 /// It is always the target node of the pointed arc.
956 Node runningNode(const OutArcIt&) const { return INVALID; }
960 template <typename _Digraph>
963 checkConcept<Base, _Digraph>();
966 typename _Digraph::Node node(INVALID);
967 typename _Digraph::Arc arc(INVALID);
977 digraph.firstIn(arc, node);
981 digraph.firstOut(arc, node);
982 digraph.nextOut(arc);
987 checkConcept<GraphItemIt<_Digraph, typename _Digraph::Arc>,
988 typename _Digraph::ArcIt >();
989 checkConcept<GraphItemIt<_Digraph, typename _Digraph::Node>,
990 typename _Digraph::NodeIt >();
991 checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
992 typename _Digraph::Node, 'i'>, typename _Digraph::InArcIt>();
993 checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
994 typename _Digraph::Node, 'o'>, typename _Digraph::OutArcIt>();
996 typename _Digraph::Node n;
997 const typename _Digraph::InArcIt iait(INVALID);
998 const typename _Digraph::OutArcIt oait(INVALID);
999 n = digraph.baseNode(iait);
1000 n = digraph.runningNode(iait);
1001 n = digraph.baseNode(oait);
1002 n = digraph.runningNode(oait);
1003 ::lemon::ignore_unused_variable_warning(n);
1007 const _Digraph& digraph;
1012 /// \brief Skeleton class for iterable undirected graphs.
1014 /// This class describes the interface of iterable undirected
1015 /// graphs. It extends \ref IterableDigraphComponent with the core
1016 /// iterable interface of undirected graphs.
1017 /// This concept is part of the Graph concept.
1018 template <typename BAS = BaseGraphComponent>
1019 class IterableGraphComponent : public IterableDigraphComponent<BAS> {
1023 typedef typename Base::Node Node;
1024 typedef typename Base::Arc Arc;
1025 typedef typename Base::Edge Edge;
1028 typedef IterableGraphComponent Graph;
1030 /// \name Base Iteration
1032 /// This interface provides functions for iteration on edges.
1036 using IterableDigraphComponent<Base>::first;
1037 using IterableDigraphComponent<Base>::next;
1039 /// \brief Return the first edge.
1041 /// This function gives back the first edge in the iteration order.
1042 void first(Edge&) const {}
1044 /// \brief Return the next edge.
1046 /// This function gives back the next edge in the iteration order.
1047 void next(Edge&) const {}
1049 /// \brief Return the first edge incident to the given node.
1051 /// This function gives back the first edge incident to the given
1052 /// node. The bool parameter gives back the direction for which the
1053 /// source node of the directed arc representing the edge is the
1055 void firstInc(Edge&, bool&, const Node&) const {}
1057 /// \brief Gives back the next of the edges from the
1060 /// This function gives back the next edge incident to the given
1061 /// node. The bool parameter should be used as \c firstInc() use it.
1062 void nextInc(Edge&, bool&) const {}
1064 using IterableDigraphComponent<Base>::baseNode;
1065 using IterableDigraphComponent<Base>::runningNode;
1069 /// \name Class Based Iteration
1071 /// This interface provides iterator classes for edges.
1075 /// \brief This iterator goes through each edge.
1077 /// This iterator goes through each edge.
1078 typedef GraphItemIt<Graph, Edge> EdgeIt;
1080 /// \brief This iterator goes trough the incident edges of a
1083 /// This iterator goes trough the incident edges of a certain
1084 /// node of a graph.
1085 typedef GraphIncIt<Graph, Edge, Node, 'e'> IncEdgeIt;
1087 /// \brief The base node of the iterator.
1089 /// This function gives back the base node of the iterator.
1090 Node baseNode(const IncEdgeIt&) const { return INVALID; }
1092 /// \brief The running node of the iterator.
1094 /// This function gives back the running node of the iterator.
1095 Node runningNode(const IncEdgeIt&) const { return INVALID; }
1099 template <typename _Graph>
1100 struct Constraints {
1101 void constraints() {
1102 checkConcept<IterableDigraphComponent<Base>, _Graph>();
1105 typename _Graph::Node node(INVALID);
1106 typename _Graph::Edge edge(INVALID);
1113 graph.firstInc(edge, dir, node);
1114 graph.nextInc(edge, dir);
1120 checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
1121 typename _Graph::EdgeIt >();
1122 checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
1123 typename _Graph::Node, 'e'>, typename _Graph::IncEdgeIt>();
1125 typename _Graph::Node n;
1126 const typename _Graph::IncEdgeIt ieit(INVALID);
1127 n = graph.baseNode(ieit);
1128 n = graph.runningNode(ieit);
1132 const _Graph& graph;
1137 /// \brief Skeleton class for iterable undirected bipartite graphs.
1139 /// This class describes the interface of iterable undirected
1140 /// bipartite graphs. It extends \ref IterableGraphComponent with
1141 /// the core iterable interface of undirected bipartite graphs.
1142 /// This concept is part of the BpGraph concept.
1143 template <typename BAS = BaseBpGraphComponent>
1144 class IterableBpGraphComponent : public IterableGraphComponent<BAS> {
1148 typedef typename Base::Node Node;
1149 typedef typename Base::RedNode RedNode;
1150 typedef typename Base::BlueNode BlueNode;
1151 typedef typename Base::Arc Arc;
1152 typedef typename Base::Edge Edge;
1154 typedef IterableBpGraphComponent BpGraph;
1156 using IterableGraphComponent<BAS>::first;
1157 using IterableGraphComponent<BAS>::next;
1159 /// \name Base Iteration
1161 /// This interface provides functions for iteration on red and blue nodes.
1165 /// \brief Return the first red node.
1167 /// This function gives back the first red node in the iteration order.
1168 void first(RedNode&) const {}
1170 /// \brief Return the next red node.
1172 /// This function gives back the next red node in the iteration order.
1173 void next(RedNode&) const {}
1175 /// \brief Return the first blue node.
1177 /// This function gives back the first blue node in the iteration order.
1178 void first(BlueNode&) const {}
1180 /// \brief Return the next blue node.
1182 /// This function gives back the next blue node in the iteration order.
1183 void next(BlueNode&) const {}
1188 /// \name Class Based Iteration
1190 /// This interface provides iterator classes for red and blue nodes.
1194 /// \brief This iterator goes through each red node.
1196 /// This iterator goes through each red node.
1197 typedef GraphItemIt<BpGraph, RedNode> RedNodeIt;
1199 /// \brief This iterator goes through each blue node.
1201 /// This iterator goes through each blue node.
1202 typedef GraphItemIt<BpGraph, BlueNode> BlueNodeIt;
1206 template <typename _BpGraph>
1207 struct Constraints {
1208 void constraints() {
1209 checkConcept<IterableGraphComponent<Base>, _BpGraph>();
1211 typename _BpGraph::RedNode rn(INVALID);
1214 typename _BpGraph::BlueNode bn(INVALID);
1218 checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::RedNode>,
1219 typename _BpGraph::RedNodeIt>();
1220 checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::BlueNode>,
1221 typename _BpGraph::BlueNodeIt>();
1224 const _BpGraph& bpgraph;
1228 /// \brief Skeleton class for alterable directed graphs.
1230 /// This class describes the interface of alterable directed
1231 /// graphs. It extends \ref BaseDigraphComponent with the alteration
1232 /// notifier interface. It implements
1233 /// an observer-notifier pattern for each digraph item. More
1234 /// obsevers can be registered into the notifier and whenever an
1235 /// alteration occured in the digraph all the observers will be
1236 /// notified about it.
1237 template <typename BAS = BaseDigraphComponent>
1238 class AlterableDigraphComponent : public BAS {
1242 typedef typename Base::Node Node;
1243 typedef typename Base::Arc Arc;
1246 /// Node alteration notifier class.
1247 typedef AlterationNotifier<AlterableDigraphComponent, Node>
1249 /// Arc alteration notifier class.
1250 typedef AlterationNotifier<AlterableDigraphComponent, Arc>
1253 mutable NodeNotifier node_notifier;
1254 mutable ArcNotifier arc_notifier;
1256 /// \brief Return the node alteration notifier.
1258 /// This function gives back the node alteration notifier.
1259 NodeNotifier& notifier(Node) const {
1260 return node_notifier;
1263 /// \brief Return the arc alteration notifier.
1265 /// This function gives back the arc alteration notifier.
1266 ArcNotifier& notifier(Arc) const {
1267 return arc_notifier;
1270 template <typename _Digraph>
1271 struct Constraints {
1272 void constraints() {
1273 checkConcept<Base, _Digraph>();
1274 typename _Digraph::NodeNotifier& nn
1275 = digraph.notifier(typename _Digraph::Node());
1277 typename _Digraph::ArcNotifier& en
1278 = digraph.notifier(typename _Digraph::Arc());
1280 ::lemon::ignore_unused_variable_warning(nn);
1281 ::lemon::ignore_unused_variable_warning(en);
1284 const _Digraph& digraph;
1289 /// \brief Skeleton class for alterable undirected graphs.
1291 /// This class describes the interface of alterable undirected
1292 /// graphs. It extends \ref AlterableDigraphComponent with the alteration
1293 /// notifier interface of undirected graphs. It implements
1294 /// an observer-notifier pattern for the edges. More
1295 /// obsevers can be registered into the notifier and whenever an
1296 /// alteration occured in the graph all the observers will be
1297 /// notified about it.
1298 template <typename BAS = BaseGraphComponent>
1299 class AlterableGraphComponent : public AlterableDigraphComponent<BAS> {
1303 typedef AlterableDigraphComponent<Base> Parent;
1304 typedef typename Base::Edge Edge;
1307 /// Edge alteration notifier class.
1308 typedef AlterationNotifier<AlterableGraphComponent, Edge>
1311 mutable EdgeNotifier edge_notifier;
1313 using Parent::notifier;
1315 /// \brief Return the edge alteration notifier.
1317 /// This function gives back the edge alteration notifier.
1318 EdgeNotifier& notifier(Edge) const {
1319 return edge_notifier;
1322 template <typename _Graph>
1323 struct Constraints {
1324 void constraints() {
1325 checkConcept<AlterableDigraphComponent<Base>, _Graph>();
1326 typename _Graph::EdgeNotifier& uen
1327 = graph.notifier(typename _Graph::Edge());
1328 ::lemon::ignore_unused_variable_warning(uen);
1331 const _Graph& graph;
1336 /// \brief Skeleton class for alterable undirected bipartite graphs.
1338 /// This class describes the interface of alterable undirected
1339 /// bipartite graphs. It extends \ref AlterableGraphComponent with
1340 /// the alteration notifier interface of bipartite graphs. It
1341 /// implements an observer-notifier pattern for the red and blue
1342 /// nodes. More obsevers can be registered into the notifier and
1343 /// whenever an alteration occured in the graph all the observers
1344 /// will be notified about it.
1345 template <typename BAS = BaseBpGraphComponent>
1346 class AlterableBpGraphComponent : public AlterableGraphComponent<BAS> {
1350 typedef AlterableGraphComponent<Base> Parent;
1351 typedef typename Base::RedNode RedNode;
1352 typedef typename Base::BlueNode BlueNode;
1355 /// Red node alteration notifier class.
1356 typedef AlterationNotifier<AlterableBpGraphComponent, RedNode>
1359 /// Blue node alteration notifier class.
1360 typedef AlterationNotifier<AlterableBpGraphComponent, BlueNode>
1363 mutable RedNodeNotifier red_node_notifier;
1364 mutable BlueNodeNotifier blue_node_notifier;
1366 using Parent::notifier;
1368 /// \brief Return the red node alteration notifier.
1370 /// This function gives back the red node alteration notifier.
1371 RedNodeNotifier& notifier(RedNode) const {
1372 return red_node_notifier;
1375 /// \brief Return the blue node alteration notifier.
1377 /// This function gives back the blue node alteration notifier.
1378 BlueNodeNotifier& notifier(BlueNode) const {
1379 return blue_node_notifier;
1382 template <typename _BpGraph>
1383 struct Constraints {
1384 void constraints() {
1385 checkConcept<AlterableGraphComponent<Base>, _BpGraph>();
1386 typename _BpGraph::RedNodeNotifier& rnn
1387 = bpgraph.notifier(typename _BpGraph::RedNode());
1388 typename _BpGraph::BlueNodeNotifier& bnn
1389 = bpgraph.notifier(typename _BpGraph::BlueNode());
1390 ::lemon::ignore_unused_variable_warning(rnn);
1391 ::lemon::ignore_unused_variable_warning(bnn);
1394 const _BpGraph& bpgraph;
1398 /// \brief Concept class for standard graph maps.
1400 /// This class describes the concept of standard graph maps, i.e.
1401 /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and
1402 /// graph types, which can be used for associating data to graph items.
1403 /// The standard graph maps must conform to the ReferenceMap concept.
1404 template <typename GR, typename K, typename V>
1405 class GraphMap : public ReferenceMap<K, V, V&, const V&> {
1406 typedef ReferenceMap<K, V, V&, const V&> Parent;
1410 /// The key type of the map.
1412 /// The value type of the map.
1414 /// The reference type of the map.
1415 typedef Value& Reference;
1416 /// The const reference type of the map.
1417 typedef const Value& ConstReference;
1419 // The reference map tag.
1420 typedef True ReferenceMapTag;
1422 /// \brief Construct a new map.
1424 /// Construct a new map for the graph.
1425 explicit GraphMap(const GR&) {}
1426 /// \brief Construct a new map with default value.
1428 /// Construct a new map for the graph and initalize the values.
1429 GraphMap(const GR&, const Value&) {}
1432 /// \brief Copy constructor.
1434 /// Copy Constructor.
1435 GraphMap(const GraphMap&) : Parent() {}
1437 /// \brief Assignment operator.
1439 /// Assignment operator. It does not mofify the underlying graph,
1440 /// it just iterates on the current item set and set the map
1441 /// with the value returned by the assigned map.
1442 template <typename CMap>
1443 GraphMap& operator=(const CMap&) {
1444 checkConcept<ReadMap<Key, Value>, CMap>();
1449 template<typename _Map>
1450 struct Constraints {
1451 void constraints() {
1453 <ReferenceMap<Key, Value, Value&, const Value&>, _Map>();
1460 // Assignment operator
1461 // ReadMap<Key, Value> cmap;
1464 ::lemon::ignore_unused_variable_warning(m1);
1465 ::lemon::ignore_unused_variable_warning(m2);
1466 // ::lemon::ignore_unused_variable_warning(m3);
1471 const typename GraphMap::Value &t;
1477 /// \brief Skeleton class for mappable directed graphs.
1479 /// This class describes the interface of mappable directed graphs.
1480 /// It extends \ref BaseDigraphComponent with the standard digraph
1481 /// map classes, namely \c NodeMap and \c ArcMap.
1482 /// This concept is part of the Digraph concept.
1483 template <typename BAS = BaseDigraphComponent>
1484 class MappableDigraphComponent : public BAS {
1488 typedef typename Base::Node Node;
1489 typedef typename Base::Arc Arc;
1491 typedef MappableDigraphComponent Digraph;
1493 /// \brief Standard graph map for the nodes.
1495 /// Standard graph map for the nodes.
1496 /// It conforms to the ReferenceMap concept.
1497 template <typename V>
1498 class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
1499 typedef GraphMap<MappableDigraphComponent, Node, V> Parent;
1502 /// \brief Construct a new map.
1504 /// Construct a new map for the digraph.
1505 explicit NodeMap(const MappableDigraphComponent& digraph)
1506 : Parent(digraph) {}
1508 /// \brief Construct a new map with default value.
1510 /// Construct a new map for the digraph and initalize the values.
1511 NodeMap(const MappableDigraphComponent& digraph, const V& value)
1512 : Parent(digraph, value) {}
1515 /// \brief Copy constructor.
1517 /// Copy Constructor.
1518 NodeMap(const NodeMap& nm) : Parent(nm) {}
1520 /// \brief Assignment operator.
1522 /// Assignment operator.
1523 template <typename CMap>
1524 NodeMap& operator=(const CMap&) {
1525 checkConcept<ReadMap<Node, V>, CMap>();
1531 /// \brief Standard graph map for the arcs.
1533 /// Standard graph map for the arcs.
1534 /// It conforms to the ReferenceMap concept.
1535 template <typename V>
1536 class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
1537 typedef GraphMap<MappableDigraphComponent, Arc, V> Parent;
1540 /// \brief Construct a new map.
1542 /// Construct a new map for the digraph.
1543 explicit ArcMap(const MappableDigraphComponent& digraph)
1544 : Parent(digraph) {}
1546 /// \brief Construct a new map with default value.
1548 /// Construct a new map for the digraph and initalize the values.
1549 ArcMap(const MappableDigraphComponent& digraph, const V& value)
1550 : Parent(digraph, value) {}
1553 /// \brief Copy constructor.
1555 /// Copy Constructor.
1556 ArcMap(const ArcMap& nm) : Parent(nm) {}
1558 /// \brief Assignment operator.
1560 /// Assignment operator.
1561 template <typename CMap>
1562 ArcMap& operator=(const CMap&) {
1563 checkConcept<ReadMap<Arc, V>, CMap>();
1570 template <typename _Digraph>
1571 struct Constraints {
1575 Dummy() : value(0) {}
1576 Dummy(int _v) : value(_v) {}
1579 void constraints() {
1580 checkConcept<Base, _Digraph>();
1582 typedef typename _Digraph::template NodeMap<int> IntNodeMap;
1583 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, int>,
1585 } { // bool map test
1586 typedef typename _Digraph::template NodeMap<bool> BoolNodeMap;
1587 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, bool>,
1589 } { // Dummy map test
1590 typedef typename _Digraph::template NodeMap<Dummy> DummyNodeMap;
1591 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, Dummy>,
1596 typedef typename _Digraph::template ArcMap<int> IntArcMap;
1597 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, int>,
1599 } { // bool map test
1600 typedef typename _Digraph::template ArcMap<bool> BoolArcMap;
1601 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, bool>,
1603 } { // Dummy map test
1604 typedef typename _Digraph::template ArcMap<Dummy> DummyArcMap;
1605 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, Dummy>,
1610 const _Digraph& digraph;
1615 /// \brief Skeleton class for mappable undirected graphs.
1617 /// This class describes the interface of mappable undirected graphs.
1618 /// It extends \ref MappableDigraphComponent with the standard graph
1619 /// map class for edges (\c EdgeMap).
1620 /// This concept is part of the Graph concept.
1621 template <typename BAS = BaseGraphComponent>
1622 class MappableGraphComponent : public MappableDigraphComponent<BAS> {
1626 typedef typename Base::Edge Edge;
1628 typedef MappableGraphComponent Graph;
1630 /// \brief Standard graph map for the edges.
1632 /// Standard graph map for the edges.
1633 /// It conforms to the ReferenceMap concept.
1634 template <typename V>
1635 class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
1636 typedef GraphMap<MappableGraphComponent, Edge, V> Parent;
1639 /// \brief Construct a new map.
1641 /// Construct a new map for the graph.
1642 explicit EdgeMap(const MappableGraphComponent& graph)
1645 /// \brief Construct a new map with default value.
1647 /// Construct a new map for the graph and initalize the values.
1648 EdgeMap(const MappableGraphComponent& graph, const V& value)
1649 : Parent(graph, value) {}
1652 /// \brief Copy constructor.
1654 /// Copy Constructor.
1655 EdgeMap(const EdgeMap& nm) : Parent(nm) {}
1657 /// \brief Assignment operator.
1659 /// Assignment operator.
1660 template <typename CMap>
1661 EdgeMap& operator=(const CMap&) {
1662 checkConcept<ReadMap<Edge, V>, CMap>();
1669 template <typename _Graph>
1670 struct Constraints {
1674 Dummy() : value(0) {}
1675 Dummy(int _v) : value(_v) {}
1678 void constraints() {
1679 checkConcept<MappableDigraphComponent<Base>, _Graph>();
1682 typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
1683 checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
1685 } { // bool map test
1686 typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
1687 checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
1689 } { // Dummy map test
1690 typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
1691 checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>,
1696 const _Graph& graph;
1701 /// \brief Skeleton class for mappable undirected bipartite graphs.
1703 /// This class describes the interface of mappable undirected
1704 /// bipartite graphs. It extends \ref MappableGraphComponent with
1705 /// the standard graph map class for red and blue nodes (\c
1706 /// RedNodeMap and BlueNodeMap). This concept is part of the
1707 /// BpGraph concept.
1708 template <typename BAS = BaseBpGraphComponent>
1709 class MappableBpGraphComponent : public MappableGraphComponent<BAS> {
1713 typedef typename Base::Node Node;
1715 typedef MappableBpGraphComponent BpGraph;
1717 /// \brief Standard graph map for the red nodes.
1719 /// Standard graph map for the red nodes.
1720 /// It conforms to the ReferenceMap concept.
1721 template <typename V>
1722 class RedNodeMap : public GraphMap<MappableBpGraphComponent, Node, V> {
1723 typedef GraphMap<MappableBpGraphComponent, Node, V> Parent;
1726 /// \brief Construct a new map.
1728 /// Construct a new map for the graph.
1729 explicit RedNodeMap(const MappableBpGraphComponent& graph)
1732 /// \brief Construct a new map with default value.
1734 /// Construct a new map for the graph and initalize the values.
1735 RedNodeMap(const MappableBpGraphComponent& graph, const V& value)
1736 : Parent(graph, value) {}
1739 /// \brief Copy constructor.
1741 /// Copy Constructor.
1742 RedNodeMap(const RedNodeMap& nm) : Parent(nm) {}
1744 /// \brief Assignment operator.
1746 /// Assignment operator.
1747 template <typename CMap>
1748 RedNodeMap& operator=(const CMap&) {
1749 checkConcept<ReadMap<Node, V>, CMap>();
1755 /// \brief Standard graph map for the blue nodes.
1757 /// Standard graph map for the blue nodes.
1758 /// It conforms to the ReferenceMap concept.
1759 template <typename V>
1760 class BlueNodeMap : public GraphMap<MappableBpGraphComponent, Node, V> {
1761 typedef GraphMap<MappableBpGraphComponent, Node, V> Parent;
1764 /// \brief Construct a new map.
1766 /// Construct a new map for the graph.
1767 explicit BlueNodeMap(const MappableBpGraphComponent& graph)
1770 /// \brief Construct a new map with default value.
1772 /// Construct a new map for the graph and initalize the values.
1773 BlueNodeMap(const MappableBpGraphComponent& graph, const V& value)
1774 : Parent(graph, value) {}
1777 /// \brief Copy constructor.
1779 /// Copy Constructor.
1780 BlueNodeMap(const BlueNodeMap& nm) : Parent(nm) {}
1782 /// \brief Assignment operator.
1784 /// Assignment operator.
1785 template <typename CMap>
1786 BlueNodeMap& operator=(const CMap&) {
1787 checkConcept<ReadMap<Node, V>, CMap>();
1794 template <typename _BpGraph>
1795 struct Constraints {
1799 Dummy() : value(0) {}
1800 Dummy(int _v) : value(_v) {}
1803 void constraints() {
1804 checkConcept<MappableGraphComponent<Base>, _BpGraph>();
1807 typedef typename _BpGraph::template RedNodeMap<int>
1809 checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, int>,
1811 } { // bool map test
1812 typedef typename _BpGraph::template RedNodeMap<bool>
1814 checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, bool>,
1816 } { // Dummy map test
1817 typedef typename _BpGraph::template RedNodeMap<Dummy>
1819 checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, Dummy>,
1820 DummyRedNodeMap >();
1824 typedef typename _BpGraph::template BlueNodeMap<int>
1826 checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, int>,
1828 } { // bool map test
1829 typedef typename _BpGraph::template BlueNodeMap<bool>
1831 checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, bool>,
1832 BoolBlueNodeMap >();
1833 } { // Dummy map test
1834 typedef typename _BpGraph::template BlueNodeMap<Dummy>
1836 checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, Dummy>,
1837 DummyBlueNodeMap >();
1841 const _BpGraph& bpgraph;
1845 /// \brief Skeleton class for extendable directed graphs.
1847 /// This class describes the interface of extendable directed graphs.
1848 /// It extends \ref BaseDigraphComponent with functions for adding
1849 /// nodes and arcs to the digraph.
1850 /// This concept requires \ref AlterableDigraphComponent.
1851 template <typename BAS = BaseDigraphComponent>
1852 class ExtendableDigraphComponent : public BAS {
1856 typedef typename Base::Node Node;
1857 typedef typename Base::Arc Arc;
1859 /// \brief Add a new node to the digraph.
1861 /// This function adds a new node to the digraph.
1866 /// \brief Add a new arc connecting the given two nodes.
1868 /// This function adds a new arc connecting the given two nodes
1870 Arc addArc(const Node&, const Node&) {
1874 template <typename _Digraph>
1875 struct Constraints {
1876 void constraints() {
1877 checkConcept<Base, _Digraph>();
1878 typename _Digraph::Node node_a, node_b;
1879 node_a = digraph.addNode();
1880 node_b = digraph.addNode();
1881 typename _Digraph::Arc arc;
1882 arc = digraph.addArc(node_a, node_b);
1890 /// \brief Skeleton class for extendable undirected graphs.
1892 /// This class describes the interface of extendable undirected graphs.
1893 /// It extends \ref BaseGraphComponent with functions for adding
1894 /// nodes and edges to the graph.
1895 /// This concept requires \ref AlterableGraphComponent.
1896 template <typename BAS = BaseGraphComponent>
1897 class ExtendableGraphComponent : public BAS {
1901 typedef typename Base::Node Node;
1902 typedef typename Base::Edge Edge;
1904 /// \brief Add a new node to the digraph.
1906 /// This function adds a new node to the digraph.
1911 /// \brief Add a new edge connecting the given two nodes.
1913 /// This function adds a new edge connecting the given two nodes
1915 Edge addEdge(const Node&, const Node&) {
1919 template <typename _Graph>
1920 struct Constraints {
1921 void constraints() {
1922 checkConcept<Base, _Graph>();
1923 typename _Graph::Node node_a, node_b;
1924 node_a = graph.addNode();
1925 node_b = graph.addNode();
1926 typename _Graph::Edge edge;
1927 edge = graph.addEdge(node_a, node_b);
1935 /// \brief Skeleton class for extendable undirected bipartite graphs.
1937 /// This class describes the interface of extendable undirected
1938 /// bipartite graphs. It extends \ref BaseGraphComponent with
1939 /// functions for adding nodes and edges to the graph. This
1940 /// concept requires \ref AlterableBpGraphComponent.
1941 template <typename BAS = BaseBpGraphComponent>
1942 class ExtendableBpGraphComponent : public BAS {
1946 typedef typename Base::Node Node;
1947 typedef typename Base::RedNode RedNode;
1948 typedef typename Base::BlueNode BlueNode;
1949 typedef typename Base::Edge Edge;
1951 /// \brief Add a new red node to the digraph.
1953 /// This function adds a red new node to the digraph.
1954 RedNode addRedNode() {
1958 /// \brief Add a new blue node to the digraph.
1960 /// This function adds a blue new node to the digraph.
1961 BlueNode addBlueNode() {
1965 /// \brief Add a new edge connecting the given two nodes.
1967 /// This function adds a new edge connecting the given two nodes
1968 /// of the graph. The first node has to be a red node, and the
1969 /// second one a blue node.
1970 Edge addEdge(const RedNode&, const BlueNode&) {
1973 Edge addEdge(const BlueNode&, const RedNode&) {
1977 template <typename _BpGraph>
1978 struct Constraints {
1979 void constraints() {
1980 checkConcept<Base, _BpGraph>();
1981 typename _BpGraph::RedNode red_node;
1982 typename _BpGraph::BlueNode blue_node;
1983 red_node = bpgraph.addRedNode();
1984 blue_node = bpgraph.addBlueNode();
1985 typename _BpGraph::Edge edge;
1986 edge = bpgraph.addEdge(red_node, blue_node);
1987 edge = bpgraph.addEdge(blue_node, red_node);
1994 /// \brief Skeleton class for erasable directed graphs.
1996 /// This class describes the interface of erasable directed graphs.
1997 /// It extends \ref BaseDigraphComponent with functions for removing
1998 /// nodes and arcs from the digraph.
1999 /// This concept requires \ref AlterableDigraphComponent.
2000 template <typename BAS = BaseDigraphComponent>
2001 class ErasableDigraphComponent : public BAS {
2005 typedef typename Base::Node Node;
2006 typedef typename Base::Arc Arc;
2008 /// \brief Erase a node from the digraph.
2010 /// This function erases the given node from the digraph and all arcs
2011 /// connected to the node.
2012 void erase(const Node&) {}
2014 /// \brief Erase an arc from the digraph.
2016 /// This function erases the given arc from the digraph.
2017 void erase(const Arc&) {}
2019 template <typename _Digraph>
2020 struct Constraints {
2021 void constraints() {
2022 checkConcept<Base, _Digraph>();
2023 const typename _Digraph::Node node(INVALID);
2024 digraph.erase(node);
2025 const typename _Digraph::Arc arc(INVALID);
2034 /// \brief Skeleton class for erasable undirected graphs.
2036 /// This class describes the interface of erasable undirected graphs.
2037 /// It extends \ref BaseGraphComponent with functions for removing
2038 /// nodes and edges from the graph.
2039 /// This concept requires \ref AlterableGraphComponent.
2040 template <typename BAS = BaseGraphComponent>
2041 class ErasableGraphComponent : public BAS {
2045 typedef typename Base::Node Node;
2046 typedef typename Base::Edge Edge;
2048 /// \brief Erase a node from the graph.
2050 /// This function erases the given node from the graph and all edges
2051 /// connected to the node.
2052 void erase(const Node&) {}
2054 /// \brief Erase an edge from the digraph.
2056 /// This function erases the given edge from the digraph.
2057 void erase(const Edge&) {}
2059 template <typename _Graph>
2060 struct Constraints {
2061 void constraints() {
2062 checkConcept<Base, _Graph>();
2063 const typename _Graph::Node node(INVALID);
2065 const typename _Graph::Edge edge(INVALID);
2074 /// \brief Skeleton class for erasable undirected graphs.
2076 /// This class describes the interface of erasable undirected
2077 /// bipartite graphs. It extends \ref BaseBpGraphComponent with
2078 /// functions for removing nodes and edges from the graph. This
2079 /// concept requires \ref AlterableBpGraphComponent.
2080 template <typename BAS = BaseBpGraphComponent>
2081 class ErasableBpGraphComponent : public ErasableGraphComponent<BAS> {};
2083 /// \brief Skeleton class for clearable directed graphs.
2085 /// This class describes the interface of clearable directed graphs.
2086 /// It extends \ref BaseDigraphComponent with a function for clearing
2088 /// This concept requires \ref AlterableDigraphComponent.
2089 template <typename BAS = BaseDigraphComponent>
2090 class ClearableDigraphComponent : public BAS {
2095 /// \brief Erase all nodes and arcs from the digraph.
2097 /// This function erases all nodes and arcs from the digraph.
2100 template <typename _Digraph>
2101 struct Constraints {
2102 void constraints() {
2103 checkConcept<Base, _Digraph>();
2112 /// \brief Skeleton class for clearable undirected graphs.
2114 /// This class describes the interface of clearable undirected graphs.
2115 /// It extends \ref BaseGraphComponent with a function for clearing
2117 /// This concept requires \ref AlterableGraphComponent.
2118 template <typename BAS = BaseGraphComponent>
2119 class ClearableGraphComponent : public ClearableDigraphComponent<BAS> {};
2121 /// \brief Skeleton class for clearable undirected biparite graphs.
2123 /// This class describes the interface of clearable undirected
2124 /// bipartite graphs. It extends \ref BaseBpGraphComponent with a
2125 /// function for clearing the graph. This concept requires \ref
2126 /// AlterableBpGraphComponent.
2127 template <typename BAS = BaseBpGraphComponent>
2128 class ClearableBpGraphComponent : public ClearableGraphComponent<BAS> {};