3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
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 the 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/concept/maps.h>
30 #include <lemon/bits/alteration_notifier.h>
35 /// \brief Skeleton class for graph Node and Edge types
37 /// This class describes the interface of Node and Edge (and UEdge
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 Edge types should \em not derive from the same base class.
43 /// For Node you should instantiate it with character 'n' and for Edge
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 graph class.
116 /// This class provides the minimal set of features needed for a graph
117 /// structure. All graph concepts have to be conform to this base
118 /// graph. It just provides types for nodes and edges and functions to
119 /// get the source and the target of the edges.
120 class BaseGraphComponent {
123 typedef BaseGraphComponent Graph;
125 /// \brief Node class of the graph.
127 /// This class represents the Nodes of the graph.
129 typedef GraphItem<'n'> Node;
131 /// \brief Edge class of the graph.
133 /// This class represents the Edges of the graph.
135 typedef GraphItem<'e'> Edge;
137 /// \brief Gives back the target node of an edge.
139 /// Gives back the target node of an edge.
141 Node target(const Edge&) const { return INVALID;}
143 /// \brief Gives back the source node of an edge.
145 /// Gives back the source node of an edge.
147 Node source(const Edge&) const { return INVALID;}
149 /// \brief Gives back the opposite node on the given edge.
151 /// Gives back the opposite node on the given edge.
152 Node oppositeNode(const Node&, const Edge&) const {
156 template <typename _Graph>
158 typedef typename _Graph::Node Node;
159 typedef typename _Graph::Edge Edge;
162 checkConcept<GraphItem<'n'>, Node>();
163 checkConcept<GraphItem<'e'>, Edge>();
169 n = graph.oppositeNode(n, e);
177 /// \brief An empty base undirected graph class.
179 /// This class provides the minimal set of features needed for an
180 /// undirected graph structure. All undirected graph concepts have
181 /// to be conform to this base graph. It just provides types for
182 /// nodes, edges and undirected edges and functions to get the
183 /// source and the target of the edges and undirected edges,
184 /// conversion from edges to undirected edges and function to get
185 /// both direction of the undirected edges.
186 class BaseUGraphComponent : public BaseGraphComponent {
188 typedef BaseGraphComponent::Node Node;
189 typedef BaseGraphComponent::Edge Edge;
190 /// \brief Undirected edge class of the graph.
192 /// This class represents the undirected edges of the graph.
193 /// The undirected graphs can be used as a directed graph which
194 /// for each edge contains the opposite edge too so the graph is
195 /// bidirected. The undirected edge represents two opposite
197 class UEdge : public GraphItem<'u'> {
199 typedef GraphItem<'u'> Parent;
200 /// \brief Default constructor.
202 /// \warning The default constructor is not required to set
203 /// the item to some well-defined value. So you should consider it
204 /// as uninitialized.
206 /// \brief Copy constructor.
208 /// Copy constructor.
210 UEdge(const UEdge &) : Parent() {}
211 /// \brief Invalid constructor \& conversion.
213 /// This constructor initializes the item to be invalid.
214 /// \sa Invalid for more details.
216 /// \brief Converter from edge to undirected edge.
218 /// Besides the core graph item functionality each edge should
219 /// be convertible to the represented undirected edge.
220 UEdge(const Edge&) {}
221 /// \brief Assign edge to undirected edge.
223 /// Besides the core graph item functionality each edge should
224 /// be convertible to the represented undirected edge.
225 UEdge& operator=(const Edge&) { return *this; }
228 /// \brief Returns the direction of the edge.
230 /// Returns the direction of the edge. Each edge represents an
231 /// undirected edge with a direction. It gives back the
233 bool direction(const Edge&) const { return true; }
235 /// \brief Returns the directed edge.
237 /// Returns the directed edge from its direction and the
238 /// represented undirected edge.
239 Edge direct(const UEdge&, bool) const { return INVALID;}
241 /// \brief Returns the directed edge.
243 /// Returns the directed edge from its source and the
244 /// represented undirected edge.
245 Edge direct(const UEdge&, const Node&) const { return INVALID;}
247 /// \brief Returns the opposite edge.
249 /// Returns the opposite edge. It is the edge representing the
250 /// same undirected edge and has opposite direction.
251 Edge oppositeEdge(const Edge&) const { return INVALID;}
253 /// \brief Gives back the target node of an undirected edge.
255 /// Gives back the target node of an undirected edge. The name
256 /// target is a little confusing because the undirected edge
257 /// does not have target but it just means that one of the end
259 Node target(const UEdge&) const { return INVALID;}
261 /// \brief Gives back the source node of an undirected edge.
263 /// Gives back the source node of an undirected edge. The name
264 /// source is a little confusing because the undirected edge
265 /// does not have source but it just means that one of the end
267 Node source(const UEdge&) const { return INVALID;}
269 template <typename _Graph>
271 typedef typename _Graph::Node Node;
272 typedef typename _Graph::Edge Edge;
273 typedef typename _Graph::UEdge UEdge;
276 checkConcept<BaseGraphComponent, _Graph>();
277 checkConcept<GraphItem<'u'>, UEdge>();
282 n = graph.source(ue);
283 n = graph.target(ue);
284 e = graph.direct(ue, true);
285 e = graph.direct(ue, n);
286 e = graph.oppositeEdge(e);
288 bool d = graph.direction(e);
289 ignore_unused_variable_warning(d);
298 /// \brief An empty base bipartite undirected graph class.
300 /// This class provides the minimal set of features needed for an
301 /// bipartite undirected graph structure. All bipartite undirected
302 /// graph concepts have to be conform to this base graph. It just
303 /// provides types for nodes, A-nodes, B-nodes, edges and
304 /// undirected edges and functions to get the source and the
305 /// target of the edges and undirected edges, conversion from
306 /// edges to undirected edges and function to get both direction
307 /// of the undirected edges.
308 class BaseBpUGraphComponent : public BaseUGraphComponent {
310 typedef BaseUGraphComponent::Node Node;
311 typedef BaseUGraphComponent::Edge Edge;
312 typedef BaseUGraphComponent::UEdge UEdge;
314 /// \brief Helper class for A-nodes.
316 /// This class is just a helper class for A-nodes, it is not
317 /// suggested to use it directly. It can be converted easily to
318 /// node and vice versa. The usage of this class is limited
319 /// to use just as template parameters for special map types.
320 class ANode : public Node {
324 /// \brief Default constructor.
326 /// \warning The default constructor is not required to set
327 /// the item to some well-defined value. So you should consider it
328 /// as uninitialized.
330 /// \brief Copy constructor.
332 /// Copy constructor.
334 ANode(const ANode &) : Parent() {}
335 /// \brief Invalid constructor \& conversion.
337 /// This constructor initializes the item to be invalid.
338 /// \sa Invalid for more details.
340 /// \brief Converter from node to A-node.
342 /// Besides the core graph item functionality each node should
343 /// be convertible to the represented A-node if it is it possible.
344 ANode(const Node&) {}
345 /// \brief Assign node to A-node.
347 /// Besides the core graph item functionality each node should
348 /// be convertible to the represented A-node if it is it possible.
349 ANode& operator=(const Node&) { return *this; }
352 /// \brief Helper class for B-nodes.
354 /// This class is just a helper class for B-nodes, it is not
355 /// suggested to use it directly. It can be converted easily to
356 /// node and vice versa. The usage of this class is limited
357 /// to use just as template parameters for special map types.
358 class BNode : public Node {
362 /// \brief Default constructor.
364 /// \warning The default constructor is not required to set
365 /// the item to some well-defined value. So you should consider it
366 /// as uninitialized.
368 /// \brief Copy constructor.
370 /// Copy constructor.
372 BNode(const BNode &) : Parent() {}
373 /// \brief Invalid constructor \& conversion.
375 /// This constructor initializes the item to be invalid.
376 /// \sa Invalid for more details.
378 /// \brief Converter from node to B-node.
380 /// Besides the core graph item functionality each node should
381 /// be convertible to the represented B-node if it is it possible.
382 BNode(const Node&) {}
383 /// \brief Assign node to B-node.
385 /// Besides the core graph item functionality each node should
386 /// be convertible to the represented B-node if it is it possible.
387 BNode& operator=(const Node&) { return *this; }
390 /// \brief Gives back %true when the node is A-node.
392 /// Gives back %true when the node is A-node.
393 bool aNode(const Node&) const { return false; }
395 /// \brief Gives back %true when the node is B-node.
397 /// Gives back %true when the node is B-node.
398 bool bNode(const Node&) const { return false; }
400 /// \brief Gives back the A-node of the undirected edge.
402 /// Gives back the A-node of the undirected edge.
403 Node aNode(const UEdge&) const { return INVALID; }
405 /// \brief Gives back the B-node of the undirected edge.
407 /// Gives back the B-node of the undirected edge.
408 Node bNode(const UEdge&) const { return INVALID; }
410 template <typename _Graph>
412 typedef typename _Graph::Node Node;
413 typedef typename _Graph::ANode ANode;
414 typedef typename _Graph::BNode BNode;
415 typedef typename _Graph::Edge Edge;
416 typedef typename _Graph::UEdge UEdge;
419 checkConcept<BaseUGraphComponent, _Graph>();
420 checkConcept<GraphItem<'a'>, ANode>();
421 checkConcept<GraphItem<'b'>, BNode>();
434 ignore_unused_variable_warning(b);
443 /// \brief An empty idable base graph class.
445 /// This class provides beside the core graph features
446 /// core id functions for the graph structure.
447 /// The most of the base graphs should be conform to this concept.
448 /// The id's are unique and immutable.
449 template <typename _Base = BaseGraphComponent>
450 class IDableGraphComponent : public _Base {
454 typedef typename Base::Node Node;
455 typedef typename Base::Edge Edge;
457 /// \brief Gives back an unique integer id for the Node.
459 /// Gives back an unique integer id for the Node.
461 int id(const Node&) const { return -1;}
463 /// \brief Gives back the node by the unique id.
465 /// Gives back the node by the unique id.
466 /// If the graph does not contain node with the given id
467 /// then the result of the function is undetermined.
468 Node nodeFromId(int) const { return INVALID;}
470 /// \brief Gives back an unique integer id for the Edge.
472 /// Gives back an unique integer id for the Edge.
474 int id(const Edge&) const { return -1;}
476 /// \brief Gives back the edge by the unique id.
478 /// Gives back the edge by the unique id.
479 /// If the graph does not contain edge with the given id
480 /// then the result of the function is undetermined.
481 Edge edgeFromId(int) const { return INVALID;}
483 /// \brief Gives back an integer greater or equal to the maximum
486 /// Gives back an integer greater or equal to the maximum Node
488 int maxNodeId() const { return -1;}
490 /// \brief Gives back an integer greater or equal to the maximum
493 /// Gives back an integer greater or equal to the maximum Edge
495 int maxEdgeId() const { return -1;}
497 template <typename _Graph>
501 checkConcept<Base, _Graph >();
502 typename _Graph::Node node;
503 int nid = graph.id(node);
504 nid = graph.id(node);
505 node = graph.nodeFromId(nid);
506 typename _Graph::Edge edge;
507 int eid = graph.id(edge);
508 eid = graph.id(edge);
509 edge = graph.edgeFromId(eid);
511 nid = graph.maxNodeId();
512 ignore_unused_variable_warning(nid);
513 eid = graph.maxEdgeId();
514 ignore_unused_variable_warning(eid);
521 /// \brief An empty idable base undirected graph class.
523 /// This class provides beside the core undirected graph features
524 /// core id functions for the undirected graph structure. The
525 /// most of the base undirected graphs should be conform to this
526 /// concept. The id's are unique and immutable.
527 template <typename _Base = BaseUGraphComponent>
528 class IDableUGraphComponent : public IDableGraphComponent<_Base> {
532 typedef typename Base::UEdge UEdge;
534 using IDableGraphComponent<_Base>::id;
536 /// \brief Gives back an unique integer id for the UEdge.
538 /// Gives back an unique integer id for the UEdge.
540 int id(const UEdge&) const { return -1;}
542 /// \brief Gives back the undirected edge by the unique id.
544 /// Gives back the undirected edge by the unique id. If the
545 /// graph does not contain edge with the given id then the
546 /// result of the function is undetermined.
547 UEdge uEdgeFromId(int) const { return INVALID;}
549 /// \brief Gives back an integer greater or equal to the maximum
552 /// Gives back an integer greater or equal to the maximum UEdge
554 int maxUEdgeId() const { return -1;}
556 template <typename _Graph>
560 checkConcept<Base, _Graph >();
561 checkConcept<IDableGraphComponent<Base>, _Graph >();
562 typename _Graph::UEdge uedge;
563 int ueid = graph.id(uedge);
564 ueid = graph.id(uedge);
565 uedge = graph.uEdgeFromId(ueid);
566 ueid = graph.maxUEdgeId();
567 ignore_unused_variable_warning(ueid);
574 /// \brief An empty idable base bipartite undirected graph class.
576 /// This class provides beside the core bipartite undirected graph
577 /// features core id functions for the bipartite undirected graph
578 /// structure. The most of the base undirected graphs should be
579 /// conform to this concept.
580 template <typename _Base = BaseBpUGraphComponent>
581 class IDableBpUGraphComponent : public IDableUGraphComponent<_Base> {
585 typedef typename Base::Node Node;
587 using IDableUGraphComponent<_Base>::id;
589 /// \brief Gives back an unique integer id for the ANode.
591 /// Gives back an unique integer id for the ANode.
593 int aNodeId(const Node&) const { return -1;}
595 /// \brief Gives back the undirected edge by the unique id.
597 /// Gives back the undirected edge by the unique id. If the
598 /// graph does not contain edge with the given id then the
599 /// result of the function is undetermined.
600 Node nodeFromANodeId(int) const { return INVALID;}
602 /// \brief Gives back an integer greater or equal to the maximum
605 /// Gives back an integer greater or equal to the maximum ANode
607 int maxANodeId() const { return -1;}
609 /// \brief Gives back an unique integer id for the BNode.
611 /// Gives back an unique integer id for the BNode.
613 int bNodeId(const Node&) const { return -1;}
615 /// \brief Gives back the undirected edge by the unique id.
617 /// Gives back the undirected edge by the unique id. If the
618 /// graph does not contain edge with the given id then the
619 /// result of the function is undetermined.
620 Node nodeFromBNodeId(int) const { return INVALID;}
622 /// \brief Gives back an integer greater or equal to the maximum
625 /// Gives back an integer greater or equal to the maximum BNode
627 int maxBNodeId() const { return -1;}
629 template <typename _Graph>
633 checkConcept<Base, _Graph >();
634 checkConcept<IDableGraphComponent<Base>, _Graph >();
635 typename _Graph::Node node(INVALID);
637 id = graph.aNodeId(node);
638 id = graph.bNodeId(node);
639 node = graph.nodeFromANodeId(id);
640 node = graph.nodeFromBNodeId(id);
641 id = graph.maxANodeId();
642 id = graph.maxBNodeId();
649 /// \brief Skeleton class for graph NodeIt and EdgeIt
651 /// Skeleton class for graph NodeIt and EdgeIt.
653 template <typename _Graph, typename _Item>
654 class GraphItemIt : public _Item {
656 /// \brief Default constructor.
658 /// @warning The default constructor sets the iterator
659 /// to an undefined value.
661 /// \brief Copy constructor.
663 /// Copy constructor.
665 GraphItemIt(const GraphItemIt& ) {}
666 /// \brief Sets the iterator to the first item.
668 /// Sets the iterator to the first item of \c the graph.
670 explicit GraphItemIt(const _Graph&) {}
671 /// \brief Invalid constructor \& conversion.
673 /// This constructor initializes the item to be invalid.
674 /// \sa Invalid for more details.
675 GraphItemIt(Invalid) {}
676 /// \brief Assign operator for items.
678 /// The items are assignable.
680 GraphItemIt& operator=(const GraphItemIt&) { return *this; }
681 /// \brief Next item.
683 /// Assign the iterator to the next item.
685 GraphItemIt& operator++() { return *this; }
686 /// \brief Equality operator
688 /// Two iterators are equal if and only if they point to the
689 /// same object or both are invalid.
690 bool operator==(const GraphItemIt&) const { return true;}
691 /// \brief Inequality operator
693 /// \sa operator==(Node n)
695 bool operator!=(const GraphItemIt&) const { return true;}
697 template<typename _GraphItemIt>
714 /// \brief Skeleton class for graph InEdgeIt and OutEdgeIt
716 /// \note Because InEdgeIt and OutEdgeIt may not inherit from the same
717 /// base class, the _selector is a additional template parameter. For
718 /// InEdgeIt you should instantiate it with character 'i' and for
719 /// OutEdgeIt with 'o'.
720 template <typename _Graph,
721 typename _Item = typename _Graph::Edge,
722 typename _Base = typename _Graph::Node,
723 char _selector = '0'>
724 class GraphIncIt : public _Item {
726 /// \brief Default constructor.
728 /// @warning The default constructor sets the iterator
729 /// to an undefined value.
731 /// \brief Copy constructor.
733 /// Copy constructor.
735 GraphIncIt(GraphIncIt const& gi) : _Item(gi) {}
736 /// \brief Sets the iterator to the first edge incoming into or outgoing
739 /// Sets the iterator to the first edge incoming into or outgoing
742 explicit GraphIncIt(const _Graph&, const _Base&) {}
743 /// \brief Invalid constructor \& conversion.
745 /// This constructor initializes the item to be invalid.
746 /// \sa Invalid for more details.
747 GraphIncIt(Invalid) {}
748 /// \brief Assign operator for iterators.
750 /// The iterators are assignable.
752 GraphIncIt& operator=(GraphIncIt const&) { return *this; }
753 /// \brief Next item.
755 /// Assign the iterator to the next item.
757 GraphIncIt& operator++() { return *this; }
759 /// \brief Equality operator
761 /// Two iterators are equal if and only if they point to the
762 /// same object or both are invalid.
763 bool operator==(const GraphIncIt&) const { return true;}
765 /// \brief Inequality operator
767 /// \sa operator==(Node n)
769 bool operator!=(const GraphIncIt&) const { return true;}
771 template <typename _GraphIncIt>
774 checkConcept<GraphItem<_selector>, _GraphIncIt>();
775 _GraphIncIt it1(graph, node);
794 /// \brief An empty iterable graph class.
796 /// This class provides beside the core graph features
797 /// iterator based iterable interface for the graph structure.
798 /// This concept is part of the Graph concept.
799 template <typename _Base = BaseGraphComponent>
800 class IterableGraphComponent : public _Base {
805 typedef typename Base::Node Node;
806 typedef typename Base::Edge Edge;
808 typedef IterableGraphComponent Graph;
810 /// \name Base iteration
812 /// This interface provides functions for iteration on graph items
816 /// \brief Gives back the first node in the iterating order.
818 /// Gives back the first node in the iterating order.
820 void first(Node&) const {}
822 /// \brief Gives back the next node in the iterating order.
824 /// Gives back the next node in the iterating order.
826 void next(Node&) const {}
828 /// \brief Gives back the first edge in the iterating order.
830 /// Gives back the first edge in the iterating order.
832 void first(Edge&) const {}
834 /// \brief Gives back the next edge in the iterating order.
836 /// Gives back the next edge in the iterating order.
838 void next(Edge&) const {}
841 /// \brief Gives back the first of the edges point to the given
844 /// Gives back the first of the edges point to the given node.
846 void firstIn(Edge&, const Node&) const {}
848 /// \brief Gives back the next of the edges points to the given
851 /// Gives back the next of the edges points to the given node.
853 void nextIn(Edge&) const {}
855 /// \brief Gives back the first of the edges start from the
858 /// Gives back the first of the edges start from the given node.
860 void firstOut(Edge&, const Node&) const {}
862 /// \brief Gives back the next of the edges start from the given
865 /// Gives back the next of the edges start from the given node.
867 void nextOut(Edge&) const {}
871 /// \name Class based iteration
873 /// This interface provides functions for iteration on graph items
877 /// \brief This iterator goes through each node.
879 /// This iterator goes through each node.
881 typedef GraphItemIt<Graph, Node> NodeIt;
883 /// \brief This iterator goes through each node.
885 /// This iterator goes through each node.
887 typedef GraphItemIt<Graph, Edge> EdgeIt;
889 /// \brief This iterator goes trough the incoming edges of a node.
891 /// This iterator goes trough the \e inccoming edges of a certain node
893 typedef GraphIncIt<Graph, Edge, Node, 'i'> InEdgeIt;
895 /// \brief This iterator goes trough the outgoing edges of a node.
897 /// This iterator goes trough the \e outgoing edges of a certain node
899 typedef GraphIncIt<Graph, Edge, Node, 'o'> OutEdgeIt;
901 /// \brief The base node of the iterator.
903 /// Gives back the base node of the iterator.
904 /// It is always the target of the pointed edge.
905 Node baseNode(const InEdgeIt&) const { return INVALID; }
907 /// \brief The running node of the iterator.
909 /// Gives back the running node of the iterator.
910 /// It is always the source of the pointed edge.
911 Node runningNode(const InEdgeIt&) const { return INVALID; }
913 /// \brief The base node of the iterator.
915 /// Gives back the base node of the iterator.
916 /// It is always the source of the pointed edge.
917 Node baseNode(const OutEdgeIt&) const { return INVALID; }
919 /// \brief The running node of the iterator.
921 /// Gives back the running node of the iterator.
922 /// It is always the target of the pointed edge.
923 Node runningNode(const OutEdgeIt&) const { return INVALID; }
927 template <typename _Graph>
930 checkConcept<Base, _Graph>();
933 typename _Graph::Node node(INVALID);
934 typename _Graph::Edge edge(INVALID);
944 graph.firstIn(edge, node);
948 graph.firstOut(edge, node);
954 checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
955 typename _Graph::EdgeIt >();
956 checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
957 typename _Graph::NodeIt >();
958 checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
959 typename _Graph::Node, 'i'>, typename _Graph::InEdgeIt>();
960 checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
961 typename _Graph::Node, 'o'>, typename _Graph::OutEdgeIt>();
963 typename _Graph::Node n;
964 typename _Graph::InEdgeIt ieit(INVALID);
965 typename _Graph::OutEdgeIt oeit(INVALID);
966 n = graph.baseNode(ieit);
967 n = graph.runningNode(ieit);
968 n = graph.baseNode(oeit);
969 n = graph.runningNode(oeit);
970 ignore_unused_variable_warning(n);
979 /// \brief An empty iterable undirected graph class.
981 /// This class provides beside the core graph features iterator
982 /// based iterable interface for the undirected graph structure.
983 /// This concept is part of the UGraph concept.
984 template <typename _Base = BaseUGraphComponent>
985 class IterableUGraphComponent : public IterableGraphComponent<_Base> {
989 typedef typename Base::Node Node;
990 typedef typename Base::Edge Edge;
991 typedef typename Base::UEdge UEdge;
994 typedef IterableUGraphComponent Graph;
996 /// \name Base iteration
998 /// This interface provides functions for iteration on graph items
1001 using IterableGraphComponent<_Base>::first;
1002 using IterableGraphComponent<_Base>::next;
1004 /// \brief Gives back the first undirected edge in the iterating
1007 /// Gives back the first undirected edge in the iterating order.
1009 void first(UEdge&) const {}
1011 /// \brief Gives back the next undirected edge in the iterating
1014 /// Gives back the next undirected edge in the iterating order.
1016 void next(UEdge&) const {}
1019 /// \brief Gives back the first of the undirected edges from the
1022 /// Gives back the first of the undirected edges from the given
1023 /// node. The bool parameter gives back that direction which
1024 /// gives a good direction of the uedge so the source of the
1025 /// directed edge is the given node.
1026 void firstInc(UEdge&, bool&, const Node&) const {}
1028 /// \brief Gives back the next of the undirected edges from the
1031 /// Gives back the next of the undirected edges from the given
1032 /// node. The bool parameter should be used as the \c firstInc()
1034 void nextInc(UEdge&, bool&) const {}
1036 using IterableGraphComponent<_Base>::baseNode;
1037 using IterableGraphComponent<_Base>::runningNode;
1041 /// \name Class based iteration
1043 /// This interface provides functions for iteration on graph items
1047 /// \brief This iterator goes through each node.
1049 /// This iterator goes through each node.
1050 typedef GraphItemIt<Graph, UEdge> UEdgeIt;
1051 /// \brief This iterator goes trough the incident edges of a
1054 /// This iterator goes trough the incident edges of a certain
1055 /// node of a graph.
1056 typedef GraphIncIt<Graph, UEdge, Node, 'u'> IncEdgeIt;
1057 /// \brief The base node of the iterator.
1059 /// Gives back the base node of the iterator.
1060 Node baseNode(const IncEdgeIt&) const { return INVALID; }
1062 /// \brief The running node of the iterator.
1064 /// Gives back the running node of the iterator.
1065 Node runningNode(const IncEdgeIt&) const { return INVALID; }
1069 template <typename _Graph>
1070 struct Constraints {
1071 void constraints() {
1072 checkConcept<IterableGraphComponent<Base>, _Graph>();
1075 typename _Graph::Node node(INVALID);
1076 typename _Graph::UEdge uedge(INVALID);
1083 graph.firstInc(uedge, dir, node);
1084 graph.nextInc(uedge, dir);
1090 checkConcept<GraphItemIt<_Graph, typename _Graph::UEdge>,
1091 typename _Graph::UEdgeIt >();
1092 checkConcept<GraphIncIt<_Graph, typename _Graph::UEdge,
1093 typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
1095 typename _Graph::Node n;
1096 typename _Graph::IncEdgeIt ueit(INVALID);
1097 n = graph.baseNode(ueit);
1098 n = graph.runningNode(ueit);
1102 const _Graph& graph;
1107 /// \brief An empty iterable bipartite undirected graph class.
1109 /// This class provides beside the core graph features iterator
1110 /// based iterable interface for the bipartite undirected graph
1111 /// structure. This concept is part of the BpUGraph concept.
1112 template <typename _Base = BaseUGraphComponent>
1113 class IterableBpUGraphComponent : public IterableUGraphComponent<_Base> {
1117 typedef typename Base::Node Node;
1118 typedef typename Base::UEdge UEdge;
1120 typedef IterableBpUGraphComponent Graph;
1122 /// \name Base iteration
1124 /// This interface provides functions for iteration on graph items
1127 using IterableUGraphComponent<_Base>::first;
1128 using IterableUGraphComponent<_Base>::next;
1130 /// \brief Gives back the first A-node in the iterating order.
1132 /// Gives back the first undirected A-node in the iterating
1135 void firstANode(Node&) const {}
1137 /// \brief Gives back the next A-node in the iterating order.
1139 /// Gives back the next A-node in the iterating order.
1141 void nextANode(Node&) const {}
1143 /// \brief Gives back the first B-node in the iterating order.
1145 /// Gives back the first undirected B-node in the iterating
1148 void firstBNode(Node&) const {}
1150 /// \brief Gives back the next B-node in the iterating order.
1152 /// Gives back the next B-node in the iterating order.
1154 void nextBNode(Node&) const {}
1157 /// \brief Gives back the first of the undirected edges start
1158 /// from the given A-node.
1160 /// Gives back the first of the undirected edges start from the
1162 void firstFromANode(UEdge&, const Node&) const {}
1164 /// \brief Gives back the next of the undirected edges start
1165 /// from the given A-node.
1167 /// Gives back the next of the undirected edges start from the
1169 void nextFromANode(UEdge&) const {}
1171 /// \brief Gives back the first of the undirected edges start
1172 /// from the given B-node.
1174 /// Gives back the first of the undirected edges start from the
1176 void firstFromBNode(UEdge&, const Node&) const {}
1178 /// \brief Gives back the next of the undirected edges start
1179 /// from the given B-node.
1181 /// Gives back the next of the undirected edges start from the
1183 void nextFromBNode(UEdge&) const {}
1188 /// \name Class based iteration
1190 /// This interface provides functions for iteration on graph items
1194 /// \brief This iterator goes through each A-node.
1196 /// This iterator goes through each A-node.
1197 typedef GraphItemIt<Graph, Node> ANodeIt;
1199 /// \brief This iterator goes through each B-node.
1201 /// This iterator goes through each B-node.
1202 typedef GraphItemIt<Graph, Node> BNodeIt;
1206 template <typename _Graph>
1207 struct Constraints {
1208 void constraints() {
1209 checkConcept<IterableUGraphComponent<Base>, _Graph>();
1212 typename _Graph::Node node(INVALID);
1213 typename _Graph::UEdge uedge(INVALID);
1214 graph.firstANode(node);
1215 graph.nextANode(node);
1216 graph.firstBNode(node);
1217 graph.nextBNode(node);
1219 graph.firstFromANode(uedge, node);
1220 graph.nextFromANode(uedge);
1221 graph.firstFromBNode(uedge, node);
1222 graph.nextFromBNode(uedge);
1225 checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
1226 typename _Graph::ANodeIt >();
1227 checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
1228 typename _Graph::BNodeIt >();
1233 const _Graph& graph;
1238 /// \brief An empty alteration notifier graph class.
1240 /// This class provides beside the core graph features alteration
1241 /// notifier interface for the graph structure. This implements
1242 /// an observer-notifier pattern for each graph item. More
1243 /// obsevers can be registered into the notifier and whenever an
1244 /// alteration occured in the graph all the observers will
1245 /// notified about it.
1246 template <typename _Base = BaseGraphComponent>
1247 class AlterableGraphComponent : public _Base {
1251 typedef typename Base::Node Node;
1252 typedef typename Base::Edge Edge;
1255 /// The node observer registry.
1256 typedef AlterationNotifier<AlterableGraphComponent, Node>
1258 /// The edge observer registry.
1259 typedef AlterationNotifier<AlterableGraphComponent, Edge>
1262 /// \brief Gives back the node alteration notifier.
1264 /// Gives back the node alteration notifier.
1265 NodeNotifier& getNotifier(Node) const {
1266 return NodeNotifier();
1269 /// \brief Gives back the edge alteration notifier.
1271 /// Gives back the edge alteration notifier.
1272 EdgeNotifier& getNotifier(Edge) const {
1273 return EdgeNotifier();
1276 template <typename _Graph>
1277 struct Constraints {
1278 void constraints() {
1279 checkConcept<Base, _Graph>();
1280 typename _Graph::NodeNotifier& nn
1281 = graph.getNotifier(typename _Graph::Node());
1283 typename _Graph::EdgeNotifier& en
1284 = graph.getNotifier(typename _Graph::Edge());
1286 ignore_unused_variable_warning(nn);
1287 ignore_unused_variable_warning(en);
1290 const _Graph& graph;
1296 /// \brief An empty alteration notifier undirected graph class.
1298 /// This class provides beside the core graph features alteration
1299 /// notifier interface for the graph structure. This implements
1300 /// an observer-notifier pattern for each graph item. More
1301 /// obsevers can be registered into the notifier and whenever an
1302 /// alteration occured in the graph all the observers will
1303 /// notified about it.
1304 template <typename _Base = BaseUGraphComponent>
1305 class AlterableUGraphComponent : public AlterableGraphComponent<_Base> {
1309 typedef typename Base::UEdge UEdge;
1312 /// The edge observer registry.
1313 typedef AlterationNotifier<AlterableUGraphComponent, UEdge>
1316 /// \brief Gives back the edge alteration notifier.
1318 /// Gives back the edge alteration notifier.
1319 UEdgeNotifier& getNotifier(UEdge) const {
1320 return UEdgeNotifier();
1323 template <typename _Graph>
1324 struct Constraints {
1325 void constraints() {
1326 checkConcept<AlterableGraphComponent<Base>, _Graph>();
1327 typename _Graph::UEdgeNotifier& uen
1328 = graph.getNotifier(typename _Graph::UEdge());
1329 ignore_unused_variable_warning(uen);
1332 const _Graph& graph;
1338 /// \brief An empty alteration notifier bipartite undirected graph
1341 /// This class provides beside the core graph features alteration
1342 /// notifier interface for the graph structure. This implements
1343 /// an observer-notifier pattern for each graph item. More
1344 /// obsevers can be registered into the notifier and whenever an
1345 /// alteration occured in the graph all the observers will
1346 /// notified about it.
1347 template <typename _Base = BaseUGraphComponent>
1348 class AlterableBpUGraphComponent : public AlterableUGraphComponent<_Base> {
1352 typedef typename Base::ANode ANode;
1353 typedef typename Base::BNode BNode;
1356 /// The A-node observer registry.
1357 typedef AlterationNotifier<AlterableBpUGraphComponent, ANode>
1360 /// The B-node observer registry.
1361 typedef AlterationNotifier<AlterableBpUGraphComponent, BNode>
1364 /// \brief Gives back the A-node alteration notifier.
1366 /// Gives back the A-node alteration notifier.
1367 ANodeNotifier& getNotifier(ANode) const {
1368 return ANodeNotifier();
1371 /// \brief Gives back the B-node alteration notifier.
1373 /// Gives back the B-node alteration notifier.
1374 BNodeNotifier& getNotifier(BNode) const {
1375 return BNodeNotifier();
1378 template <typename _Graph>
1379 struct Constraints {
1380 void constraints() {
1381 checkConcept<AlterableUGraphComponent<Base>, _Graph>();
1382 typename _Graph::ANodeNotifier& ann
1383 = graph.getNotifier(typename _Graph::ANode());
1384 typename _Graph::BNodeNotifier& bnn
1385 = graph.getNotifier(typename _Graph::BNode());
1386 ignore_unused_variable_warning(ann);
1387 ignore_unused_variable_warning(bnn);
1390 const _Graph& graph;
1397 /// \brief Class describing the concept of graph maps
1399 /// This class describes the common interface of the graph maps
1400 /// (NodeMap, EdgeMap), that is \ref maps-page "maps" which can be used to
1401 /// associate data to graph descriptors (nodes or edges).
1402 template <typename _Graph, typename _Item, typename _Value>
1403 class GraphMap : public ReadWriteMap<_Item, _Value> {
1406 typedef ReadWriteMap<_Item, _Value> Parent;
1408 /// The graph type of the map.
1409 typedef _Graph Graph;
1410 /// The key type of the map.
1412 /// The value type of the map.
1413 typedef _Value Value;
1415 /// \brief Construct a new map.
1417 /// Construct a new map for the graph.
1418 explicit GraphMap(const Graph&) {}
1419 /// \brief Construct a new map with default value.
1421 /// Construct a new map for the graph and initalise the values.
1422 GraphMap(const Graph&, const Value&) {}
1423 /// \brief Copy constructor.
1425 /// Copy Constructor.
1426 GraphMap(const GraphMap&) : Parent() {}
1428 /// \brief Assign operator.
1430 /// Assign operator. It does not mofify the underlying graph,
1431 /// it just iterates on the current item set and set the map
1432 /// with the value returned by the assigned map.
1433 template <typename CMap>
1434 GraphMap& operator=(const CMap&) {
1435 checkConcept<ReadMap<Key, Value>, CMap>();
1439 template<typename _Map>
1440 struct Constraints {
1441 void constraints() {
1442 checkConcept<ReadWriteMap<Key, Value>, _Map >();
1443 // Construction with a graph parameter
1445 // Constructor with a graph and a default value parameter
1447 // Copy constructor.
1450 ReadMap<Key, Value> cmap;
1453 ignore_unused_variable_warning(a2);
1454 ignore_unused_variable_warning(b);
1459 const typename GraphMap::Value &t;
1464 /// \brief An empty mappable graph class.
1466 /// This class provides beside the core graph features
1467 /// map interface for the graph structure.
1468 /// This concept is part of the Graph concept.
1469 template <typename _Base = BaseGraphComponent>
1470 class MappableGraphComponent : public _Base {
1474 typedef typename Base::Node Node;
1475 typedef typename Base::Edge Edge;
1477 typedef MappableGraphComponent Graph;
1479 /// \brief ReadWrite map of the nodes.
1481 /// ReadWrite map of the nodes.
1483 template <typename _Value>
1484 class NodeMap : public GraphMap<Graph, Node, _Value> {
1488 typedef GraphMap<MappableGraphComponent, Node, _Value> Parent;
1490 /// \brief Construct a new map.
1492 /// Construct a new map for the graph.
1493 /// \todo call the right parent class constructor
1494 explicit NodeMap(const MappableGraphComponent& graph)
1497 /// \brief Construct a new map with default value.
1499 /// Construct a new map for the graph and initalise the values.
1500 NodeMap(const MappableGraphComponent& graph, const _Value& value)
1501 : Parent(graph, value) {}
1503 /// \brief Copy constructor.
1505 /// Copy Constructor.
1506 NodeMap(const NodeMap& nm) : Parent(nm) {}
1508 /// \brief Assign operator.
1510 /// Assign operator.
1511 template <typename CMap>
1512 NodeMap& operator=(const CMap&) {
1513 checkConcept<ReadMap<Node, _Value>, CMap>();
1519 /// \brief ReadWrite map of the edges.
1521 /// ReadWrite map of the edges.
1523 template <typename _Value>
1524 class EdgeMap : public GraphMap<Graph, Edge, _Value> {
1528 typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent;
1530 /// \brief Construct a new map.
1532 /// Construct a new map for the graph.
1533 /// \todo call the right parent class constructor
1534 explicit EdgeMap(const MappableGraphComponent& graph)
1537 /// \brief Construct a new map with default value.
1539 /// Construct a new map for the graph and initalise the values.
1540 EdgeMap(const MappableGraphComponent& graph, const _Value& value)
1541 : Parent(graph, value) {}
1543 /// \brief Copy constructor.
1545 /// Copy Constructor.
1546 EdgeMap(const EdgeMap& nm) : Parent(nm) {}
1548 /// \brief Assign operator.
1550 /// Assign operator.
1551 template <typename CMap>
1552 EdgeMap& operator=(const CMap&) {
1553 checkConcept<ReadMap<Edge, _Value>, CMap>();
1560 template <typename _Graph>
1561 struct Constraints {
1565 Dummy() : value(0) {}
1566 Dummy(int _v) : value(_v) {}
1569 void constraints() {
1570 checkConcept<Base, _Graph>();
1572 typedef typename _Graph::template NodeMap<int> IntNodeMap;
1573 checkConcept<GraphMap<_Graph, typename _Graph::Node, int>,
1575 } { // bool map test
1576 typedef typename _Graph::template NodeMap<bool> BoolNodeMap;
1577 checkConcept<GraphMap<_Graph, typename _Graph::Node, bool>,
1579 } { // Dummy map test
1580 typedef typename _Graph::template NodeMap<Dummy> DummyNodeMap;
1581 checkConcept<GraphMap<_Graph, typename _Graph::Node, Dummy>,
1586 typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
1587 checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
1589 } { // bool map test
1590 typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
1591 checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
1593 } { // Dummy map test
1594 typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
1595 checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>,
1604 /// \brief An empty mappable base bipartite undirected graph class.
1606 /// This class provides beside the core graph features
1607 /// map interface for the graph structure.
1608 /// This concept is part of the UGraph concept.
1609 template <typename _Base = BaseUGraphComponent>
1610 class MappableUGraphComponent : public MappableGraphComponent<_Base> {
1614 typedef typename Base::UEdge UEdge;
1616 typedef MappableUGraphComponent Graph;
1618 /// \brief ReadWrite map of the uedges.
1620 /// ReadWrite map of the uedges.
1622 template <typename _Value>
1623 class UEdgeMap : public GraphMap<Graph, UEdge, _Value> {
1625 typedef GraphMap<MappableUGraphComponent, UEdge, _Value> Parent;
1627 /// \brief Construct a new map.
1629 /// Construct a new map for the graph.
1630 /// \todo call the right parent class constructor
1631 explicit UEdgeMap(const MappableUGraphComponent& graph)
1634 /// \brief Construct a new map with default value.
1636 /// Construct a new map for the graph and initalise the values.
1637 UEdgeMap(const MappableUGraphComponent& graph, const _Value& value)
1638 : Parent(graph, value) {}
1640 /// \brief Copy constructor.
1642 /// Copy Constructor.
1643 UEdgeMap(const UEdgeMap& nm) : Parent(nm) {}
1645 /// \brief Assign operator.
1647 /// Assign operator.
1648 template <typename CMap>
1649 UEdgeMap& operator=(const CMap&) {
1650 checkConcept<ReadMap<UEdge, _Value>, CMap>();
1657 template <typename _Graph>
1658 struct Constraints {
1662 Dummy() : value(0) {}
1663 Dummy(int _v) : value(_v) {}
1666 void constraints() {
1667 checkConcept<MappableGraphComponent<Base>, _Graph>();
1670 typedef typename _Graph::template UEdgeMap<int> IntUEdgeMap;
1671 checkConcept<GraphMap<_Graph, typename _Graph::UEdge, int>,
1673 } { // bool map test
1674 typedef typename _Graph::template UEdgeMap<bool> BoolUEdgeMap;
1675 checkConcept<GraphMap<_Graph, typename _Graph::UEdge, bool>,
1677 } { // Dummy map test
1678 typedef typename _Graph::template UEdgeMap<Dummy> DummyUEdgeMap;
1679 checkConcept<GraphMap<_Graph, typename _Graph::UEdge, Dummy>,
1688 /// \brief An empty mappable base bipartite undirected graph
1691 /// This class provides beside the core graph features
1692 /// map interface for the graph structure.
1693 /// This concept is part of the BpUGraph concept.
1694 template <typename _Base = BaseBpUGraphComponent>
1695 class MappableBpUGraphComponent : public MappableUGraphComponent<_Base> {
1699 typedef typename Base::Node Node;
1701 typedef MappableBpUGraphComponent Graph;
1703 /// \brief ReadWrite map of the A-nodes.
1705 /// ReadWrite map of the A-nodes.
1707 template <typename _Value>
1708 class ANodeMap : public GraphMap<Graph, Node, _Value> {
1710 typedef GraphMap<MappableBpUGraphComponent, Node, _Value> Parent;
1712 /// \brief Construct a new map.
1714 /// Construct a new map for the graph.
1715 /// \todo call the right parent class constructor
1716 explicit ANodeMap(const MappableBpUGraphComponent& graph)
1719 /// \brief Construct a new map with default value.
1721 /// Construct a new map for the graph and initalise the values.
1722 ANodeMap(const MappableBpUGraphComponent& graph, const _Value& value)
1723 : Parent(graph, value) {}
1725 /// \brief Copy constructor.
1727 /// Copy Constructor.
1728 ANodeMap(const ANodeMap& nm) : Parent(nm) {}
1730 /// \brief Assign operator.
1732 /// Assign operator.
1733 template <typename CMap>
1734 ANodeMap& operator=(const CMap&) {
1735 checkConcept<ReadMap<Node, _Value>, CMap>();
1741 /// \brief ReadWrite map of the B-nodes.
1743 /// ReadWrite map of the A-nodes.
1745 template <typename _Value>
1746 class BNodeMap : public GraphMap<Graph, Node, _Value> {
1748 typedef GraphMap<MappableBpUGraphComponent, Node, _Value> Parent;
1750 /// \brief Construct a new map.
1752 /// Construct a new map for the graph.
1753 /// \todo call the right parent class constructor
1754 explicit BNodeMap(const MappableBpUGraphComponent& graph)
1757 /// \brief Construct a new map with default value.
1759 /// Construct a new map for the graph and initalise the values.
1760 BNodeMap(const MappableBpUGraphComponent& graph, const _Value& value)
1761 : Parent(graph, value) {}
1763 /// \brief Copy constructor.
1765 /// Copy Constructor.
1766 BNodeMap(const BNodeMap& nm) : Parent(nm) {}
1768 /// \brief Assign operator.
1770 /// Assign operator.
1771 template <typename CMap>
1772 BNodeMap& operator=(const CMap&) {
1773 checkConcept<ReadMap<Node, _Value>, CMap>();
1780 template <typename _Graph>
1781 struct Constraints {
1785 Dummy() : value(0) {}
1786 Dummy(int _v) : value(_v) {}
1789 void constraints() {
1790 checkConcept<MappableUGraphComponent<Base>, _Graph>();
1793 typedef typename _Graph::template ANodeMap<int> IntANodeMap;
1794 checkConcept<GraphMap<_Graph, typename _Graph::ANode, int>,
1796 } { // bool map test
1797 typedef typename _Graph::template ANodeMap<bool> BoolANodeMap;
1798 checkConcept<GraphMap<_Graph, typename _Graph::ANode, bool>,
1800 } { // Dummy map test
1801 typedef typename _Graph::template ANodeMap<Dummy> DummyANodeMap;
1802 checkConcept<GraphMap<_Graph, typename _Graph::ANode, Dummy>,
1812 /// \brief An empty extendable graph class.
1814 /// This class provides beside the core graph features graph
1815 /// extendable interface for the graph structure. The main
1816 /// difference between the base and this interface is that the
1817 /// graph alterations should handled already on this level.
1818 template <typename _Base = BaseGraphComponent>
1819 class ExtendableGraphComponent : public _Base {
1823 typedef typename _Base::Node Node;
1824 typedef typename _Base::Edge Edge;
1826 /// \brief Adds a new node to the graph.
1828 /// Adds a new node to the graph.
1834 /// \brief Adds a new edge connects the given two nodes.
1836 /// Adds a new edge connects the the given two nodes.
1837 Edge addEdge(const Node&, const Node&) {
1841 template <typename _Graph>
1842 struct Constraints {
1843 void constraints() {
1844 checkConcept<Base, _Graph>();
1845 typename _Graph::Node node_a, node_b;
1846 node_a = graph.addNode();
1847 node_b = graph.addNode();
1848 typename _Graph::Edge edge;
1849 edge = graph.addEdge(node_a, node_b);
1856 /// \brief An empty extendable base undirected graph class.
1858 /// This class provides beside the core undirected graph features
1859 /// core undircted graph extend interface for the graph structure.
1860 /// The main difference between the base and this interface is
1861 /// that the graph alterations should handled already on this
1863 template <typename _Base = BaseUGraphComponent>
1864 class ExtendableUGraphComponent : public _Base {
1868 typedef typename _Base::Node Node;
1869 typedef typename _Base::UEdge UEdge;
1871 /// \brief Adds a new node to the graph.
1873 /// Adds a new node to the graph.
1879 /// \brief Adds a new edge connects the given two nodes.
1881 /// Adds a new edge connects the the given two nodes.
1882 UEdge addEdge(const Node&, const Node&) {
1886 template <typename _Graph>
1887 struct Constraints {
1888 void constraints() {
1889 checkConcept<Base, _Graph>();
1890 typename _Graph::Node node_a, node_b;
1891 node_a = graph.addNode();
1892 node_b = graph.addNode();
1893 typename _Graph::UEdge uedge;
1894 uedge = graph.addUEdge(node_a, node_b);
1901 /// \brief An empty extendable base undirected graph class.
1903 /// This class provides beside the core bipartite undirected graph
1904 /// features core undircted graph extend interface for the graph
1905 /// structure. The main difference between the base and this
1906 /// interface is that the graph alterations should handled already
1908 template <typename _Base = BaseBpUGraphComponent>
1909 class ExtendableBpUGraphComponent
1910 : public ExtendableUGraphComponent<_Base> {
1914 template <typename _Graph>
1915 struct Constraints {
1916 void constraints() {
1917 checkConcept<ExtendableUGraphComponent<Base>, _Graph>();
1922 /// \brief An empty erasable graph class.
1924 /// This class provides beside the core graph features core erase
1925 /// functions for the graph structure. The main difference between
1926 /// the base and this interface is that the graph alterations
1927 /// should handled already on this level.
1928 template <typename _Base = BaseGraphComponent>
1929 class ErasableGraphComponent : public _Base {
1933 typedef typename Base::Node Node;
1934 typedef typename Base::Edge Edge;
1936 /// \brief Erase a node from the graph.
1938 /// Erase a node from the graph. This function should
1939 /// erase all edges connecting to the node.
1940 void erase(const Node&) {}
1942 /// \brief Erase an edge from the graph.
1944 /// Erase an edge from the graph.
1946 void erase(const Edge&) {}
1948 template <typename _Graph>
1949 struct Constraints {
1950 void constraints() {
1951 checkConcept<Base, _Graph>();
1952 typename _Graph::Node node;
1954 typename _Graph::Edge edge;
1962 /// \brief An empty erasable base undirected graph class.
1964 /// This class provides beside the core undirected graph features
1965 /// core erase functions for the undirceted graph structure. The
1966 /// main difference between the base and this interface is that
1967 /// the graph alterations should handled already on this level.
1968 template <typename _Base = BaseUGraphComponent>
1969 class ErasableUGraphComponent : public _Base {
1973 typedef typename Base::Node Node;
1974 typedef typename Base::UEdge UEdge;
1976 /// \brief Erase a node from the graph.
1978 /// Erase a node from the graph. This function should erase
1979 /// edges connecting to the node.
1980 void erase(const Node&) {}
1982 /// \brief Erase an edge from the graph.
1984 /// Erase an edge from the graph.
1986 void erase(const UEdge&) {}
1988 template <typename _Graph>
1989 struct Constraints {
1990 void constraints() {
1991 checkConcept<Base, _Graph>();
1992 typename _Graph::Node node;
1994 typename _Graph::Edge edge;
2002 /// \brief An empty erasable base bipartite undirected graph class.
2004 /// This class provides beside the core bipartite undirected graph
2005 /// features core erase functions for the undirceted graph
2006 /// structure. The main difference between the base and this
2007 /// interface is that the graph alterations should handled already
2009 template <typename _Base = BaseBpUGraphComponent>
2010 class ErasableBpUGraphComponent : public ErasableUGraphComponent<_Base> {
2015 template <typename _Graph>
2016 struct Constraints {
2017 void constraints() {
2018 checkConcept<ErasableUGraphComponent<Base>, _Graph>();
2023 /// \brief An empty clearable base graph class.
2025 /// This class provides beside the core graph features core clear
2026 /// functions for the graph structure. The main difference between
2027 /// the base and this interface is that the graph alterations
2028 /// should handled already on this level.
2029 template <typename _Base = BaseGraphComponent>
2030 class ClearableGraphComponent : public _Base {
2035 /// \brief Erase all nodes and edges from the graph.
2037 /// Erase all nodes and edges from the graph.
2041 template <typename _Graph>
2042 struct Constraints {
2043 void constraints() {
2044 checkConcept<Base, _Graph>();
2052 /// \brief An empty clearable base undirected graph class.
2054 /// This class provides beside the core undirected graph features
2055 /// core clear functions for the undirected graph structure. The
2056 /// main difference between the base and this interface is that
2057 /// the graph alterations should handled already on this level.
2058 template <typename _Base = BaseUGraphComponent>
2059 class ClearableUGraphComponent : public ClearableUGraphComponent<_Base> {
2064 template <typename _Graph>
2065 struct Constraints {
2066 void constraints() {
2067 checkConcept<ClearableUGraphComponent<Base>, _Graph>();
2074 /// \brief An empty clearable base bipartite undirected graph
2077 /// This class provides beside the core bipartite undirected graph
2078 /// features core clear functions for the undirected graph
2079 /// structure. The main difference between the base and this
2080 /// interface is that the graph alterations should handled already
2082 template <typename _Base = BaseUGraphComponent>
2083 class ClearableBpUGraphComponent
2084 : public ClearableBpUGraphComponent<_Base> {
2089 template <typename _Graph>
2090 struct Constraints {
2091 void constraints() {
2092 checkConcept<ClearableBpUGraphComponent<Base>, _Graph>();