1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2010
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 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 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. It does
321 /// not supposed to be used directly, because the nodes can be
322 /// represented as Node instances. This class can be used as
323 /// template parameter for special map classes.
324 class RedNode : public Node {
328 /// \brief Default constructor.
330 /// Default constructor.
331 /// \warning The default constructor is not required to set
332 /// the item to some well-defined value. So you should consider it
333 /// as uninitialized.
336 /// \brief Copy constructor.
338 /// Copy constructor.
339 RedNode(const RedNode &) : Parent() {}
341 /// \brief Constructor for conversion from \c INVALID.
343 /// Constructor for conversion from \c INVALID.
344 /// It initializes the item to be invalid.
345 /// \sa Invalid for more details.
348 /// \brief Constructor for conversion from a node.
350 /// Constructor for conversion from a node. The conversion can
351 /// be invalid, since the Node can be member of the blue
353 RedNode(const Node&) {}
356 /// \brief Class to represent blue nodes.
358 /// This class represents the blue nodes of the graph. It does
359 /// not supposed to be used directly, because the nodes can be
360 /// represented as Node instances. This class can be used as
361 /// template parameter for special map classes.
362 class BlueNode : public Node {
366 /// \brief Default constructor.
368 /// Default constructor.
369 /// \warning The default constructor is not required to set
370 /// the item to some well-defined value. So you should consider it
371 /// as uninitialized.
374 /// \brief Copy constructor.
376 /// Copy constructor.
377 BlueNode(const BlueNode &) : Parent() {}
379 /// \brief Constructor for conversion from \c INVALID.
381 /// Constructor for conversion from \c INVALID.
382 /// It initializes the item to be invalid.
383 /// \sa Invalid for more details.
386 /// \brief Constructor for conversion from a node.
388 /// Constructor for conversion from a node. The conversion can
389 /// be invalid, since the Node can be member of the red
391 BlueNode(const Node&) {}
394 /// \brief Gives back %true for red nodes.
396 /// Gives back %true for red nodes.
397 bool red(const Node&) const { return true; }
399 /// \brief Gives back %true for blue nodes.
401 /// Gives back %true for blue nodes.
402 bool blue(const Node&) const { return true; }
404 /// \brief Gives back the red end node of the edge.
406 /// Gives back the red end node of the edge.
407 Node redNode(const Edge&) const { return Node(); }
409 /// \brief Gives back the blue end node of the edge.
411 /// Gives back the blue end node of the edge.
412 Node blueNode(const Edge&) const { return Node(); }
414 template <typename _BpGraph>
416 typedef typename _BpGraph::Node Node;
417 typedef typename _BpGraph::RedNode RedNode;
418 typedef typename _BpGraph::BlueNode BlueNode;
419 typedef typename _BpGraph::Arc Arc;
420 typedef typename _BpGraph::Edge Edge;
423 checkConcept<BaseGraphComponent, _BpGraph>();
424 checkConcept<GraphItem<'n'>, RedNode>();
425 checkConcept<GraphItem<'n'>, BlueNode>();
434 ignore_unused_variable_warning(b);
435 n = bpgraph.redNode(e);
436 n = bpgraph.blueNode(e);
442 const _BpGraph& bpgraph;
447 /// \brief Skeleton class for \e idable directed graphs.
449 /// This class describes the interface of \e idable directed graphs.
450 /// It extends \ref BaseDigraphComponent with the core ID functions.
451 /// The ids of the items must be unique and immutable.
452 /// This concept is part of the Digraph concept.
453 template <typename BAS = BaseDigraphComponent>
454 class IDableDigraphComponent : public BAS {
458 typedef typename Base::Node Node;
459 typedef typename Base::Arc Arc;
461 /// \brief Return a unique integer id for the given node.
463 /// This function returns a unique integer id for the given node.
464 int id(const Node&) const { return -1; }
466 /// \brief Return the node by its unique id.
468 /// This function returns the node by its unique id.
469 /// If the digraph does not contain a node with the given id,
470 /// then the result of the function is undefined.
471 Node nodeFromId(int) const { return INVALID; }
473 /// \brief Return a unique integer id for the given arc.
475 /// This function returns a unique integer id for the given arc.
476 int id(const Arc&) const { return -1; }
478 /// \brief Return the arc by its unique id.
480 /// This function returns the arc by its unique id.
481 /// If the digraph does not contain an arc with the given id,
482 /// then the result of the function is undefined.
483 Arc arcFromId(int) const { return INVALID; }
485 /// \brief Return an integer greater or equal to the maximum
488 /// This function returns an integer greater or equal to the
490 int maxNodeId() const { return -1; }
492 /// \brief Return an integer greater or equal to the maximum
495 /// This function returns an integer greater or equal to the
497 int maxArcId() const { return -1; }
499 template <typename _Digraph>
503 checkConcept<Base, _Digraph >();
504 typename _Digraph::Node node;
506 int nid = digraph.id(node);
507 nid = digraph.id(node);
508 node = digraph.nodeFromId(nid);
509 typename _Digraph::Arc arc;
511 int eid = digraph.id(arc);
512 eid = digraph.id(arc);
513 arc = digraph.arcFromId(eid);
515 nid = digraph.maxNodeId();
516 ignore_unused_variable_warning(nid);
517 eid = digraph.maxArcId();
518 ignore_unused_variable_warning(eid);
521 const _Digraph& digraph;
526 /// \brief Skeleton class for \e idable undirected graphs.
528 /// This class describes the interface of \e idable undirected
529 /// graphs. It extends \ref IDableDigraphComponent with the core ID
530 /// functions of undirected graphs.
531 /// The ids of the items must be unique and immutable.
532 /// This concept is part of the Graph concept.
533 template <typename BAS = BaseGraphComponent>
534 class IDableGraphComponent : public IDableDigraphComponent<BAS> {
538 typedef typename Base::Edge Edge;
540 using IDableDigraphComponent<Base>::id;
542 /// \brief Return a unique integer id for the given edge.
544 /// This function returns a unique integer id for the given edge.
545 int id(const Edge&) const { return -1; }
547 /// \brief Return the edge by its unique id.
549 /// This function returns the edge by its unique id.
550 /// If the graph does not contain an edge with the given id,
551 /// then the result of the function is undefined.
552 Edge edgeFromId(int) const { return INVALID; }
554 /// \brief Return an integer greater or equal to the maximum
557 /// This function returns an integer greater or equal to the
559 int maxEdgeId() const { return -1; }
561 template <typename _Graph>
565 checkConcept<IDableDigraphComponent<Base>, _Graph >();
566 typename _Graph::Edge edge;
567 int ueid = graph.id(edge);
568 ueid = graph.id(edge);
569 edge = graph.edgeFromId(ueid);
570 ueid = graph.maxEdgeId();
571 ignore_unused_variable_warning(ueid);
579 /// \brief Skeleton class for \e idable undirected bipartite graphs.
581 /// This class describes the interface of \e idable undirected
582 /// bipartite graphs. It extends \ref IDableGraphComponent with
583 /// the core ID functions of undirected bipartite graphs. Beside
584 /// the regular node ids, this class also provides ids within the
585 /// the red and blue sets of the nodes. This concept is part of
586 /// the BpGraph concept.
587 template <typename BAS = BaseBpGraphComponent>
588 class IDableBpGraphComponent : public IDableGraphComponent<BAS> {
592 typedef IDableGraphComponent<BAS> Parent;
593 typedef typename Base::Node Node;
594 typedef typename Base::RedNode RedNode;
595 typedef typename Base::BlueNode BlueNode;
599 /// \brief Return a unique integer id for the given node in the red set.
601 /// Return a unique integer id for the given node in the red set.
602 int redId(const Node&) const { return -1; }
604 /// \brief Return the same value as redId().
606 /// Return the same value as redId().
607 int id(const RedNode&) const { return -1; }
609 /// \brief Return a unique integer id for the given node in the blue set.
611 /// Return a unique integer id for the given node in the blue set.
612 int blueId(const Node&) const { return -1; }
614 /// \brief Return the same value as blueId().
616 /// Return the same value as blueId().
617 int id(const BlueNode&) const { return -1; }
619 /// \brief Return an integer greater or equal to the maximum
620 /// node id in the red set.
622 /// Return an integer greater or equal to the maximum
623 /// node id in the red set.
624 int maxRedId() const { return -1; }
626 /// \brief Return an integer greater or equal to the maximum
627 /// node id in the blue set.
629 /// Return an integer greater or equal to the maximum
630 /// node id in the blue set.
631 int maxBlueId() const { return -1; }
633 template <typename _BpGraph>
637 checkConcept<IDableGraphComponent<Base>, _BpGraph>();
638 typename _BpGraph::Node node;
639 typename _BpGraph::RedNode red;
640 typename _BpGraph::BlueNode blue;
641 int rid = bpgraph.redId(node);
642 int bid = bpgraph.blueId(node);
643 rid = bpgraph.id(red);
644 bid = bpgraph.id(blue);
645 rid = bpgraph.maxRedId();
646 bid = bpgraph.maxBlueId();
647 ignore_unused_variable_warning(rid);
648 ignore_unused_variable_warning(bid);
651 const _BpGraph& bpgraph;
655 /// \brief Concept class for \c NodeIt, \c ArcIt and \c EdgeIt types.
657 /// This class describes the concept of \c NodeIt, \c ArcIt and
658 /// \c EdgeIt subtypes of digraph and graph types.
659 template <typename GR, typename Item>
660 class GraphItemIt : public Item {
662 /// \brief Default constructor.
664 /// Default constructor.
665 /// \warning The default constructor is not required to set
666 /// the iterator to some well-defined value. So you should consider it
667 /// as uninitialized.
670 /// \brief Copy constructor.
672 /// Copy constructor.
673 GraphItemIt(const GraphItemIt& it) : Item(it) {}
675 /// \brief Constructor that sets the iterator to the first item.
677 /// Constructor that sets the iterator to the first item.
678 explicit GraphItemIt(const GR&) {}
680 /// \brief Constructor for conversion from \c INVALID.
682 /// Constructor for conversion from \c INVALID.
683 /// It initializes the iterator to be invalid.
684 /// \sa Invalid for more details.
685 GraphItemIt(Invalid) {}
687 /// \brief Assignment operator.
689 /// Assignment operator for the iterator.
690 GraphItemIt& operator=(const GraphItemIt&) { return *this; }
692 /// \brief Increment the iterator.
694 /// This operator increments the iterator, i.e. assigns it to the
696 GraphItemIt& operator++() { return *this; }
698 /// \brief Equality operator
700 /// Equality operator.
701 /// Two iterators are equal if and only if they point to the
702 /// same object or both are invalid.
703 bool operator==(const GraphItemIt&) const { return true;}
705 /// \brief Inequality operator
707 /// Inequality operator.
708 /// Two iterators are equal if and only if they point to the
709 /// same object or both are invalid.
710 bool operator!=(const GraphItemIt&) const { return true;}
712 template<typename _GraphItemIt>
715 checkConcept<GraphItem<>, _GraphItemIt>();
718 _GraphItemIt it3 = it1;
719 _GraphItemIt it4 = INVALID;
720 ignore_unused_variable_warning(it3);
721 ignore_unused_variable_warning(it4);
735 /// \brief Concept class for \c InArcIt, \c OutArcIt and
736 /// \c IncEdgeIt types.
738 /// This class describes the concept of \c InArcIt, \c OutArcIt
739 /// and \c IncEdgeIt subtypes of digraph and graph types.
741 /// \note Since these iterator classes do not inherit from the same
742 /// base class, there is an additional template parameter (selector)
743 /// \c sel. For \c InArcIt you should instantiate it with character
744 /// \c 'i', for \c OutArcIt with \c 'o' and for \c IncEdgeIt with \c 'e'.
745 template <typename GR,
746 typename Item = typename GR::Arc,
747 typename Base = typename GR::Node,
749 class GraphIncIt : public Item {
751 /// \brief Default constructor.
753 /// Default constructor.
754 /// \warning The default constructor is not required to set
755 /// the iterator to some well-defined value. So you should consider it
756 /// as uninitialized.
759 /// \brief Copy constructor.
761 /// Copy constructor.
762 GraphIncIt(const GraphIncIt& it) : Item(it) {}
764 /// \brief Constructor that sets the iterator to the first
765 /// incoming or outgoing arc.
767 /// Constructor that sets the iterator to the first arc
768 /// incoming to or outgoing from the given node.
769 explicit GraphIncIt(const GR&, const Base&) {}
771 /// \brief Constructor for conversion from \c INVALID.
773 /// Constructor for conversion from \c INVALID.
774 /// It initializes the iterator to be invalid.
775 /// \sa Invalid for more details.
776 GraphIncIt(Invalid) {}
778 /// \brief Assignment operator.
780 /// Assignment operator for the iterator.
781 GraphIncIt& operator=(const GraphIncIt&) { return *this; }
783 /// \brief Increment the iterator.
785 /// This operator increments the iterator, i.e. assigns it to the
786 /// next arc incoming to or outgoing from the given node.
787 GraphIncIt& operator++() { return *this; }
789 /// \brief Equality operator
791 /// Equality operator.
792 /// Two iterators are equal if and only if they point to the
793 /// same object or both are invalid.
794 bool operator==(const GraphIncIt&) const { return true;}
796 /// \brief Inequality operator
798 /// Inequality operator.
799 /// Two iterators are equal if and only if they point to the
800 /// same object or both are invalid.
801 bool operator!=(const GraphIncIt&) const { return true;}
803 template <typename _GraphIncIt>
806 checkConcept<GraphItem<sel>, _GraphIncIt>();
807 _GraphIncIt it1(graph, node);
809 _GraphIncIt it3 = it1;
810 _GraphIncIt it4 = INVALID;
811 ignore_unused_variable_warning(it3);
812 ignore_unused_variable_warning(it4);
826 /// \brief Skeleton class for iterable directed graphs.
828 /// This class describes the interface of iterable directed
829 /// graphs. It extends \ref BaseDigraphComponent with the core
830 /// iterable interface.
831 /// This concept is part of the Digraph concept.
832 template <typename BAS = BaseDigraphComponent>
833 class IterableDigraphComponent : public BAS {
838 typedef typename Base::Node Node;
839 typedef typename Base::Arc Arc;
841 typedef IterableDigraphComponent Digraph;
843 /// \name Base Iteration
845 /// This interface provides functions for iteration on digraph items.
849 /// \brief Return the first node.
851 /// This function gives back the first node in the iteration order.
852 void first(Node&) const {}
854 /// \brief Return the next node.
856 /// This function gives back the next node in the iteration order.
857 void next(Node&) const {}
859 /// \brief Return the first arc.
861 /// This function gives back the first arc in the iteration order.
862 void first(Arc&) const {}
864 /// \brief Return the next arc.
866 /// This function gives back the next arc in the iteration order.
867 void next(Arc&) const {}
869 /// \brief Return the first arc incomming to the given node.
871 /// This function gives back the first arc incomming to the
873 void firstIn(Arc&, const Node&) const {}
875 /// \brief Return the next arc incomming to the given node.
877 /// This function gives back the next arc incomming to the
879 void nextIn(Arc&) const {}
881 /// \brief Return the first arc outgoing form the given node.
883 /// This function gives back the first arc outgoing form the
885 void firstOut(Arc&, const Node&) const {}
887 /// \brief Return the next arc outgoing form the given node.
889 /// This function gives back the next arc outgoing form the
891 void nextOut(Arc&) const {}
895 /// \name Class Based Iteration
897 /// This interface provides iterator classes for digraph items.
901 /// \brief This iterator goes through each node.
903 /// This iterator goes through each node.
905 typedef GraphItemIt<Digraph, Node> NodeIt;
907 /// \brief This iterator goes through each arc.
909 /// This iterator goes through each arc.
911 typedef GraphItemIt<Digraph, Arc> ArcIt;
913 /// \brief This iterator goes trough the incoming arcs of a node.
915 /// This iterator goes trough the \e incoming arcs of a certain node
917 typedef GraphIncIt<Digraph, Arc, Node, 'i'> InArcIt;
919 /// \brief This iterator goes trough the outgoing arcs of a node.
921 /// This iterator goes trough the \e outgoing arcs of a certain node
923 typedef GraphIncIt<Digraph, Arc, Node, 'o'> OutArcIt;
925 /// \brief The base node of the iterator.
927 /// This function gives back the base node of the iterator.
928 /// It is always the target node of the pointed arc.
929 Node baseNode(const InArcIt&) const { return INVALID; }
931 /// \brief The running node of the iterator.
933 /// This function gives back the running node of the iterator.
934 /// It is always the source node of the pointed arc.
935 Node runningNode(const InArcIt&) const { return INVALID; }
937 /// \brief The base node of the iterator.
939 /// This function gives back the base node of the iterator.
940 /// It is always the source node of the pointed arc.
941 Node baseNode(const OutArcIt&) const { return INVALID; }
943 /// \brief The running node of the iterator.
945 /// This function gives back the running node of the iterator.
946 /// It is always the target node of the pointed arc.
947 Node runningNode(const OutArcIt&) const { return INVALID; }
951 template <typename _Digraph>
954 checkConcept<Base, _Digraph>();
957 typename _Digraph::Node node(INVALID);
958 typename _Digraph::Arc arc(INVALID);
968 digraph.firstIn(arc, node);
972 digraph.firstOut(arc, node);
973 digraph.nextOut(arc);
978 checkConcept<GraphItemIt<_Digraph, typename _Digraph::Arc>,
979 typename _Digraph::ArcIt >();
980 checkConcept<GraphItemIt<_Digraph, typename _Digraph::Node>,
981 typename _Digraph::NodeIt >();
982 checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
983 typename _Digraph::Node, 'i'>, typename _Digraph::InArcIt>();
984 checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
985 typename _Digraph::Node, 'o'>, typename _Digraph::OutArcIt>();
987 typename _Digraph::Node n;
988 const typename _Digraph::InArcIt iait(INVALID);
989 const typename _Digraph::OutArcIt oait(INVALID);
990 n = digraph.baseNode(iait);
991 n = digraph.runningNode(iait);
992 n = digraph.baseNode(oait);
993 n = digraph.runningNode(oait);
994 ignore_unused_variable_warning(n);
998 const _Digraph& digraph;
1003 /// \brief Skeleton class for iterable undirected graphs.
1005 /// This class describes the interface of iterable undirected
1006 /// graphs. It extends \ref IterableDigraphComponent with the core
1007 /// iterable interface of undirected graphs.
1008 /// This concept is part of the Graph concept.
1009 template <typename BAS = BaseGraphComponent>
1010 class IterableGraphComponent : public IterableDigraphComponent<BAS> {
1014 typedef typename Base::Node Node;
1015 typedef typename Base::Arc Arc;
1016 typedef typename Base::Edge Edge;
1019 typedef IterableGraphComponent Graph;
1021 /// \name Base Iteration
1023 /// This interface provides functions for iteration on edges.
1027 using IterableDigraphComponent<Base>::first;
1028 using IterableDigraphComponent<Base>::next;
1030 /// \brief Return the first edge.
1032 /// This function gives back the first edge in the iteration order.
1033 void first(Edge&) const {}
1035 /// \brief Return the next edge.
1037 /// This function gives back the next edge in the iteration order.
1038 void next(Edge&) const {}
1040 /// \brief Return the first edge incident to the given node.
1042 /// This function gives back the first edge incident to the given
1043 /// node. The bool parameter gives back the direction for which the
1044 /// source node of the directed arc representing the edge is the
1046 void firstInc(Edge&, bool&, const Node&) const {}
1048 /// \brief Gives back the next of the edges from the
1051 /// This function gives back the next edge incident to the given
1052 /// node. The bool parameter should be used as \c firstInc() use it.
1053 void nextInc(Edge&, bool&) const {}
1055 using IterableDigraphComponent<Base>::baseNode;
1056 using IterableDigraphComponent<Base>::runningNode;
1060 /// \name Class Based Iteration
1062 /// This interface provides iterator classes for edges.
1066 /// \brief This iterator goes through each edge.
1068 /// This iterator goes through each edge.
1069 typedef GraphItemIt<Graph, Edge> EdgeIt;
1071 /// \brief This iterator goes trough the incident edges of a
1074 /// This iterator goes trough the incident edges of a certain
1075 /// node of a graph.
1076 typedef GraphIncIt<Graph, Edge, Node, 'e'> IncEdgeIt;
1078 /// \brief The base node of the iterator.
1080 /// This function gives back the base node of the iterator.
1081 Node baseNode(const IncEdgeIt&) const { return INVALID; }
1083 /// \brief The running node of the iterator.
1085 /// This function gives back the running node of the iterator.
1086 Node runningNode(const IncEdgeIt&) const { return INVALID; }
1090 template <typename _Graph>
1091 struct Constraints {
1092 void constraints() {
1093 checkConcept<IterableDigraphComponent<Base>, _Graph>();
1096 typename _Graph::Node node(INVALID);
1097 typename _Graph::Edge edge(INVALID);
1104 graph.firstInc(edge, dir, node);
1105 graph.nextInc(edge, dir);
1111 checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
1112 typename _Graph::EdgeIt >();
1113 checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
1114 typename _Graph::Node, 'e'>, typename _Graph::IncEdgeIt>();
1116 typename _Graph::Node n;
1117 const typename _Graph::IncEdgeIt ieit(INVALID);
1118 n = graph.baseNode(ieit);
1119 n = graph.runningNode(ieit);
1123 const _Graph& graph;
1128 /// \brief Skeleton class for iterable undirected bipartite graphs.
1130 /// This class describes the interface of iterable undirected
1131 /// bipartite graphs. It extends \ref IterableGraphComponent with
1132 /// the core iterable interface of undirected bipartite graphs.
1133 /// This concept is part of the BpGraph concept.
1134 template <typename BAS = BaseBpGraphComponent>
1135 class IterableBpGraphComponent : public IterableGraphComponent<BAS> {
1139 typedef typename Base::Node Node;
1140 typedef typename Base::Arc Arc;
1141 typedef typename Base::Edge Edge;
1144 typedef IterableBpGraphComponent BpGraph;
1146 /// \name Base Iteration
1148 /// This interface provides functions for iteration on red and blue nodes.
1152 /// \brief Return the first red node.
1154 /// This function gives back the first red node in the iteration order.
1155 void firstRed(Node&) const {}
1157 /// \brief Return the next red node.
1159 /// This function gives back the next red node in the iteration order.
1160 void nextRed(Node&) const {}
1162 /// \brief Return the first blue node.
1164 /// This function gives back the first blue node in the iteration order.
1165 void firstBlue(Node&) const {}
1167 /// \brief Return the next blue node.
1169 /// This function gives back the next blue node in the iteration order.
1170 void nextBlue(Node&) const {}
1175 /// \name Class Based Iteration
1177 /// This interface provides iterator classes for red and blue nodes.
1181 /// \brief This iterator goes through each red node.
1183 /// This iterator goes through each red node.
1184 typedef GraphItemIt<BpGraph, Node> RedIt;
1186 /// \brief This iterator goes through each blue node.
1188 /// This iterator goes through each blue node.
1189 typedef GraphItemIt<BpGraph, Node> BlueIt;
1193 template <typename _BpGraph>
1194 struct Constraints {
1195 void constraints() {
1196 checkConcept<IterableGraphComponent<Base>, _BpGraph>();
1198 typename _BpGraph::Node node(INVALID);
1199 bpgraph.firstRed(node);
1200 bpgraph.nextRed(node);
1201 bpgraph.firstBlue(node);
1202 bpgraph.nextBlue(node);
1204 checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::Node>,
1205 typename _BpGraph::RedIt>();
1206 checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::Node>,
1207 typename _BpGraph::BlueIt>();
1210 const _BpGraph& bpgraph;
1214 /// \brief Skeleton class for alterable directed graphs.
1216 /// This class describes the interface of alterable directed
1217 /// graphs. It extends \ref BaseDigraphComponent with the alteration
1218 /// notifier interface. It implements
1219 /// an observer-notifier pattern for each digraph item. More
1220 /// obsevers can be registered into the notifier and whenever an
1221 /// alteration occured in the digraph all the observers will be
1222 /// notified about it.
1223 template <typename BAS = BaseDigraphComponent>
1224 class AlterableDigraphComponent : public BAS {
1228 typedef typename Base::Node Node;
1229 typedef typename Base::Arc Arc;
1232 /// Node alteration notifier class.
1233 typedef AlterationNotifier<AlterableDigraphComponent, Node>
1235 /// Arc alteration notifier class.
1236 typedef AlterationNotifier<AlterableDigraphComponent, Arc>
1239 mutable NodeNotifier node_notifier;
1240 mutable ArcNotifier arc_notifier;
1242 /// \brief Return the node alteration notifier.
1244 /// This function gives back the node alteration notifier.
1245 NodeNotifier& notifier(Node) const {
1246 return node_notifier;
1249 /// \brief Return the arc alteration notifier.
1251 /// This function gives back the arc alteration notifier.
1252 ArcNotifier& notifier(Arc) const {
1253 return arc_notifier;
1256 template <typename _Digraph>
1257 struct Constraints {
1258 void constraints() {
1259 checkConcept<Base, _Digraph>();
1260 typename _Digraph::NodeNotifier& nn
1261 = digraph.notifier(typename _Digraph::Node());
1263 typename _Digraph::ArcNotifier& en
1264 = digraph.notifier(typename _Digraph::Arc());
1266 ignore_unused_variable_warning(nn);
1267 ignore_unused_variable_warning(en);
1270 const _Digraph& digraph;
1275 /// \brief Skeleton class for alterable undirected graphs.
1277 /// This class describes the interface of alterable undirected
1278 /// graphs. It extends \ref AlterableDigraphComponent with the alteration
1279 /// notifier interface of undirected graphs. It implements
1280 /// an observer-notifier pattern for the edges. More
1281 /// obsevers can be registered into the notifier and whenever an
1282 /// alteration occured in the graph all the observers will be
1283 /// notified about it.
1284 template <typename BAS = BaseGraphComponent>
1285 class AlterableGraphComponent : public AlterableDigraphComponent<BAS> {
1289 typedef AlterableDigraphComponent<Base> Parent;
1290 typedef typename Base::Edge Edge;
1293 /// Edge alteration notifier class.
1294 typedef AlterationNotifier<AlterableGraphComponent, Edge>
1297 mutable EdgeNotifier edge_notifier;
1299 using Parent::notifier;
1301 /// \brief Return the edge alteration notifier.
1303 /// This function gives back the edge alteration notifier.
1304 EdgeNotifier& notifier(Edge) const {
1305 return edge_notifier;
1308 template <typename _Graph>
1309 struct Constraints {
1310 void constraints() {
1311 checkConcept<AlterableDigraphComponent<Base>, _Graph>();
1312 typename _Graph::EdgeNotifier& uen
1313 = graph.notifier(typename _Graph::Edge());
1314 ignore_unused_variable_warning(uen);
1317 const _Graph& graph;
1322 /// \brief Skeleton class for alterable undirected bipartite graphs.
1324 /// This class describes the interface of alterable undirected
1325 /// bipartite graphs. It extends \ref AlterableGraphComponent with
1326 /// the alteration notifier interface of bipartite graphs. It
1327 /// implements an observer-notifier pattern for the red and blue
1328 /// nodes. More obsevers can be registered into the notifier and
1329 /// whenever an alteration occured in the graph all the observers
1330 /// will be notified about it.
1331 template <typename BAS = BaseBpGraphComponent>
1332 class AlterableBpGraphComponent : public AlterableGraphComponent<BAS> {
1336 typedef AlterableGraphComponent<Base> Parent;
1337 typedef typename Base::RedNode RedNode;
1338 typedef typename Base::BlueNode BlueNode;
1341 /// Red node alteration notifier class.
1342 typedef AlterationNotifier<AlterableBpGraphComponent, RedNode>
1345 /// Blue node alteration notifier class.
1346 typedef AlterationNotifier<AlterableBpGraphComponent, BlueNode>
1349 mutable RedNodeNotifier red_node_notifier;
1350 mutable BlueNodeNotifier blue_node_notifier;
1352 using Parent::notifier;
1354 /// \brief Return the red node alteration notifier.
1356 /// This function gives back the red node alteration notifier.
1357 RedNodeNotifier& notifier(RedNode) const {
1358 return red_node_notifier;
1361 /// \brief Return the blue node alteration notifier.
1363 /// This function gives back the blue node alteration notifier.
1364 BlueNodeNotifier& notifier(BlueNode) const {
1365 return blue_node_notifier;
1368 template <typename _BpGraph>
1369 struct Constraints {
1370 void constraints() {
1371 checkConcept<AlterableGraphComponent<Base>, _BpGraph>();
1372 typename _BpGraph::RedNodeNotifier& rnn
1373 = bpgraph.notifier(typename _BpGraph::RedNode());
1374 typename _BpGraph::BlueNodeNotifier& bnn
1375 = bpgraph.notifier(typename _BpGraph::BlueNode());
1376 ignore_unused_variable_warning(rnn);
1377 ignore_unused_variable_warning(bnn);
1380 const _BpGraph& bpgraph;
1384 /// \brief Concept class for standard graph maps.
1386 /// This class describes the concept of standard graph maps, i.e.
1387 /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and
1388 /// graph types, which can be used for associating data to graph items.
1389 /// The standard graph maps must conform to the ReferenceMap concept.
1390 template <typename GR, typename K, typename V>
1391 class GraphMap : public ReferenceMap<K, V, V&, const V&> {
1392 typedef ReferenceMap<K, V, V&, const V&> Parent;
1396 /// The key type of the map.
1398 /// The value type of the map.
1400 /// The reference type of the map.
1401 typedef Value& Reference;
1402 /// The const reference type of the map.
1403 typedef const Value& ConstReference;
1405 // The reference map tag.
1406 typedef True ReferenceMapTag;
1408 /// \brief Construct a new map.
1410 /// Construct a new map for the graph.
1411 explicit GraphMap(const GR&) {}
1412 /// \brief Construct a new map with default value.
1414 /// Construct a new map for the graph and initalize the values.
1415 GraphMap(const GR&, const Value&) {}
1418 /// \brief Copy constructor.
1420 /// Copy Constructor.
1421 GraphMap(const GraphMap&) : Parent() {}
1423 /// \brief Assignment operator.
1425 /// Assignment operator. It does not mofify the underlying graph,
1426 /// it just iterates on the current item set and set the map
1427 /// with the value returned by the assigned map.
1428 template <typename CMap>
1429 GraphMap& operator=(const CMap&) {
1430 checkConcept<ReadMap<Key, Value>, CMap>();
1435 template<typename _Map>
1436 struct Constraints {
1437 void constraints() {
1439 <ReferenceMap<Key, Value, Value&, const Value&>, _Map>();
1446 // Assignment operator
1447 // ReadMap<Key, Value> cmap;
1450 ignore_unused_variable_warning(m1);
1451 ignore_unused_variable_warning(m2);
1452 // ignore_unused_variable_warning(m3);
1457 const typename GraphMap::Value &t;
1463 /// \brief Skeleton class for mappable directed graphs.
1465 /// This class describes the interface of mappable directed graphs.
1466 /// It extends \ref BaseDigraphComponent with the standard digraph
1467 /// map classes, namely \c NodeMap and \c ArcMap.
1468 /// This concept is part of the Digraph concept.
1469 template <typename BAS = BaseDigraphComponent>
1470 class MappableDigraphComponent : public BAS {
1474 typedef typename Base::Node Node;
1475 typedef typename Base::Arc Arc;
1477 typedef MappableDigraphComponent Digraph;
1479 /// \brief Standard graph map for the nodes.
1481 /// Standard graph map for the nodes.
1482 /// It conforms to the ReferenceMap concept.
1483 template <typename V>
1484 class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
1485 typedef GraphMap<MappableDigraphComponent, Node, V> Parent;
1488 /// \brief Construct a new map.
1490 /// Construct a new map for the digraph.
1491 explicit NodeMap(const MappableDigraphComponent& digraph)
1492 : Parent(digraph) {}
1494 /// \brief Construct a new map with default value.
1496 /// Construct a new map for the digraph and initalize the values.
1497 NodeMap(const MappableDigraphComponent& digraph, const V& value)
1498 : Parent(digraph, value) {}
1501 /// \brief Copy constructor.
1503 /// Copy Constructor.
1504 NodeMap(const NodeMap& nm) : Parent(nm) {}
1506 /// \brief Assignment operator.
1508 /// Assignment operator.
1509 template <typename CMap>
1510 NodeMap& operator=(const CMap&) {
1511 checkConcept<ReadMap<Node, V>, CMap>();
1517 /// \brief Standard graph map for the arcs.
1519 /// Standard graph map for the arcs.
1520 /// It conforms to the ReferenceMap concept.
1521 template <typename V>
1522 class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
1523 typedef GraphMap<MappableDigraphComponent, Arc, V> Parent;
1526 /// \brief Construct a new map.
1528 /// Construct a new map for the digraph.
1529 explicit ArcMap(const MappableDigraphComponent& digraph)
1530 : Parent(digraph) {}
1532 /// \brief Construct a new map with default value.
1534 /// Construct a new map for the digraph and initalize the values.
1535 ArcMap(const MappableDigraphComponent& digraph, const V& value)
1536 : Parent(digraph, value) {}
1539 /// \brief Copy constructor.
1541 /// Copy Constructor.
1542 ArcMap(const ArcMap& nm) : Parent(nm) {}
1544 /// \brief Assignment operator.
1546 /// Assignment operator.
1547 template <typename CMap>
1548 ArcMap& operator=(const CMap&) {
1549 checkConcept<ReadMap<Arc, V>, CMap>();
1556 template <typename _Digraph>
1557 struct Constraints {
1561 Dummy() : value(0) {}
1562 Dummy(int _v) : value(_v) {}
1565 void constraints() {
1566 checkConcept<Base, _Digraph>();
1568 typedef typename _Digraph::template NodeMap<int> IntNodeMap;
1569 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, int>,
1571 } { // bool map test
1572 typedef typename _Digraph::template NodeMap<bool> BoolNodeMap;
1573 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, bool>,
1575 } { // Dummy map test
1576 typedef typename _Digraph::template NodeMap<Dummy> DummyNodeMap;
1577 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, Dummy>,
1582 typedef typename _Digraph::template ArcMap<int> IntArcMap;
1583 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, int>,
1585 } { // bool map test
1586 typedef typename _Digraph::template ArcMap<bool> BoolArcMap;
1587 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, bool>,
1589 } { // Dummy map test
1590 typedef typename _Digraph::template ArcMap<Dummy> DummyArcMap;
1591 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, Dummy>,
1596 const _Digraph& digraph;
1601 /// \brief Skeleton class for mappable undirected graphs.
1603 /// This class describes the interface of mappable undirected graphs.
1604 /// It extends \ref MappableDigraphComponent with the standard graph
1605 /// map class for edges (\c EdgeMap).
1606 /// This concept is part of the Graph concept.
1607 template <typename BAS = BaseGraphComponent>
1608 class MappableGraphComponent : public MappableDigraphComponent<BAS> {
1612 typedef typename Base::Edge Edge;
1614 typedef MappableGraphComponent Graph;
1616 /// \brief Standard graph map for the edges.
1618 /// Standard graph map for the edges.
1619 /// It conforms to the ReferenceMap concept.
1620 template <typename V>
1621 class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
1622 typedef GraphMap<MappableGraphComponent, Edge, V> Parent;
1625 /// \brief Construct a new map.
1627 /// Construct a new map for the graph.
1628 explicit EdgeMap(const MappableGraphComponent& graph)
1631 /// \brief Construct a new map with default value.
1633 /// Construct a new map for the graph and initalize the values.
1634 EdgeMap(const MappableGraphComponent& graph, const V& value)
1635 : Parent(graph, value) {}
1638 /// \brief Copy constructor.
1640 /// Copy Constructor.
1641 EdgeMap(const EdgeMap& nm) : Parent(nm) {}
1643 /// \brief Assignment operator.
1645 /// Assignment operator.
1646 template <typename CMap>
1647 EdgeMap& operator=(const CMap&) {
1648 checkConcept<ReadMap<Edge, V>, CMap>();
1655 template <typename _Graph>
1656 struct Constraints {
1660 Dummy() : value(0) {}
1661 Dummy(int _v) : value(_v) {}
1664 void constraints() {
1665 checkConcept<MappableDigraphComponent<Base>, _Graph>();
1668 typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
1669 checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
1671 } { // bool map test
1672 typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
1673 checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
1675 } { // Dummy map test
1676 typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
1677 checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>,
1682 const _Graph& graph;
1687 /// \brief Skeleton class for mappable undirected bipartite graphs.
1689 /// This class describes the interface of mappable undirected
1690 /// bipartite graphs. It extends \ref MappableGraphComponent with
1691 /// the standard graph map class for red and blue nodes (\c
1692 /// RedMap and BlueMap). This concept is part of the BpGraph concept.
1693 template <typename BAS = BaseBpGraphComponent>
1694 class MappableBpGraphComponent : public MappableGraphComponent<BAS> {
1698 typedef typename Base::Node Node;
1700 typedef MappableBpGraphComponent BpGraph;
1702 /// \brief Standard graph map for the red nodes.
1704 /// Standard graph map for the red nodes.
1705 /// It conforms to the ReferenceMap concept.
1706 template <typename V>
1707 class RedMap : public GraphMap<MappableBpGraphComponent, Node, V> {
1708 typedef GraphMap<MappableBpGraphComponent, Node, V> Parent;
1711 /// \brief Construct a new map.
1713 /// Construct a new map for the graph.
1714 explicit RedMap(const MappableBpGraphComponent& graph)
1717 /// \brief Construct a new map with default value.
1719 /// Construct a new map for the graph and initalize the values.
1720 RedMap(const MappableBpGraphComponent& graph, const V& value)
1721 : Parent(graph, value) {}
1724 /// \brief Copy constructor.
1726 /// Copy Constructor.
1727 RedMap(const RedMap& nm) : Parent(nm) {}
1729 /// \brief Assignment operator.
1731 /// Assignment operator.
1732 template <typename CMap>
1733 RedMap& operator=(const CMap&) {
1734 checkConcept<ReadMap<Node, V>, CMap>();
1740 /// \brief Standard graph map for the blue nodes.
1742 /// Standard graph map for the blue nodes.
1743 /// It conforms to the ReferenceMap concept.
1744 template <typename V>
1745 class BlueMap : public GraphMap<MappableBpGraphComponent, Node, V> {
1746 typedef GraphMap<MappableBpGraphComponent, Node, V> Parent;
1749 /// \brief Construct a new map.
1751 /// Construct a new map for the graph.
1752 explicit BlueMap(const MappableBpGraphComponent& graph)
1755 /// \brief Construct a new map with default value.
1757 /// Construct a new map for the graph and initalize the values.
1758 BlueMap(const MappableBpGraphComponent& graph, const V& value)
1759 : Parent(graph, value) {}
1762 /// \brief Copy constructor.
1764 /// Copy Constructor.
1765 BlueMap(const BlueMap& nm) : Parent(nm) {}
1767 /// \brief Assignment operator.
1769 /// Assignment operator.
1770 template <typename CMap>
1771 BlueMap& operator=(const CMap&) {
1772 checkConcept<ReadMap<Node, V>, CMap>();
1779 template <typename _BpGraph>
1780 struct Constraints {
1784 Dummy() : value(0) {}
1785 Dummy(int _v) : value(_v) {}
1788 void constraints() {
1789 checkConcept<MappableGraphComponent<Base>, _BpGraph>();
1792 typedef typename _BpGraph::template RedMap<int> IntRedMap;
1793 checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, int>,
1795 } { // bool map test
1796 typedef typename _BpGraph::template RedMap<bool> BoolRedMap;
1797 checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, bool>,
1799 } { // Dummy map test
1800 typedef typename _BpGraph::template RedMap<Dummy> DummyRedMap;
1801 checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, Dummy>,
1806 typedef typename _BpGraph::template BlueMap<int> IntBlueMap;
1807 checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, int>,
1809 } { // bool map test
1810 typedef typename _BpGraph::template BlueMap<bool> BoolBlueMap;
1811 checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, bool>,
1813 } { // Dummy map test
1814 typedef typename _BpGraph::template BlueMap<Dummy> DummyBlueMap;
1815 checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, Dummy>,
1820 const _BpGraph& bpgraph;
1824 /// \brief Skeleton class for extendable directed graphs.
1826 /// This class describes the interface of extendable directed graphs.
1827 /// It extends \ref BaseDigraphComponent with functions for adding
1828 /// nodes and arcs to the digraph.
1829 /// This concept requires \ref AlterableDigraphComponent.
1830 template <typename BAS = BaseDigraphComponent>
1831 class ExtendableDigraphComponent : public BAS {
1835 typedef typename Base::Node Node;
1836 typedef typename Base::Arc Arc;
1838 /// \brief Add a new node to the digraph.
1840 /// This function adds a new node to the digraph.
1845 /// \brief Add a new arc connecting the given two nodes.
1847 /// This function adds a new arc connecting the given two nodes
1849 Arc addArc(const Node&, const Node&) {
1853 template <typename _Digraph>
1854 struct Constraints {
1855 void constraints() {
1856 checkConcept<Base, _Digraph>();
1857 typename _Digraph::Node node_a, node_b;
1858 node_a = digraph.addNode();
1859 node_b = digraph.addNode();
1860 typename _Digraph::Arc arc;
1861 arc = digraph.addArc(node_a, node_b);
1869 /// \brief Skeleton class for extendable undirected graphs.
1871 /// This class describes the interface of extendable undirected graphs.
1872 /// It extends \ref BaseGraphComponent with functions for adding
1873 /// nodes and edges to the graph.
1874 /// This concept requires \ref AlterableGraphComponent.
1875 template <typename BAS = BaseGraphComponent>
1876 class ExtendableGraphComponent : public BAS {
1880 typedef typename Base::Node Node;
1881 typedef typename Base::Edge Edge;
1883 /// \brief Add a new node to the digraph.
1885 /// This function adds a new node to the digraph.
1890 /// \brief Add a new edge connecting the given two nodes.
1892 /// This function adds a new edge connecting the given two nodes
1894 Edge addEdge(const Node&, const Node&) {
1898 template <typename _Graph>
1899 struct Constraints {
1900 void constraints() {
1901 checkConcept<Base, _Graph>();
1902 typename _Graph::Node node_a, node_b;
1903 node_a = graph.addNode();
1904 node_b = graph.addNode();
1905 typename _Graph::Edge edge;
1906 edge = graph.addEdge(node_a, node_b);
1914 /// \brief Skeleton class for extendable undirected bipartite graphs.
1916 /// This class describes the interface of extendable undirected
1917 /// bipartite graphs. It extends \ref BaseGraphComponent with
1918 /// functions for adding nodes and edges to the graph. This
1919 /// concept requires \ref AlterableBpGraphComponent.
1920 template <typename BAS = BaseBpGraphComponent>
1921 class ExtendableBpGraphComponent : public BAS {
1925 typedef typename Base::Node Node;
1926 typedef typename Base::Edge Edge;
1928 /// \brief Add a new red node to the digraph.
1930 /// This function adds a red new node to the digraph.
1935 /// \brief Add a new blue node to the digraph.
1937 /// This function adds a blue new node to the digraph.
1938 Node addBlueNode() {
1942 /// \brief Add a new edge connecting the given two nodes.
1944 /// This function adds a new edge connecting the given two nodes
1945 /// of the graph. The first node has to be a red node, and the
1946 /// second one a blue node.
1947 Edge addEdge(const Node&, const Node&) {
1951 template <typename _BpGraph>
1952 struct Constraints {
1953 void constraints() {
1954 checkConcept<Base, _BpGraph>();
1955 typename _BpGraph::Node red_node, blue_node;
1956 red_node = bpgraph.addRedNode();
1957 blue_node = bpgraph.addBlueNode();
1958 typename _BpGraph::Edge edge;
1959 edge = bpgraph.addEdge(red_node, blue_node);
1966 /// \brief Skeleton class for erasable directed graphs.
1968 /// This class describes the interface of erasable directed graphs.
1969 /// It extends \ref BaseDigraphComponent with functions for removing
1970 /// nodes and arcs from the digraph.
1971 /// This concept requires \ref AlterableDigraphComponent.
1972 template <typename BAS = BaseDigraphComponent>
1973 class ErasableDigraphComponent : public BAS {
1977 typedef typename Base::Node Node;
1978 typedef typename Base::Arc Arc;
1980 /// \brief Erase a node from the digraph.
1982 /// This function erases the given node from the digraph and all arcs
1983 /// connected to the node.
1984 void erase(const Node&) {}
1986 /// \brief Erase an arc from the digraph.
1988 /// This function erases the given arc from the digraph.
1989 void erase(const Arc&) {}
1991 template <typename _Digraph>
1992 struct Constraints {
1993 void constraints() {
1994 checkConcept<Base, _Digraph>();
1995 const typename _Digraph::Node node(INVALID);
1996 digraph.erase(node);
1997 const typename _Digraph::Arc arc(INVALID);
2006 /// \brief Skeleton class for erasable undirected graphs.
2008 /// This class describes the interface of erasable undirected graphs.
2009 /// It extends \ref BaseGraphComponent with functions for removing
2010 /// nodes and edges from the graph.
2011 /// This concept requires \ref AlterableGraphComponent.
2012 template <typename BAS = BaseGraphComponent>
2013 class ErasableGraphComponent : public BAS {
2017 typedef typename Base::Node Node;
2018 typedef typename Base::Edge Edge;
2020 /// \brief Erase a node from the graph.
2022 /// This function erases the given node from the graph and all edges
2023 /// connected to the node.
2024 void erase(const Node&) {}
2026 /// \brief Erase an edge from the digraph.
2028 /// This function erases the given edge from the digraph.
2029 void erase(const Edge&) {}
2031 template <typename _Graph>
2032 struct Constraints {
2033 void constraints() {
2034 checkConcept<Base, _Graph>();
2035 const typename _Graph::Node node(INVALID);
2037 const typename _Graph::Edge edge(INVALID);
2046 /// \brief Skeleton class for erasable undirected graphs.
2048 /// This class describes the interface of erasable undirected
2049 /// bipartite graphs. It extends \ref BaseBpGraphComponent with
2050 /// functions for removing nodes and edges from the graph. This
2051 /// concept requires \ref AlterableBpGraphComponent.
2052 template <typename BAS = BaseBpGraphComponent>
2053 class ErasableBpGraphComponent : public ErasableGraphComponent<BAS> {};
2055 /// \brief Skeleton class for clearable directed graphs.
2057 /// This class describes the interface of clearable directed graphs.
2058 /// It extends \ref BaseDigraphComponent with a function for clearing
2060 /// This concept requires \ref AlterableDigraphComponent.
2061 template <typename BAS = BaseDigraphComponent>
2062 class ClearableDigraphComponent : public BAS {
2067 /// \brief Erase all nodes and arcs from the digraph.
2069 /// This function erases all nodes and arcs from the digraph.
2072 template <typename _Digraph>
2073 struct Constraints {
2074 void constraints() {
2075 checkConcept<Base, _Digraph>();
2084 /// \brief Skeleton class for clearable undirected graphs.
2086 /// This class describes the interface of clearable undirected graphs.
2087 /// It extends \ref BaseGraphComponent with a function for clearing
2089 /// This concept requires \ref AlterableGraphComponent.
2090 template <typename BAS = BaseGraphComponent>
2091 class ClearableGraphComponent : public ClearableDigraphComponent<BAS> {};
2093 /// \brief Skeleton class for clearable undirected biparite graphs.
2095 /// This class describes the interface of clearable undirected
2096 /// bipartite graphs. It extends \ref BaseBpGraphComponent with a
2097 /// function for clearing the graph. This concept requires \ref
2098 /// AlterableBpGraphComponent.
2099 template <typename BAS = BaseBpGraphComponent>
2100 class ClearableBpGraphComponent : public ClearableGraphComponent<BAS> {};