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 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& notifier(Node) const {
1266 return NodeNotifier();
1269 /// \brief Gives back the edge alteration notifier.
1271 /// Gives back the edge alteration notifier.
1272 EdgeNotifier& notifier(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.notifier(typename _Graph::Node());
1283 typename _Graph::EdgeNotifier& en
1284 = graph.notifier(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& notifier(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.notifier(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& notifier(ANode) const {
1368 return ANodeNotifier();
1371 /// \brief Gives back the B-node alteration notifier.
1373 /// Gives back the B-node alteration notifier.
1374 BNodeNotifier& notifier(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.notifier(typename _Graph::ANode());
1384 typename _Graph::BNodeNotifier& bnn
1385 = graph.notifier(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> {
1486 typedef GraphMap<MappableGraphComponent, Node, _Value> Parent;
1488 /// \brief Construct a new map.
1490 /// Construct a new map for the graph.
1491 explicit NodeMap(const MappableGraphComponent& graph)
1494 /// \brief Construct a new map with default value.
1496 /// Construct a new map for the graph and initalise the values.
1497 NodeMap(const MappableGraphComponent& graph, const _Value& value)
1498 : Parent(graph, value) {}
1500 /// \brief Copy constructor.
1502 /// Copy Constructor.
1503 NodeMap(const NodeMap& nm) : Parent(nm) {}
1505 /// \brief Assign operator.
1507 /// Assign operator.
1508 template <typename CMap>
1509 NodeMap& operator=(const CMap&) {
1510 checkConcept<ReadMap<Node, _Value>, CMap>();
1516 /// \brief ReadWrite map of the edges.
1518 /// ReadWrite map of the edges.
1520 template <typename _Value>
1521 class EdgeMap : public GraphMap<Graph, Edge, _Value> {
1523 typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent;
1525 /// \brief Construct a new map.
1527 /// Construct a new map for the graph.
1528 explicit EdgeMap(const MappableGraphComponent& graph)
1531 /// \brief Construct a new map with default value.
1533 /// Construct a new map for the graph and initalise the values.
1534 EdgeMap(const MappableGraphComponent& graph, const _Value& value)
1535 : Parent(graph, value) {}
1537 /// \brief Copy constructor.
1539 /// Copy Constructor.
1540 EdgeMap(const EdgeMap& nm) : Parent(nm) {}
1542 /// \brief Assign operator.
1544 /// Assign operator.
1545 template <typename CMap>
1546 EdgeMap& operator=(const CMap&) {
1547 checkConcept<ReadMap<Edge, _Value>, CMap>();
1554 template <typename _Graph>
1555 struct Constraints {
1559 Dummy() : value(0) {}
1560 Dummy(int _v) : value(_v) {}
1563 void constraints() {
1564 checkConcept<Base, _Graph>();
1566 typedef typename _Graph::template NodeMap<int> IntNodeMap;
1567 checkConcept<GraphMap<_Graph, typename _Graph::Node, int>,
1569 } { // bool map test
1570 typedef typename _Graph::template NodeMap<bool> BoolNodeMap;
1571 checkConcept<GraphMap<_Graph, typename _Graph::Node, bool>,
1573 } { // Dummy map test
1574 typedef typename _Graph::template NodeMap<Dummy> DummyNodeMap;
1575 checkConcept<GraphMap<_Graph, typename _Graph::Node, Dummy>,
1580 typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
1581 checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
1583 } { // bool map test
1584 typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
1585 checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
1587 } { // Dummy map test
1588 typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
1589 checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>,
1598 /// \brief An empty mappable base bipartite undirected graph class.
1600 /// This class provides beside the core graph features
1601 /// map interface for the graph structure.
1602 /// This concept is part of the UGraph concept.
1603 template <typename _Base = BaseUGraphComponent>
1604 class MappableUGraphComponent : public MappableGraphComponent<_Base> {
1608 typedef typename Base::UEdge UEdge;
1610 typedef MappableUGraphComponent Graph;
1612 /// \brief ReadWrite map of the uedges.
1614 /// ReadWrite map of the uedges.
1616 template <typename _Value>
1617 class UEdgeMap : public GraphMap<Graph, UEdge, _Value> {
1619 typedef GraphMap<MappableUGraphComponent, UEdge, _Value> Parent;
1621 /// \brief Construct a new map.
1623 /// Construct a new map for the graph.
1624 explicit UEdgeMap(const MappableUGraphComponent& graph)
1627 /// \brief Construct a new map with default value.
1629 /// Construct a new map for the graph and initalise the values.
1630 UEdgeMap(const MappableUGraphComponent& graph, const _Value& value)
1631 : Parent(graph, value) {}
1633 /// \brief Copy constructor.
1635 /// Copy Constructor.
1636 UEdgeMap(const UEdgeMap& nm) : Parent(nm) {}
1638 /// \brief Assign operator.
1640 /// Assign operator.
1641 template <typename CMap>
1642 UEdgeMap& operator=(const CMap&) {
1643 checkConcept<ReadMap<UEdge, _Value>, CMap>();
1650 template <typename _Graph>
1651 struct Constraints {
1655 Dummy() : value(0) {}
1656 Dummy(int _v) : value(_v) {}
1659 void constraints() {
1660 checkConcept<MappableGraphComponent<Base>, _Graph>();
1663 typedef typename _Graph::template UEdgeMap<int> IntUEdgeMap;
1664 checkConcept<GraphMap<_Graph, typename _Graph::UEdge, int>,
1666 } { // bool map test
1667 typedef typename _Graph::template UEdgeMap<bool> BoolUEdgeMap;
1668 checkConcept<GraphMap<_Graph, typename _Graph::UEdge, bool>,
1670 } { // Dummy map test
1671 typedef typename _Graph::template UEdgeMap<Dummy> DummyUEdgeMap;
1672 checkConcept<GraphMap<_Graph, typename _Graph::UEdge, Dummy>,
1681 /// \brief An empty mappable base bipartite undirected graph
1684 /// This class provides beside the core graph features
1685 /// map interface for the graph structure.
1686 /// This concept is part of the BpUGraph concept.
1687 template <typename _Base = BaseBpUGraphComponent>
1688 class MappableBpUGraphComponent : public MappableUGraphComponent<_Base> {
1692 typedef typename Base::Node Node;
1694 typedef MappableBpUGraphComponent Graph;
1696 /// \brief ReadWrite map of the A-nodes.
1698 /// ReadWrite map of the A-nodes.
1700 template <typename _Value>
1701 class ANodeMap : public GraphMap<Graph, Node, _Value> {
1703 typedef GraphMap<MappableBpUGraphComponent, Node, _Value> Parent;
1705 /// \brief Construct a new map.
1707 /// Construct a new map for the graph.
1708 explicit ANodeMap(const MappableBpUGraphComponent& graph)
1711 /// \brief Construct a new map with default value.
1713 /// Construct a new map for the graph and initalise the values.
1714 ANodeMap(const MappableBpUGraphComponent& graph, const _Value& value)
1715 : Parent(graph, value) {}
1717 /// \brief Copy constructor.
1719 /// Copy Constructor.
1720 ANodeMap(const ANodeMap& nm) : Parent(nm) {}
1722 /// \brief Assign operator.
1724 /// Assign operator.
1725 template <typename CMap>
1726 ANodeMap& operator=(const CMap&) {
1727 checkConcept<ReadMap<Node, _Value>, CMap>();
1733 /// \brief ReadWrite map of the B-nodes.
1735 /// ReadWrite map of the A-nodes.
1737 template <typename _Value>
1738 class BNodeMap : public GraphMap<Graph, Node, _Value> {
1740 typedef GraphMap<MappableBpUGraphComponent, Node, _Value> Parent;
1742 /// \brief Construct a new map.
1744 /// Construct a new map for the graph.
1745 explicit BNodeMap(const MappableBpUGraphComponent& graph)
1748 /// \brief Construct a new map with default value.
1750 /// Construct a new map for the graph and initalise the values.
1751 BNodeMap(const MappableBpUGraphComponent& graph, const _Value& value)
1752 : Parent(graph, value) {}
1754 /// \brief Copy constructor.
1756 /// Copy Constructor.
1757 BNodeMap(const BNodeMap& nm) : Parent(nm) {}
1759 /// \brief Assign operator.
1761 /// Assign operator.
1762 template <typename CMap>
1763 BNodeMap& operator=(const CMap&) {
1764 checkConcept<ReadMap<Node, _Value>, CMap>();
1771 template <typename _Graph>
1772 struct Constraints {
1776 Dummy() : value(0) {}
1777 Dummy(int _v) : value(_v) {}
1780 void constraints() {
1781 checkConcept<MappableUGraphComponent<Base>, _Graph>();
1784 typedef typename _Graph::template ANodeMap<int> IntANodeMap;
1785 checkConcept<GraphMap<_Graph, typename _Graph::ANode, int>,
1787 } { // bool map test
1788 typedef typename _Graph::template ANodeMap<bool> BoolANodeMap;
1789 checkConcept<GraphMap<_Graph, typename _Graph::ANode, bool>,
1791 } { // Dummy map test
1792 typedef typename _Graph::template ANodeMap<Dummy> DummyANodeMap;
1793 checkConcept<GraphMap<_Graph, typename _Graph::ANode, Dummy>,
1803 /// \brief An empty extendable graph class.
1805 /// This class provides beside the core graph features graph
1806 /// extendable interface for the graph structure. The main
1807 /// difference between the base and this interface is that the
1808 /// graph alterations should handled already on this level.
1809 template <typename _Base = BaseGraphComponent>
1810 class ExtendableGraphComponent : public _Base {
1814 typedef typename _Base::Node Node;
1815 typedef typename _Base::Edge Edge;
1817 /// \brief Adds a new node to the graph.
1819 /// Adds a new node to the graph.
1825 /// \brief Adds a new edge connects the given two nodes.
1827 /// Adds a new edge connects the the given two nodes.
1828 Edge addEdge(const Node&, const Node&) {
1832 template <typename _Graph>
1833 struct Constraints {
1834 void constraints() {
1835 checkConcept<Base, _Graph>();
1836 typename _Graph::Node node_a, node_b;
1837 node_a = graph.addNode();
1838 node_b = graph.addNode();
1839 typename _Graph::Edge edge;
1840 edge = graph.addEdge(node_a, node_b);
1847 /// \brief An empty extendable base undirected graph class.
1849 /// This class provides beside the core undirected graph features
1850 /// core undircted graph extend interface for the graph structure.
1851 /// The main difference between the base and this interface is
1852 /// that the graph alterations should handled already on this
1854 template <typename _Base = BaseUGraphComponent>
1855 class ExtendableUGraphComponent : public _Base {
1859 typedef typename _Base::Node Node;
1860 typedef typename _Base::UEdge UEdge;
1862 /// \brief Adds a new node to the graph.
1864 /// Adds a new node to the graph.
1870 /// \brief Adds a new edge connects the given two nodes.
1872 /// Adds a new edge connects the the given two nodes.
1873 UEdge addEdge(const Node&, const Node&) {
1877 template <typename _Graph>
1878 struct Constraints {
1879 void constraints() {
1880 checkConcept<Base, _Graph>();
1881 typename _Graph::Node node_a, node_b;
1882 node_a = graph.addNode();
1883 node_b = graph.addNode();
1884 typename _Graph::UEdge uedge;
1885 uedge = graph.addUEdge(node_a, node_b);
1892 /// \brief An empty extendable base undirected graph class.
1894 /// This class provides beside the core bipartite undirected graph
1895 /// features core undircted graph extend interface for the graph
1896 /// structure. The main difference between the base and this
1897 /// interface is that the graph alterations should handled already
1899 template <typename _Base = BaseBpUGraphComponent>
1900 class ExtendableBpUGraphComponent
1901 : public ExtendableUGraphComponent<_Base> {
1905 template <typename _Graph>
1906 struct Constraints {
1907 void constraints() {
1908 checkConcept<ExtendableUGraphComponent<Base>, _Graph>();
1913 /// \brief An empty erasable graph class.
1915 /// This class provides beside the core graph features core erase
1916 /// functions for the graph structure. The main difference between
1917 /// the base and this interface is that the graph alterations
1918 /// should handled already on this level.
1919 template <typename _Base = BaseGraphComponent>
1920 class ErasableGraphComponent : public _Base {
1924 typedef typename Base::Node Node;
1925 typedef typename Base::Edge Edge;
1927 /// \brief Erase a node from the graph.
1929 /// Erase a node from the graph. This function should
1930 /// erase all edges connecting to the node.
1931 void erase(const Node&) {}
1933 /// \brief Erase an edge from the graph.
1935 /// Erase an edge from the graph.
1937 void erase(const Edge&) {}
1939 template <typename _Graph>
1940 struct Constraints {
1941 void constraints() {
1942 checkConcept<Base, _Graph>();
1943 typename _Graph::Node node;
1945 typename _Graph::Edge edge;
1953 /// \brief An empty erasable base undirected graph class.
1955 /// This class provides beside the core undirected graph features
1956 /// core erase functions for the undirceted graph structure. The
1957 /// main difference between the base and this interface is that
1958 /// the graph alterations should handled already on this level.
1959 template <typename _Base = BaseUGraphComponent>
1960 class ErasableUGraphComponent : public _Base {
1964 typedef typename Base::Node Node;
1965 typedef typename Base::UEdge UEdge;
1967 /// \brief Erase a node from the graph.
1969 /// Erase a node from the graph. This function should erase
1970 /// edges connecting to the node.
1971 void erase(const Node&) {}
1973 /// \brief Erase an edge from the graph.
1975 /// Erase an edge from the graph.
1977 void erase(const UEdge&) {}
1979 template <typename _Graph>
1980 struct Constraints {
1981 void constraints() {
1982 checkConcept<Base, _Graph>();
1983 typename _Graph::Node node;
1985 typename _Graph::Edge edge;
1993 /// \brief An empty erasable base bipartite undirected graph class.
1995 /// This class provides beside the core bipartite undirected graph
1996 /// features core erase functions for the undirceted graph
1997 /// structure. The main difference between the base and this
1998 /// interface is that the graph alterations should handled already
2000 template <typename _Base = BaseBpUGraphComponent>
2001 class ErasableBpUGraphComponent : public ErasableUGraphComponent<_Base> {
2006 template <typename _Graph>
2007 struct Constraints {
2008 void constraints() {
2009 checkConcept<ErasableUGraphComponent<Base>, _Graph>();
2014 /// \brief An empty clearable base graph class.
2016 /// This class provides beside the core graph features core clear
2017 /// functions for the graph structure. The main difference between
2018 /// the base and this interface is that the graph alterations
2019 /// should handled already on this level.
2020 template <typename _Base = BaseGraphComponent>
2021 class ClearableGraphComponent : public _Base {
2026 /// \brief Erase all nodes and edges from the graph.
2028 /// Erase all nodes and edges from the graph.
2032 template <typename _Graph>
2033 struct Constraints {
2034 void constraints() {
2035 checkConcept<Base, _Graph>();
2043 /// \brief An empty clearable base undirected graph class.
2045 /// This class provides beside the core undirected graph features
2046 /// core clear functions for the undirected graph structure. The
2047 /// main difference between the base and this interface is that
2048 /// the graph alterations should handled already on this level.
2049 template <typename _Base = BaseUGraphComponent>
2050 class ClearableUGraphComponent : public ClearableGraphComponent<_Base> {
2055 template <typename _Graph>
2056 struct Constraints {
2057 void constraints() {
2058 checkConcept<ClearableUGraphComponent<Base>, _Graph>();
2065 /// \brief An empty clearable base bipartite undirected graph
2068 /// This class provides beside the core bipartite undirected graph
2069 /// features core clear functions for the undirected graph
2070 /// structure. The main difference between the base and this
2071 /// interface is that the graph alterations should handled already
2073 template <typename _Base = BaseUGraphComponent>
2074 class ClearableBpUGraphComponent : public ClearableUGraphComponent<_Base> {
2079 template <typename _Graph>
2080 struct Constraints {
2081 void constraints() {
2082 checkConcept<ClearableBpUGraphComponent<Base>, _Graph>();