Fix bug caused by m4 consuming pairs of square brackets (#108).
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 ///\ingroup graph_concepts
21 ///\brief The concept of graph components.
24 #ifndef LEMON_CONCEPT_GRAPH_COMPONENTS_H
25 #define LEMON_CONCEPT_GRAPH_COMPONENTS_H
27 #include <lemon/bits/invalid.h>
28 #include <lemon/concepts/maps.h>
30 #include <lemon/bits/alteration_notifier.h>
35 /// \brief Skeleton class for graph Node and Arc types
37 /// This class describes the interface of Node and Arc (and Edge
38 /// in undirected graphs) subtypes of graph types.
40 /// \note This class is a template class so that we can use it to
41 /// create graph skeleton classes. The reason for this is than Node
42 /// and Arc types should \em not derive from the same base class.
43 /// For Node you should instantiate it with character 'n' and for Arc
47 template <char _selector = '0'>
51 /// \brief Default constructor.
53 /// \warning The default constructor is not required to set
54 /// the item to some well-defined value. So you should consider it
57 /// \brief Copy constructor.
61 GraphItem(const GraphItem &) {}
62 /// \brief Invalid constructor \& conversion.
64 /// This constructor initializes the item to be invalid.
65 /// \sa Invalid for more details.
67 /// \brief Assign operator for nodes.
69 /// The nodes are assignable.
71 GraphItem& operator=(GraphItem const&) { return *this; }
72 /// \brief Equality operator.
74 /// Two iterators are equal if and only if they represents the
75 /// same node in the graph or both are invalid.
76 bool operator==(GraphItem) const { return false; }
77 /// \brief Inequality operator.
79 /// \sa operator==(const Node& n)
81 bool operator!=(GraphItem) const { return false; }
83 /// \brief Artificial ordering operator.
85 /// To allow the use of graph descriptors as key type in std::map or
86 /// similar associative container we require this.
88 /// \note This operator only have to define some strict ordering of
89 /// the items; this order has nothing to do with the iteration
90 /// ordering of the items.
91 bool operator<(GraphItem) const { return false; }
93 template<typename _GraphItem>
98 _GraphItem i3 = INVALID;
103 // b = (ia == ib) && (ia != ib) && (ia < ib);
104 b = (ia == ib) && (ia != ib);
105 b = (ia == INVALID) && (ib != INVALID);
109 const _GraphItem &ia;
110 const _GraphItem &ib;
114 /// \brief An empty base directed graph class.
116 /// This class provides the minimal set of features needed for a
117 /// directed graph structure. All digraph concepts have to be
118 /// conform to this base directed graph. It just provides types
119 /// for nodes and arcs and functions to get the source and the
120 /// target of the arcs.
121 class BaseDigraphComponent {
124 typedef BaseDigraphComponent Digraph;
126 /// \brief Node class of the digraph.
128 /// This class represents the Nodes of the digraph.
130 typedef GraphItem<'n'> Node;
132 /// \brief Arc class of the digraph.
134 /// This class represents the Arcs of the digraph.
136 typedef GraphItem<'e'> Arc;
138 /// \brief Gives back the target node of an arc.
140 /// Gives back the target node of an arc.
142 Node target(const Arc&) const { return INVALID;}
144 /// \brief Gives back the source node of an arc.
146 /// Gives back the source node of an arc.
148 Node source(const Arc&) const { return INVALID;}
150 /// \brief Gives back the opposite node on the given arc.
152 /// Gives back the opposite node on the given arc.
153 Node oppositeNode(const Node&, const Arc&) const {
157 template <typename _Digraph>
159 typedef typename _Digraph::Node Node;
160 typedef typename _Digraph::Arc Arc;
163 checkConcept<GraphItem<'n'>, Node>();
164 checkConcept<GraphItem<'a'>, Arc>();
168 n = digraph.source(e);
169 n = digraph.target(e);
170 n = digraph.oppositeNode(n, e);
174 const _Digraph& digraph;
178 /// \brief An empty base undirected graph class.
180 /// This class provides the minimal set of features needed for an
181 /// undirected graph structure. All undirected graph concepts have
182 /// to be conform to this base graph. It just provides types for
183 /// nodes, arcs and edges and functions to get the
184 /// source and the target of the arcs and edges,
185 /// conversion from arcs to edges and function to get
186 /// both direction of the edges.
187 class BaseGraphComponent : public BaseDigraphComponent {
189 typedef BaseDigraphComponent::Node Node;
190 typedef BaseDigraphComponent::Arc Arc;
191 /// \brief Undirected arc class of the graph.
193 /// This class represents the edges of the graph.
194 /// The undirected graphs can be used as a directed graph which
195 /// for each arc contains the opposite arc too so the graph is
196 /// bidirected. The edge represents two opposite
198 class Edge : public GraphItem<'u'> {
200 typedef GraphItem<'u'> Parent;
201 /// \brief Default constructor.
203 /// \warning The default constructor is not required to set
204 /// the item to some well-defined value. So you should consider it
205 /// as uninitialized.
207 /// \brief Copy constructor.
209 /// Copy constructor.
211 Edge(const Edge &) : Parent() {}
212 /// \brief Invalid constructor \& conversion.
214 /// This constructor initializes the item to be invalid.
215 /// \sa Invalid for more details.
217 /// \brief Converter from arc to edge.
219 /// Besides the core graph item functionality each arc should
220 /// be convertible to the represented edge.
222 /// \brief Assign arc to edge.
224 /// Besides the core graph item functionality each arc should
225 /// be convertible to the represented edge.
226 Edge& operator=(const Arc&) { return *this; }
229 /// \brief Returns the direction of the arc.
231 /// Returns the direction of the arc. Each arc represents an
232 /// edge with a direction. It gives back the
234 bool direction(const Arc&) const { return true; }
236 /// \brief Returns the directed arc.
238 /// Returns the directed arc from its direction and the
239 /// represented edge.
240 Arc direct(const Edge&, bool) const { return INVALID;}
242 /// \brief Returns the directed arc.
244 /// Returns the directed arc from its source and the
245 /// represented edge.
246 Arc direct(const Edge&, const Node&) const { return INVALID;}
248 /// \brief Returns the opposite arc.
250 /// Returns the opposite arc. It is the arc representing the
251 /// same edge and has opposite direction.
252 Arc oppositeArc(const Arc&) const { return INVALID;}
254 /// \brief Gives back one ending of an edge.
256 /// Gives back one ending of an edge.
257 Node u(const Edge&) const { return INVALID;}
259 /// \brief Gives back the other ending of an edge.
261 /// Gives back the other ending of an edge.
262 Node v(const Edge&) const { return INVALID;}
264 template <typename _Graph>
266 typedef typename _Graph::Node Node;
267 typedef typename _Graph::Arc Arc;
268 typedef typename _Graph::Edge Edge;
271 checkConcept<BaseDigraphComponent, _Graph>();
272 checkConcept<GraphItem<'u'>, Edge>();
279 e = graph.direct(ue, true);
280 e = graph.direct(ue, n);
281 e = graph.oppositeArc(e);
283 bool d = graph.direction(e);
284 ignore_unused_variable_warning(d);
293 /// \brief An empty idable base digraph class.
295 /// This class provides beside the core digraph features
296 /// core id functions for the digraph structure.
297 /// The most of the base digraphs should be conform to this concept.
298 /// The id's are unique and immutable.
299 template <typename _Base = BaseDigraphComponent>
300 class IDableDigraphComponent : public _Base {
304 typedef typename Base::Node Node;
305 typedef typename Base::Arc Arc;
307 /// \brief Gives back an unique integer id for the Node.
309 /// Gives back an unique integer id for the Node.
311 int id(const Node&) const { return -1;}
313 /// \brief Gives back the node by the unique id.
315 /// Gives back the node by the unique id.
316 /// If the digraph does not contain node with the given id
317 /// then the result of the function is undetermined.
318 Node nodeFromId(int) const { return INVALID;}
320 /// \brief Gives back an unique integer id for the Arc.
322 /// Gives back an unique integer id for the Arc.
324 int id(const Arc&) const { return -1;}
326 /// \brief Gives back the arc by the unique id.
328 /// Gives back the arc by the unique id.
329 /// If the digraph does not contain arc with the given id
330 /// then the result of the function is undetermined.
331 Arc arcFromId(int) const { return INVALID;}
333 /// \brief Gives back an integer greater or equal to the maximum
336 /// Gives back an integer greater or equal to the maximum Node
338 int maxNodeId() const { return -1;}
340 /// \brief Gives back an integer greater or equal to the maximum
343 /// Gives back an integer greater or equal to the maximum Arc
345 int maxArcId() const { return -1;}
347 template <typename _Digraph>
351 checkConcept<Base, _Digraph >();
352 typename _Digraph::Node node;
353 int nid = digraph.id(node);
354 nid = digraph.id(node);
355 node = digraph.nodeFromId(nid);
356 typename _Digraph::Arc arc;
357 int eid = digraph.id(arc);
358 eid = digraph.id(arc);
359 arc = digraph.arcFromId(eid);
361 nid = digraph.maxNodeId();
362 ignore_unused_variable_warning(nid);
363 eid = digraph.maxArcId();
364 ignore_unused_variable_warning(eid);
367 const _Digraph& digraph;
371 /// \brief An empty idable base undirected graph class.
373 /// This class provides beside the core undirected graph features
374 /// core id functions for the undirected graph structure. The
375 /// most of the base undirected graphs should be conform to this
376 /// concept. The id's are unique and immutable.
377 template <typename _Base = BaseGraphComponent>
378 class IDableGraphComponent : public IDableDigraphComponent<_Base> {
382 typedef typename Base::Edge Edge;
384 using IDableDigraphComponent<_Base>::id;
386 /// \brief Gives back an unique integer id for the Edge.
388 /// Gives back an unique integer id for the Edge.
390 int id(const Edge&) const { return -1;}
392 /// \brief Gives back the edge by the unique id.
394 /// Gives back the edge by the unique id. If the
395 /// graph does not contain arc with the given id then the
396 /// result of the function is undetermined.
397 Edge edgeFromId(int) const { return INVALID;}
399 /// \brief Gives back an integer greater or equal to the maximum
402 /// Gives back an integer greater or equal to the maximum Edge
404 int maxEdgeId() const { return -1;}
406 template <typename _Graph>
410 checkConcept<Base, _Graph >();
411 checkConcept<IDableDigraphComponent<Base>, _Graph >();
412 typename _Graph::Edge edge;
413 int ueid = graph.id(edge);
414 ueid = graph.id(edge);
415 edge = graph.edgeFromId(ueid);
416 ueid = graph.maxEdgeId();
417 ignore_unused_variable_warning(ueid);
424 /// \brief Skeleton class for graph NodeIt and ArcIt
426 /// Skeleton class for graph NodeIt and ArcIt.
428 template <typename _Graph, typename _Item>
429 class GraphItemIt : public _Item {
431 /// \brief Default constructor.
433 /// @warning The default constructor sets the iterator
434 /// to an undefined value.
436 /// \brief Copy constructor.
438 /// Copy constructor.
440 GraphItemIt(const GraphItemIt& ) {}
441 /// \brief Sets the iterator to the first item.
443 /// Sets the iterator to the first item of \c the graph.
445 explicit GraphItemIt(const _Graph&) {}
446 /// \brief Invalid constructor \& conversion.
448 /// This constructor initializes the item to be invalid.
449 /// \sa Invalid for more details.
450 GraphItemIt(Invalid) {}
451 /// \brief Assign operator for items.
453 /// The items are assignable.
455 GraphItemIt& operator=(const GraphItemIt&) { return *this; }
456 /// \brief Next item.
458 /// Assign the iterator to the next item.
460 GraphItemIt& operator++() { return *this; }
461 /// \brief Equality operator
463 /// Two iterators are equal if and only if they point to the
464 /// same object or both are invalid.
465 bool operator==(const GraphItemIt&) const { return true;}
466 /// \brief Inequality operator
468 /// \sa operator==(Node n)
470 bool operator!=(const GraphItemIt&) const { return true;}
472 template<typename _GraphItemIt>
489 /// \brief Skeleton class for graph InArcIt and OutArcIt
491 /// \note Because InArcIt and OutArcIt may not inherit from the same
492 /// base class, the _selector is a additional template parameter. For
493 /// InArcIt you should instantiate it with character 'i' and for
494 /// OutArcIt with 'o'.
495 template <typename _Graph,
496 typename _Item = typename _Graph::Arc,
497 typename _Base = typename _Graph::Node,
498 char _selector = '0'>
499 class GraphIncIt : public _Item {
501 /// \brief Default constructor.
503 /// @warning The default constructor sets the iterator
504 /// to an undefined value.
506 /// \brief Copy constructor.
508 /// Copy constructor.
510 GraphIncIt(GraphIncIt const& gi) : _Item(gi) {}
511 /// \brief Sets the iterator to the first arc incoming into or outgoing
514 /// Sets the iterator to the first arc incoming into or outgoing
517 explicit GraphIncIt(const _Graph&, const _Base&) {}
518 /// \brief Invalid constructor \& conversion.
520 /// This constructor initializes the item to be invalid.
521 /// \sa Invalid for more details.
522 GraphIncIt(Invalid) {}
523 /// \brief Assign operator for iterators.
525 /// The iterators are assignable.
527 GraphIncIt& operator=(GraphIncIt const&) { return *this; }
528 /// \brief Next item.
530 /// Assign the iterator to the next item.
532 GraphIncIt& operator++() { return *this; }
534 /// \brief Equality operator
536 /// Two iterators are equal if and only if they point to the
537 /// same object or both are invalid.
538 bool operator==(const GraphIncIt&) const { return true;}
540 /// \brief Inequality operator
542 /// \sa operator==(Node n)
544 bool operator!=(const GraphIncIt&) const { return true;}
546 template <typename _GraphIncIt>
549 checkConcept<GraphItem<_selector>, _GraphIncIt>();
550 _GraphIncIt it1(graph, node);
569 /// \brief An empty iterable digraph class.
571 /// This class provides beside the core digraph features
572 /// iterator based iterable interface for the digraph structure.
573 /// This concept is part of the Digraph concept.
574 template <typename _Base = BaseDigraphComponent>
575 class IterableDigraphComponent : public _Base {
580 typedef typename Base::Node Node;
581 typedef typename Base::Arc Arc;
583 typedef IterableDigraphComponent Digraph;
585 /// \name Base iteration
587 /// This interface provides functions for iteration on digraph items
591 /// \brief Gives back the first node in the iterating order.
593 /// Gives back the first node in the iterating order.
595 void first(Node&) const {}
597 /// \brief Gives back the next node in the iterating order.
599 /// Gives back the next node in the iterating order.
601 void next(Node&) const {}
603 /// \brief Gives back the first arc in the iterating order.
605 /// Gives back the first arc in the iterating order.
607 void first(Arc&) const {}
609 /// \brief Gives back the next arc in the iterating order.
611 /// Gives back the next arc in the iterating order.
613 void next(Arc&) const {}
616 /// \brief Gives back the first of the arcs point to the given
619 /// Gives back the first of the arcs point to the given node.
621 void firstIn(Arc&, const Node&) const {}
623 /// \brief Gives back the next of the arcs points to the given
626 /// Gives back the next of the arcs points to the given node.
628 void nextIn(Arc&) const {}
630 /// \brief Gives back the first of the arcs start from the
633 /// Gives back the first of the arcs start from the given node.
635 void firstOut(Arc&, const Node&) const {}
637 /// \brief Gives back the next of the arcs start from the given
640 /// Gives back the next of the arcs start from the given node.
642 void nextOut(Arc&) const {}
646 /// \name Class based iteration
648 /// This interface provides functions for iteration on digraph items
652 /// \brief This iterator goes through each node.
654 /// This iterator goes through each node.
656 typedef GraphItemIt<Digraph, Node> NodeIt;
658 /// \brief This iterator goes through each node.
660 /// This iterator goes through each node.
662 typedef GraphItemIt<Digraph, Arc> ArcIt;
664 /// \brief This iterator goes trough the incoming arcs of a node.
666 /// This iterator goes trough the \e inccoming arcs of a certain node
668 typedef GraphIncIt<Digraph, Arc, Node, 'i'> InArcIt;
670 /// \brief This iterator goes trough the outgoing arcs of a node.
672 /// This iterator goes trough the \e outgoing arcs of a certain node
674 typedef GraphIncIt<Digraph, Arc, Node, 'o'> OutArcIt;
676 /// \brief The base node of the iterator.
678 /// Gives back the base node of the iterator.
679 /// It is always the target of the pointed arc.
680 Node baseNode(const InArcIt&) const { return INVALID; }
682 /// \brief The running node of the iterator.
684 /// Gives back the running node of the iterator.
685 /// It is always the source of the pointed arc.
686 Node runningNode(const InArcIt&) const { return INVALID; }
688 /// \brief The base node of the iterator.
690 /// Gives back the base node of the iterator.
691 /// It is always the source of the pointed arc.
692 Node baseNode(const OutArcIt&) const { return INVALID; }
694 /// \brief The running node of the iterator.
696 /// Gives back the running node of the iterator.
697 /// It is always the target of the pointed arc.
698 Node runningNode(const OutArcIt&) const { return INVALID; }
702 template <typename _Digraph>
705 checkConcept<Base, _Digraph>();
708 typename _Digraph::Node node(INVALID);
709 typename _Digraph::Arc arc(INVALID);
719 digraph.firstIn(arc, node);
723 digraph.firstOut(arc, node);
724 digraph.nextOut(arc);
729 checkConcept<GraphItemIt<_Digraph, typename _Digraph::Arc>,
730 typename _Digraph::ArcIt >();
731 checkConcept<GraphItemIt<_Digraph, typename _Digraph::Node>,
732 typename _Digraph::NodeIt >();
733 checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
734 typename _Digraph::Node, 'i'>, typename _Digraph::InArcIt>();
735 checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
736 typename _Digraph::Node, 'o'>, typename _Digraph::OutArcIt>();
738 typename _Digraph::Node n;
739 typename _Digraph::InArcIt ieit(INVALID);
740 typename _Digraph::OutArcIt oeit(INVALID);
741 n = digraph.baseNode(ieit);
742 n = digraph.runningNode(ieit);
743 n = digraph.baseNode(oeit);
744 n = digraph.runningNode(oeit);
745 ignore_unused_variable_warning(n);
749 const _Digraph& digraph;
754 /// \brief An empty iterable undirected graph class.
756 /// This class provides beside the core graph features iterator
757 /// based iterable interface for the undirected graph structure.
758 /// This concept is part of the Graph concept.
759 template <typename _Base = BaseGraphComponent>
760 class IterableGraphComponent : public IterableDigraphComponent<_Base> {
764 typedef typename Base::Node Node;
765 typedef typename Base::Arc Arc;
766 typedef typename Base::Edge Edge;
769 typedef IterableGraphComponent Graph;
771 /// \name Base iteration
773 /// This interface provides functions for iteration on graph items
776 using IterableDigraphComponent<_Base>::first;
777 using IterableDigraphComponent<_Base>::next;
779 /// \brief Gives back the first edge in the iterating
782 /// Gives back the first edge in the iterating order.
784 void first(Edge&) const {}
786 /// \brief Gives back the next edge in the iterating
789 /// Gives back the next edge in the iterating order.
791 void next(Edge&) const {}
794 /// \brief Gives back the first of the edges from the
797 /// Gives back the first of the edges from the given
798 /// node. The bool parameter gives back that direction which
799 /// gives a good direction of the edge so the source of the
800 /// directed arc is the given node.
801 void firstInc(Edge&, bool&, const Node&) const {}
803 /// \brief Gives back the next of the edges from the
806 /// Gives back the next of the edges from the given
807 /// node. The bool parameter should be used as the \c firstInc()
809 void nextInc(Edge&, bool&) const {}
811 using IterableDigraphComponent<_Base>::baseNode;
812 using IterableDigraphComponent<_Base>::runningNode;
816 /// \name Class based iteration
818 /// This interface provides functions for iteration on graph items
822 /// \brief This iterator goes through each node.
824 /// This iterator goes through each node.
825 typedef GraphItemIt<Graph, Edge> EdgeIt;
826 /// \brief This iterator goes trough the incident arcs of a
829 /// This iterator goes trough the incident arcs of a certain
831 typedef GraphIncIt<Graph, Edge, Node, 'u'> IncEdgeIt;
832 /// \brief The base node of the iterator.
834 /// Gives back the base node of the iterator.
835 Node baseNode(const IncEdgeIt&) const { return INVALID; }
837 /// \brief The running node of the iterator.
839 /// Gives back the running node of the iterator.
840 Node runningNode(const IncEdgeIt&) const { return INVALID; }
844 template <typename _Graph>
847 checkConcept<IterableDigraphComponent<Base>, _Graph>();
850 typename _Graph::Node node(INVALID);
851 typename _Graph::Edge edge(INVALID);
858 graph.firstInc(edge, dir, node);
859 graph.nextInc(edge, dir);
865 checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
866 typename _Graph::EdgeIt >();
867 checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
868 typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
870 typename _Graph::Node n;
871 typename _Graph::IncEdgeIt ueit(INVALID);
872 n = graph.baseNode(ueit);
873 n = graph.runningNode(ueit);
882 /// \brief An empty alteration notifier digraph class.
884 /// This class provides beside the core digraph features alteration
885 /// notifier interface for the digraph structure. This implements
886 /// an observer-notifier pattern for each digraph item. More
887 /// obsevers can be registered into the notifier and whenever an
888 /// alteration occured in the digraph all the observers will
889 /// notified about it.
890 template <typename _Base = BaseDigraphComponent>
891 class AlterableDigraphComponent : public _Base {
895 typedef typename Base::Node Node;
896 typedef typename Base::Arc Arc;
899 /// The node observer registry.
900 typedef AlterationNotifier<AlterableDigraphComponent, Node>
902 /// The arc observer registry.
903 typedef AlterationNotifier<AlterableDigraphComponent, Arc>
906 /// \brief Gives back the node alteration notifier.
908 /// Gives back the node alteration notifier.
909 NodeNotifier& notifier(Node) const {
910 return NodeNotifier();
913 /// \brief Gives back the arc alteration notifier.
915 /// Gives back the arc alteration notifier.
916 ArcNotifier& notifier(Arc) const {
917 return ArcNotifier();
920 template <typename _Digraph>
923 checkConcept<Base, _Digraph>();
924 typename _Digraph::NodeNotifier& nn
925 = digraph.notifier(typename _Digraph::Node());
927 typename _Digraph::ArcNotifier& en
928 = digraph.notifier(typename _Digraph::Arc());
930 ignore_unused_variable_warning(nn);
931 ignore_unused_variable_warning(en);
934 const _Digraph& digraph;
940 /// \brief An empty alteration notifier undirected graph class.
942 /// This class provides beside the core graph features alteration
943 /// notifier interface for the graph structure. This implements
944 /// an observer-notifier pattern for each graph item. More
945 /// obsevers can be registered into the notifier and whenever an
946 /// alteration occured in the graph all the observers will
947 /// notified about it.
948 template <typename _Base = BaseGraphComponent>
949 class AlterableGraphComponent : public AlterableDigraphComponent<_Base> {
953 typedef typename Base::Edge Edge;
956 /// The arc observer registry.
957 typedef AlterationNotifier<AlterableGraphComponent, Edge>
960 /// \brief Gives back the arc alteration notifier.
962 /// Gives back the arc alteration notifier.
963 EdgeNotifier& notifier(Edge) const {
964 return EdgeNotifier();
967 template <typename _Graph>
970 checkConcept<AlterableGraphComponent<Base>, _Graph>();
971 typename _Graph::EdgeNotifier& uen
972 = graph.notifier(typename _Graph::Edge());
973 ignore_unused_variable_warning(uen);
982 /// \brief Class describing the concept of graph maps
984 /// This class describes the common interface of the graph maps
985 /// (NodeMap, ArcMap), that is \ref maps-page "maps" which can be used to
986 /// associate data to graph descriptors (nodes or arcs).
987 template <typename _Graph, typename _Item, typename _Value>
988 class GraphMap : public ReadWriteMap<_Item, _Value> {
991 typedef ReadWriteMap<_Item, _Value> Parent;
993 /// The graph type of the map.
994 typedef _Graph Graph;
995 /// The key type of the map.
997 /// The value type of the map.
998 typedef _Value Value;
1000 /// \brief Construct a new map.
1002 /// Construct a new map for the graph.
1003 explicit GraphMap(const Graph&) {}
1004 /// \brief Construct a new map with default value.
1006 /// Construct a new map for the graph and initalise the values.
1007 GraphMap(const Graph&, const Value&) {}
1008 /// \brief Copy constructor.
1010 /// Copy Constructor.
1011 GraphMap(const GraphMap&) : Parent() {}
1013 /// \brief Assign operator.
1015 /// Assign operator. It does not mofify the underlying graph,
1016 /// it just iterates on the current item set and set the map
1017 /// with the value returned by the assigned map.
1018 template <typename CMap>
1019 GraphMap& operator=(const CMap&) {
1020 checkConcept<ReadMap<Key, Value>, CMap>();
1024 template<typename _Map>
1025 struct Constraints {
1026 void constraints() {
1027 checkConcept<ReadWriteMap<Key, Value>, _Map >();
1028 // Construction with a graph parameter
1030 // Constructor with a graph and a default value parameter
1032 // Copy constructor.
1035 ReadMap<Key, Value> cmap;
1038 ignore_unused_variable_warning(a2);
1039 ignore_unused_variable_warning(b);
1044 const typename GraphMap::Value &t;
1049 /// \brief An empty mappable digraph class.
1051 /// This class provides beside the core digraph features
1052 /// map interface for the digraph structure.
1053 /// This concept is part of the Digraph concept.
1054 template <typename _Base = BaseDigraphComponent>
1055 class MappableDigraphComponent : public _Base {
1059 typedef typename Base::Node Node;
1060 typedef typename Base::Arc Arc;
1062 typedef MappableDigraphComponent Digraph;
1064 /// \brief ReadWrite map of the nodes.
1066 /// ReadWrite map of the nodes.
1068 template <typename _Value>
1069 class NodeMap : public GraphMap<Digraph, Node, _Value> {
1071 typedef GraphMap<MappableDigraphComponent, Node, _Value> Parent;
1073 /// \brief Construct a new map.
1075 /// Construct a new map for the digraph.
1076 explicit NodeMap(const MappableDigraphComponent& digraph)
1077 : Parent(digraph) {}
1079 /// \brief Construct a new map with default value.
1081 /// Construct a new map for the digraph and initalise the values.
1082 NodeMap(const MappableDigraphComponent& digraph, const _Value& value)
1083 : Parent(digraph, value) {}
1085 /// \brief Copy constructor.
1087 /// Copy Constructor.
1088 NodeMap(const NodeMap& nm) : Parent(nm) {}
1090 /// \brief Assign operator.
1092 /// Assign operator.
1093 template <typename CMap>
1094 NodeMap& operator=(const CMap&) {
1095 checkConcept<ReadMap<Node, _Value>, CMap>();
1101 /// \brief ReadWrite map of the arcs.
1103 /// ReadWrite map of the arcs.
1105 template <typename _Value>
1106 class ArcMap : public GraphMap<Digraph, Arc, _Value> {
1108 typedef GraphMap<MappableDigraphComponent, Arc, _Value> Parent;
1110 /// \brief Construct a new map.
1112 /// Construct a new map for the digraph.
1113 explicit ArcMap(const MappableDigraphComponent& digraph)
1114 : Parent(digraph) {}
1116 /// \brief Construct a new map with default value.
1118 /// Construct a new map for the digraph and initalise the values.
1119 ArcMap(const MappableDigraphComponent& digraph, const _Value& value)
1120 : Parent(digraph, value) {}
1122 /// \brief Copy constructor.
1124 /// Copy Constructor.
1125 ArcMap(const ArcMap& nm) : Parent(nm) {}
1127 /// \brief Assign operator.
1129 /// Assign operator.
1130 template <typename CMap>
1131 ArcMap& operator=(const CMap&) {
1132 checkConcept<ReadMap<Arc, _Value>, CMap>();
1139 template <typename _Digraph>
1140 struct Constraints {
1144 Dummy() : value(0) {}
1145 Dummy(int _v) : value(_v) {}
1148 void constraints() {
1149 checkConcept<Base, _Digraph>();
1151 typedef typename _Digraph::template NodeMap<int> IntNodeMap;
1152 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, int>,
1154 } { // bool map test
1155 typedef typename _Digraph::template NodeMap<bool> BoolNodeMap;
1156 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, bool>,
1158 } { // Dummy map test
1159 typedef typename _Digraph::template NodeMap<Dummy> DummyNodeMap;
1160 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, Dummy>,
1165 typedef typename _Digraph::template ArcMap<int> IntArcMap;
1166 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, int>,
1168 } { // bool map test
1169 typedef typename _Digraph::template ArcMap<bool> BoolArcMap;
1170 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, bool>,
1172 } { // Dummy map test
1173 typedef typename _Digraph::template ArcMap<Dummy> DummyArcMap;
1174 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, Dummy>,
1183 /// \brief An empty mappable base bipartite graph class.
1185 /// This class provides beside the core graph features
1186 /// map interface for the graph structure.
1187 /// This concept is part of the Graph concept.
1188 template <typename _Base = BaseGraphComponent>
1189 class MappableGraphComponent : public MappableDigraphComponent<_Base> {
1193 typedef typename Base::Edge Edge;
1195 typedef MappableGraphComponent Graph;
1197 /// \brief ReadWrite map of the edges.
1199 /// ReadWrite map of the edges.
1201 template <typename _Value>
1202 class EdgeMap : public GraphMap<Graph, Edge, _Value> {
1204 typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent;
1206 /// \brief Construct a new map.
1208 /// Construct a new map for the graph.
1209 explicit EdgeMap(const MappableGraphComponent& graph)
1212 /// \brief Construct a new map with default value.
1214 /// Construct a new map for the graph and initalise the values.
1215 EdgeMap(const MappableGraphComponent& graph, const _Value& value)
1216 : Parent(graph, value) {}
1218 /// \brief Copy constructor.
1220 /// Copy Constructor.
1221 EdgeMap(const EdgeMap& nm) : Parent(nm) {}
1223 /// \brief Assign operator.
1225 /// Assign operator.
1226 template <typename CMap>
1227 EdgeMap& operator=(const CMap&) {
1228 checkConcept<ReadMap<Edge, _Value>, CMap>();
1235 template <typename _Graph>
1236 struct Constraints {
1240 Dummy() : value(0) {}
1241 Dummy(int _v) : value(_v) {}
1244 void constraints() {
1245 checkConcept<MappableGraphComponent<Base>, _Graph>();
1248 typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
1249 checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
1251 } { // bool map test
1252 typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
1253 checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
1255 } { // Dummy map test
1256 typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
1257 checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>,
1266 /// \brief An empty extendable digraph class.
1268 /// This class provides beside the core digraph features digraph
1269 /// extendable interface for the digraph structure. The main
1270 /// difference between the base and this interface is that the
1271 /// digraph alterations should handled already on this level.
1272 template <typename _Base = BaseDigraphComponent>
1273 class ExtendableDigraphComponent : public _Base {
1277 typedef typename _Base::Node Node;
1278 typedef typename _Base::Arc Arc;
1280 /// \brief Adds a new node to the digraph.
1282 /// Adds a new node to the digraph.
1288 /// \brief Adds a new arc connects the given two nodes.
1290 /// Adds a new arc connects the the given two nodes.
1291 Arc addArc(const Node&, const Node&) {
1295 template <typename _Digraph>
1296 struct Constraints {
1297 void constraints() {
1298 checkConcept<Base, _Digraph>();
1299 typename _Digraph::Node node_a, node_b;
1300 node_a = digraph.addNode();
1301 node_b = digraph.addNode();
1302 typename _Digraph::Arc arc;
1303 arc = digraph.addArc(node_a, node_b);
1310 /// \brief An empty extendable base undirected graph class.
1312 /// This class provides beside the core undirected graph features
1313 /// core undircted graph extend interface for the graph structure.
1314 /// The main difference between the base and this interface is
1315 /// that the graph alterations should handled already on this
1317 template <typename _Base = BaseGraphComponent>
1318 class ExtendableGraphComponent : public _Base {
1322 typedef typename _Base::Node Node;
1323 typedef typename _Base::Edge Edge;
1325 /// \brief Adds a new node to the graph.
1327 /// Adds a new node to the graph.
1333 /// \brief Adds a new arc connects the given two nodes.
1335 /// Adds a new arc connects the the given two nodes.
1336 Edge addArc(const Node&, const Node&) {
1340 template <typename _Graph>
1341 struct Constraints {
1342 void constraints() {
1343 checkConcept<Base, _Graph>();
1344 typename _Graph::Node node_a, node_b;
1345 node_a = graph.addNode();
1346 node_b = graph.addNode();
1347 typename _Graph::Edge edge;
1348 edge = graph.addEdge(node_a, node_b);
1355 /// \brief An empty erasable digraph class.
1357 /// This class provides beside the core digraph features core erase
1358 /// functions for the digraph structure. The main difference between
1359 /// the base and this interface is that the digraph alterations
1360 /// should handled already on this level.
1361 template <typename _Base = BaseDigraphComponent>
1362 class ErasableDigraphComponent : public _Base {
1366 typedef typename Base::Node Node;
1367 typedef typename Base::Arc Arc;
1369 /// \brief Erase a node from the digraph.
1371 /// Erase a node from the digraph. This function should
1372 /// erase all arcs connecting to the node.
1373 void erase(const Node&) {}
1375 /// \brief Erase an arc from the digraph.
1377 /// Erase an arc from the digraph.
1379 void erase(const Arc&) {}
1381 template <typename _Digraph>
1382 struct Constraints {
1383 void constraints() {
1384 checkConcept<Base, _Digraph>();
1385 typename _Digraph::Node node;
1386 digraph.erase(node);
1387 typename _Digraph::Arc arc;
1395 /// \brief An empty erasable base undirected graph class.
1397 /// This class provides beside the core undirected graph features
1398 /// core erase functions for the undirceted graph structure. The
1399 /// main difference between the base and this interface is that
1400 /// the graph alterations should handled already on this level.
1401 template <typename _Base = BaseGraphComponent>
1402 class ErasableGraphComponent : public _Base {
1406 typedef typename Base::Node Node;
1407 typedef typename Base::Edge Edge;
1409 /// \brief Erase a node from the graph.
1411 /// Erase a node from the graph. This function should erase
1412 /// arcs connecting to the node.
1413 void erase(const Node&) {}
1415 /// \brief Erase an arc from the graph.
1417 /// Erase an arc from the graph.
1419 void erase(const Edge&) {}
1421 template <typename _Graph>
1422 struct Constraints {
1423 void constraints() {
1424 checkConcept<Base, _Graph>();
1425 typename _Graph::Node node;
1427 typename _Graph::Edge edge;
1435 /// \brief An empty clearable base digraph class.
1437 /// This class provides beside the core digraph features core clear
1438 /// functions for the digraph structure. The main difference between
1439 /// the base and this interface is that the digraph alterations
1440 /// should handled already on this level.
1441 template <typename _Base = BaseDigraphComponent>
1442 class ClearableDigraphComponent : public _Base {
1447 /// \brief Erase all nodes and arcs from the digraph.
1449 /// Erase all nodes and arcs from the digraph.
1453 template <typename _Digraph>
1454 struct Constraints {
1455 void constraints() {
1456 checkConcept<Base, _Digraph>();
1464 /// \brief An empty clearable base undirected graph class.
1466 /// This class provides beside the core undirected graph features
1467 /// core clear functions for the undirected graph structure. The
1468 /// main difference between the base and this interface is that
1469 /// the graph alterations should handled already on this level.
1470 template <typename _Base = BaseGraphComponent>
1471 class ClearableGraphComponent : public ClearableDigraphComponent<_Base> {
1476 template <typename _Graph>
1477 struct Constraints {
1478 void constraints() {
1479 checkConcept<ClearableGraphComponent<Base>, _Graph>();