1.1 --- a/lemon/concepts/graph_components.h Fri Nov 13 12:33:33 2009 +0100
1.2 +++ b/lemon/concepts/graph_components.h Thu Dec 10 17:05:35 2009 +0100
1.3 @@ -2,7 +2,7 @@
1.4 *
1.5 * This file is a part of LEMON, a generic C++ optimization library.
1.6 *
1.7 - * Copyright (C) 2003-2008
1.8 + * Copyright (C) 2003-2009
1.9 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 *
1.12 @@ -20,9 +20,8 @@
1.13 ///\file
1.14 ///\brief The concept of graph components.
1.15
1.16 -
1.17 -#ifndef LEMON_CONCEPT_GRAPH_COMPONENTS_H
1.18 -#define LEMON_CONCEPT_GRAPH_COMPONENTS_H
1.19 +#ifndef LEMON_CONCEPTS_GRAPH_COMPONENTS_H
1.20 +#define LEMON_CONCEPTS_GRAPH_COMPONENTS_H
1.21
1.22 #include <lemon/core.h>
1.23 #include <lemon/concepts/maps.h>
1.24 @@ -32,75 +31,83 @@
1.25 namespace lemon {
1.26 namespace concepts {
1.27
1.28 - /// \brief Skeleton class for graph Node and Arc types
1.29 + /// \brief Concept class for \c Node, \c Arc and \c Edge types.
1.30 ///
1.31 - /// This class describes the interface of Node and Arc (and Edge
1.32 - /// in undirected graphs) subtypes of graph types.
1.33 + /// This class describes the concept of \c Node, \c Arc and \c Edge
1.34 + /// subtypes of digraph and graph types.
1.35 ///
1.36 /// \note This class is a template class so that we can use it to
1.37 - /// create graph skeleton classes. The reason for this is than Node
1.38 - /// and Arc types should \em not derive from the same base class.
1.39 - /// For Node you should instantiate it with character 'n' and for Arc
1.40 - /// with 'a'.
1.41 -
1.42 + /// create graph skeleton classes. The reason for this is that \c Node
1.43 + /// and \c Arc (or \c Edge) types should \e not derive from the same
1.44 + /// base class. For \c Node you should instantiate it with character
1.45 + /// \c 'n', for \c Arc with \c 'a' and for \c Edge with \c 'e'.
1.46 #ifndef DOXYGEN
1.47 - template <char _selector = '0'>
1.48 + template <char sel = '0'>
1.49 #endif
1.50 class GraphItem {
1.51 public:
1.52 /// \brief Default constructor.
1.53 ///
1.54 + /// Default constructor.
1.55 /// \warning The default constructor is not required to set
1.56 /// the item to some well-defined value. So you should consider it
1.57 /// as uninitialized.
1.58 GraphItem() {}
1.59 +
1.60 /// \brief Copy constructor.
1.61 ///
1.62 /// Copy constructor.
1.63 + GraphItem(const GraphItem &) {}
1.64 +
1.65 + /// \brief Constructor for conversion from \c INVALID.
1.66 ///
1.67 - GraphItem(const GraphItem &) {}
1.68 - /// \brief Invalid constructor \& conversion.
1.69 - ///
1.70 - /// This constructor initializes the item to be invalid.
1.71 + /// Constructor for conversion from \c INVALID.
1.72 + /// It initializes the item to be invalid.
1.73 /// \sa Invalid for more details.
1.74 GraphItem(Invalid) {}
1.75 - /// \brief Assign operator for nodes.
1.76 +
1.77 + /// \brief Assignment operator.
1.78 ///
1.79 - /// The nodes are assignable.
1.80 + /// Assignment operator for the item.
1.81 + GraphItem& operator=(const GraphItem&) { return *this; }
1.82 +
1.83 + /// \brief Assignment operator for INVALID.
1.84 ///
1.85 - GraphItem& operator=(GraphItem const&) { return *this; }
1.86 + /// This operator makes the item invalid.
1.87 + GraphItem& operator=(Invalid) { return *this; }
1.88 +
1.89 /// \brief Equality operator.
1.90 ///
1.91 - /// Two iterators are equal if and only if they represents the
1.92 - /// same node in the graph or both are invalid.
1.93 - bool operator==(GraphItem) const { return false; }
1.94 + /// Equality operator.
1.95 + bool operator==(const GraphItem&) const { return false; }
1.96 +
1.97 /// \brief Inequality operator.
1.98 ///
1.99 - /// \sa operator==(const Node& n)
1.100 + /// Inequality operator.
1.101 + bool operator!=(const GraphItem&) const { return false; }
1.102 +
1.103 + /// \brief Ordering operator.
1.104 ///
1.105 - bool operator!=(GraphItem) const { return false; }
1.106 -
1.107 - /// \brief Artificial ordering operator.
1.108 - ///
1.109 - /// To allow the use of graph descriptors as key type in std::map or
1.110 - /// similar associative container we require this.
1.111 + /// This operator defines an ordering of the items.
1.112 + /// It makes possible to use graph item types as key types in
1.113 + /// associative containers (e.g. \c std::map).
1.114 ///
1.115 /// \note This operator only have to define some strict ordering of
1.116 /// the items; this order has nothing to do with the iteration
1.117 /// ordering of the items.
1.118 - bool operator<(GraphItem) const { return false; }
1.119 + bool operator<(const GraphItem&) const { return false; }
1.120
1.121 template<typename _GraphItem>
1.122 struct Constraints {
1.123 void constraints() {
1.124 _GraphItem i1;
1.125 + i1=INVALID;
1.126 _GraphItem i2 = i1;
1.127 _GraphItem i3 = INVALID;
1.128
1.129 i1 = i2 = i3;
1.130
1.131 bool b;
1.132 - // b = (ia == ib) && (ia != ib) && (ia < ib);
1.133 b = (ia == ib) && (ia != ib);
1.134 b = (ia == INVALID) && (ib != INVALID);
1.135 b = (ia < ib);
1.136 @@ -111,13 +118,12 @@
1.137 };
1.138 };
1.139
1.140 - /// \brief An empty base directed graph class.
1.141 + /// \brief Base skeleton class for directed graphs.
1.142 ///
1.143 - /// This class provides the minimal set of features needed for a
1.144 - /// directed graph structure. All digraph concepts have to be
1.145 - /// conform to this base directed graph. It just provides types
1.146 - /// for nodes and arcs and functions to get the source and the
1.147 - /// target of the arcs.
1.148 + /// This class describes the base interface of directed graph types.
1.149 + /// All digraph %concepts have to conform to this class.
1.150 + /// It just provides types for nodes and arcs and functions
1.151 + /// to get the source and the target nodes of arcs.
1.152 class BaseDigraphComponent {
1.153 public:
1.154
1.155 @@ -125,31 +131,27 @@
1.156
1.157 /// \brief Node class of the digraph.
1.158 ///
1.159 - /// This class represents the Nodes of the digraph.
1.160 - ///
1.161 + /// This class represents the nodes of the digraph.
1.162 typedef GraphItem<'n'> Node;
1.163
1.164 /// \brief Arc class of the digraph.
1.165 ///
1.166 - /// This class represents the Arcs of the digraph.
1.167 + /// This class represents the arcs of the digraph.
1.168 + typedef GraphItem<'a'> Arc;
1.169 +
1.170 + /// \brief Return the source node of an arc.
1.171 ///
1.172 - typedef GraphItem<'e'> Arc;
1.173 + /// This function returns the source node of an arc.
1.174 + Node source(const Arc&) const { return INVALID; }
1.175
1.176 - /// \brief Gives back the target node of an arc.
1.177 + /// \brief Return the target node of an arc.
1.178 ///
1.179 - /// Gives back the target node of an arc.
1.180 + /// This function returns the target node of an arc.
1.181 + Node target(const Arc&) const { return INVALID; }
1.182 +
1.183 + /// \brief Return the opposite node on the given arc.
1.184 ///
1.185 - Node target(const Arc&) const { return INVALID;}
1.186 -
1.187 - /// \brief Gives back the source node of an arc.
1.188 - ///
1.189 - /// Gives back the source node of an arc.
1.190 - ///
1.191 - Node source(const Arc&) const { return INVALID;}
1.192 -
1.193 - /// \brief Gives back the opposite node on the given arc.
1.194 - ///
1.195 - /// Gives back the opposite node on the given arc.
1.196 + /// This function returns the opposite node on the given arc.
1.197 Node oppositeNode(const Node&, const Arc&) const {
1.198 return INVALID;
1.199 }
1.200 @@ -175,91 +177,92 @@
1.201 };
1.202 };
1.203
1.204 - /// \brief An empty base undirected graph class.
1.205 + /// \brief Base skeleton class for undirected graphs.
1.206 ///
1.207 - /// This class provides the minimal set of features needed for an
1.208 - /// undirected graph structure. All undirected graph concepts have
1.209 - /// to be conform to this base graph. It just provides types for
1.210 - /// nodes, arcs and edges and functions to get the
1.211 - /// source and the target of the arcs and edges,
1.212 - /// conversion from arcs to edges and function to get
1.213 - /// both direction of the edges.
1.214 + /// This class describes the base interface of undirected graph types.
1.215 + /// All graph %concepts have to conform to this class.
1.216 + /// It extends the interface of \ref BaseDigraphComponent with an
1.217 + /// \c Edge type and functions to get the end nodes of edges,
1.218 + /// to convert from arcs to edges and to get both direction of edges.
1.219 class BaseGraphComponent : public BaseDigraphComponent {
1.220 public:
1.221 +
1.222 + typedef BaseGraphComponent Graph;
1.223 +
1.224 typedef BaseDigraphComponent::Node Node;
1.225 typedef BaseDigraphComponent::Arc Arc;
1.226 - /// \brief Undirected arc class of the graph.
1.227 +
1.228 + /// \brief Undirected edge class of the graph.
1.229 ///
1.230 - /// This class represents the edges of the graph.
1.231 - /// The undirected graphs can be used as a directed graph which
1.232 - /// for each arc contains the opposite arc too so the graph is
1.233 - /// bidirected. The edge represents two opposite
1.234 - /// directed arcs.
1.235 - class Edge : public GraphItem<'u'> {
1.236 + /// This class represents the undirected edges of the graph.
1.237 + /// Undirected graphs can be used as directed graphs, each edge is
1.238 + /// represented by two opposite directed arcs.
1.239 + class Edge : public GraphItem<'e'> {
1.240 + typedef GraphItem<'e'> Parent;
1.241 +
1.242 public:
1.243 - typedef GraphItem<'u'> Parent;
1.244 /// \brief Default constructor.
1.245 ///
1.246 + /// Default constructor.
1.247 /// \warning The default constructor is not required to set
1.248 /// the item to some well-defined value. So you should consider it
1.249 /// as uninitialized.
1.250 Edge() {}
1.251 +
1.252 /// \brief Copy constructor.
1.253 ///
1.254 /// Copy constructor.
1.255 + Edge(const Edge &) : Parent() {}
1.256 +
1.257 + /// \brief Constructor for conversion from \c INVALID.
1.258 ///
1.259 - Edge(const Edge &) : Parent() {}
1.260 - /// \brief Invalid constructor \& conversion.
1.261 - ///
1.262 - /// This constructor initializes the item to be invalid.
1.263 + /// Constructor for conversion from \c INVALID.
1.264 + /// It initializes the item to be invalid.
1.265 /// \sa Invalid for more details.
1.266 Edge(Invalid) {}
1.267 - /// \brief Converter from arc to edge.
1.268 +
1.269 + /// \brief Constructor for conversion from an arc.
1.270 ///
1.271 + /// Constructor for conversion from an arc.
1.272 /// Besides the core graph item functionality each arc should
1.273 /// be convertible to the represented edge.
1.274 Edge(const Arc&) {}
1.275 - /// \brief Assign arc to edge.
1.276 - ///
1.277 - /// Besides the core graph item functionality each arc should
1.278 - /// be convertible to the represented edge.
1.279 - Edge& operator=(const Arc&) { return *this; }
1.280 - };
1.281 + };
1.282
1.283 - /// \brief Returns the direction of the arc.
1.284 + /// \brief Return one end node of an edge.
1.285 + ///
1.286 + /// This function returns one end node of an edge.
1.287 + Node u(const Edge&) const { return INVALID; }
1.288 +
1.289 + /// \brief Return the other end node of an edge.
1.290 + ///
1.291 + /// This function returns the other end node of an edge.
1.292 + Node v(const Edge&) const { return INVALID; }
1.293 +
1.294 + /// \brief Return a directed arc related to an edge.
1.295 + ///
1.296 + /// This function returns a directed arc from its direction and the
1.297 + /// represented edge.
1.298 + Arc direct(const Edge&, bool) const { return INVALID; }
1.299 +
1.300 + /// \brief Return a directed arc related to an edge.
1.301 + ///
1.302 + /// This function returns a directed arc from its source node and the
1.303 + /// represented edge.
1.304 + Arc direct(const Edge&, const Node&) const { return INVALID; }
1.305 +
1.306 + /// \brief Return the direction of the arc.
1.307 ///
1.308 /// Returns the direction of the arc. Each arc represents an
1.309 /// edge with a direction. It gives back the
1.310 /// direction.
1.311 bool direction(const Arc&) const { return true; }
1.312
1.313 - /// \brief Returns the directed arc.
1.314 + /// \brief Return the opposite arc.
1.315 ///
1.316 - /// Returns the directed arc from its direction and the
1.317 - /// represented edge.
1.318 - Arc direct(const Edge&, bool) const { return INVALID;}
1.319 -
1.320 - /// \brief Returns the directed arc.
1.321 - ///
1.322 - /// Returns the directed arc from its source and the
1.323 - /// represented edge.
1.324 - Arc direct(const Edge&, const Node&) const { return INVALID;}
1.325 -
1.326 - /// \brief Returns the opposite arc.
1.327 - ///
1.328 - /// Returns the opposite arc. It is the arc representing the
1.329 - /// same edge and has opposite direction.
1.330 - Arc oppositeArc(const Arc&) const { return INVALID;}
1.331 -
1.332 - /// \brief Gives back one ending of an edge.
1.333 - ///
1.334 - /// Gives back one ending of an edge.
1.335 - Node u(const Edge&) const { return INVALID;}
1.336 -
1.337 - /// \brief Gives back the other ending of an edge.
1.338 - ///
1.339 - /// Gives back the other ending of an edge.
1.340 - Node v(const Edge&) const { return INVALID;}
1.341 + /// This function returns the opposite arc, i.e. the arc representing
1.342 + /// the same edge and has opposite direction.
1.343 + Arc oppositeArc(const Arc&) const { return INVALID; }
1.344
1.345 template <typename _Graph>
1.346 struct Constraints {
1.347 @@ -269,7 +272,7 @@
1.348
1.349 void constraints() {
1.350 checkConcept<BaseDigraphComponent, _Graph>();
1.351 - checkConcept<GraphItem<'u'>, Edge>();
1.352 + checkConcept<GraphItem<'e'>, Edge>();
1.353 {
1.354 Node n;
1.355 Edge ue(INVALID);
1.356 @@ -277,6 +280,7 @@
1.357 n = graph.u(ue);
1.358 n = graph.v(ue);
1.359 e = graph.direct(ue, true);
1.360 + e = graph.direct(ue, false);
1.361 e = graph.direct(ue, n);
1.362 e = graph.oppositeArc(e);
1.363 ue = e;
1.364 @@ -290,59 +294,57 @@
1.365
1.366 };
1.367
1.368 - /// \brief An empty idable base digraph class.
1.369 + /// \brief Skeleton class for \e idable directed graphs.
1.370 ///
1.371 - /// This class provides beside the core digraph features
1.372 - /// core id functions for the digraph structure.
1.373 - /// The most of the base digraphs should be conform to this concept.
1.374 - /// The id's are unique and immutable.
1.375 - template <typename _Base = BaseDigraphComponent>
1.376 - class IDableDigraphComponent : public _Base {
1.377 + /// This class describes the interface of \e idable directed graphs.
1.378 + /// It extends \ref BaseDigraphComponent with the core ID functions.
1.379 + /// The ids of the items must be unique and immutable.
1.380 + /// This concept is part of the Digraph concept.
1.381 + template <typename BAS = BaseDigraphComponent>
1.382 + class IDableDigraphComponent : public BAS {
1.383 public:
1.384
1.385 - typedef _Base Base;
1.386 + typedef BAS Base;
1.387 typedef typename Base::Node Node;
1.388 typedef typename Base::Arc Arc;
1.389
1.390 - /// \brief Gives back an unique integer id for the Node.
1.391 + /// \brief Return a unique integer id for the given node.
1.392 ///
1.393 - /// Gives back an unique integer id for the Node.
1.394 + /// This function returns a unique integer id for the given node.
1.395 + int id(const Node&) const { return -1; }
1.396 +
1.397 + /// \brief Return the node by its unique id.
1.398 ///
1.399 - int id(const Node&) const { return -1;}
1.400 + /// This function returns the node by its unique id.
1.401 + /// If the digraph does not contain a node with the given id,
1.402 + /// then the result of the function is undefined.
1.403 + Node nodeFromId(int) const { return INVALID; }
1.404
1.405 - /// \brief Gives back the node by the unique id.
1.406 + /// \brief Return a unique integer id for the given arc.
1.407 ///
1.408 - /// Gives back the node by the unique id.
1.409 - /// If the digraph does not contain node with the given id
1.410 - /// then the result of the function is undetermined.
1.411 - Node nodeFromId(int) const { return INVALID;}
1.412 + /// This function returns a unique integer id for the given arc.
1.413 + int id(const Arc&) const { return -1; }
1.414
1.415 - /// \brief Gives back an unique integer id for the Arc.
1.416 + /// \brief Return the arc by its unique id.
1.417 ///
1.418 - /// Gives back an unique integer id for the Arc.
1.419 + /// This function returns the arc by its unique id.
1.420 + /// If the digraph does not contain an arc with the given id,
1.421 + /// then the result of the function is undefined.
1.422 + Arc arcFromId(int) const { return INVALID; }
1.423 +
1.424 + /// \brief Return an integer greater or equal to the maximum
1.425 + /// node id.
1.426 ///
1.427 - int id(const Arc&) const { return -1;}
1.428 + /// This function returns an integer greater or equal to the
1.429 + /// maximum node id.
1.430 + int maxNodeId() const { return -1; }
1.431
1.432 - /// \brief Gives back the arc by the unique id.
1.433 + /// \brief Return an integer greater or equal to the maximum
1.434 + /// arc id.
1.435 ///
1.436 - /// Gives back the arc by the unique id.
1.437 - /// If the digraph does not contain arc with the given id
1.438 - /// then the result of the function is undetermined.
1.439 - Arc arcFromId(int) const { return INVALID;}
1.440 -
1.441 - /// \brief Gives back an integer greater or equal to the maximum
1.442 - /// Node id.
1.443 - ///
1.444 - /// Gives back an integer greater or equal to the maximum Node
1.445 - /// id.
1.446 - int maxNodeId() const { return -1;}
1.447 -
1.448 - /// \brief Gives back an integer greater or equal to the maximum
1.449 - /// Arc id.
1.450 - ///
1.451 - /// Gives back an integer greater or equal to the maximum Arc
1.452 - /// id.
1.453 - int maxArcId() const { return -1;}
1.454 + /// This function returns an integer greater or equal to the
1.455 + /// maximum arc id.
1.456 + int maxArcId() const { return -1; }
1.457
1.458 template <typename _Digraph>
1.459 struct Constraints {
1.460 @@ -350,10 +352,12 @@
1.461 void constraints() {
1.462 checkConcept<Base, _Digraph >();
1.463 typename _Digraph::Node node;
1.464 + node=INVALID;
1.465 int nid = digraph.id(node);
1.466 nid = digraph.id(node);
1.467 node = digraph.nodeFromId(nid);
1.468 typename _Digraph::Arc arc;
1.469 + arc=INVALID;
1.470 int eid = digraph.id(arc);
1.471 eid = digraph.id(arc);
1.472 arc = digraph.arcFromId(eid);
1.473 @@ -368,46 +372,45 @@
1.474 };
1.475 };
1.476
1.477 - /// \brief An empty idable base undirected graph class.
1.478 + /// \brief Skeleton class for \e idable undirected graphs.
1.479 ///
1.480 - /// This class provides beside the core undirected graph features
1.481 - /// core id functions for the undirected graph structure. The
1.482 - /// most of the base undirected graphs should be conform to this
1.483 - /// concept. The id's are unique and immutable.
1.484 - template <typename _Base = BaseGraphComponent>
1.485 - class IDableGraphComponent : public IDableDigraphComponent<_Base> {
1.486 + /// This class describes the interface of \e idable undirected
1.487 + /// graphs. It extends \ref IDableDigraphComponent with the core ID
1.488 + /// functions of undirected graphs.
1.489 + /// The ids of the items must be unique and immutable.
1.490 + /// This concept is part of the Graph concept.
1.491 + template <typename BAS = BaseGraphComponent>
1.492 + class IDableGraphComponent : public IDableDigraphComponent<BAS> {
1.493 public:
1.494
1.495 - typedef _Base Base;
1.496 + typedef BAS Base;
1.497 typedef typename Base::Edge Edge;
1.498
1.499 - using IDableDigraphComponent<_Base>::id;
1.500 + using IDableDigraphComponent<Base>::id;
1.501
1.502 - /// \brief Gives back an unique integer id for the Edge.
1.503 + /// \brief Return a unique integer id for the given edge.
1.504 ///
1.505 - /// Gives back an unique integer id for the Edge.
1.506 + /// This function returns a unique integer id for the given edge.
1.507 + int id(const Edge&) const { return -1; }
1.508 +
1.509 + /// \brief Return the edge by its unique id.
1.510 ///
1.511 - int id(const Edge&) const { return -1;}
1.512 + /// This function returns the edge by its unique id.
1.513 + /// If the graph does not contain an edge with the given id,
1.514 + /// then the result of the function is undefined.
1.515 + Edge edgeFromId(int) const { return INVALID; }
1.516
1.517 - /// \brief Gives back the edge by the unique id.
1.518 + /// \brief Return an integer greater or equal to the maximum
1.519 + /// edge id.
1.520 ///
1.521 - /// Gives back the edge by the unique id. If the
1.522 - /// graph does not contain arc with the given id then the
1.523 - /// result of the function is undetermined.
1.524 - Edge edgeFromId(int) const { return INVALID;}
1.525 -
1.526 - /// \brief Gives back an integer greater or equal to the maximum
1.527 - /// Edge id.
1.528 - ///
1.529 - /// Gives back an integer greater or equal to the maximum Edge
1.530 - /// id.
1.531 - int maxEdgeId() const { return -1;}
1.532 + /// This function returns an integer greater or equal to the
1.533 + /// maximum edge id.
1.534 + int maxEdgeId() const { return -1; }
1.535
1.536 template <typename _Graph>
1.537 struct Constraints {
1.538
1.539 void constraints() {
1.540 - checkConcept<Base, _Graph >();
1.541 checkConcept<IDableDigraphComponent<Base>, _Graph >();
1.542 typename _Graph::Edge edge;
1.543 int ueid = graph.id(edge);
1.544 @@ -421,231 +424,243 @@
1.545 };
1.546 };
1.547
1.548 - /// \brief Skeleton class for graph NodeIt and ArcIt
1.549 + /// \brief Concept class for \c NodeIt, \c ArcIt and \c EdgeIt types.
1.550 ///
1.551 - /// Skeleton class for graph NodeIt and ArcIt.
1.552 - ///
1.553 - template <typename _Graph, typename _Item>
1.554 - class GraphItemIt : public _Item {
1.555 + /// This class describes the concept of \c NodeIt, \c ArcIt and
1.556 + /// \c EdgeIt subtypes of digraph and graph types.
1.557 + template <typename GR, typename Item>
1.558 + class GraphItemIt : public Item {
1.559 public:
1.560 /// \brief Default constructor.
1.561 ///
1.562 - /// @warning The default constructor sets the iterator
1.563 - /// to an undefined value.
1.564 + /// Default constructor.
1.565 + /// \warning The default constructor is not required to set
1.566 + /// the iterator to some well-defined value. So you should consider it
1.567 + /// as uninitialized.
1.568 GraphItemIt() {}
1.569 +
1.570 /// \brief Copy constructor.
1.571 ///
1.572 /// Copy constructor.
1.573 + GraphItemIt(const GraphItemIt& it) : Item(it) {}
1.574 +
1.575 + /// \brief Constructor that sets the iterator to the first item.
1.576 ///
1.577 - GraphItemIt(const GraphItemIt& ) {}
1.578 - /// \brief Sets the iterator to the first item.
1.579 + /// Constructor that sets the iterator to the first item.
1.580 + explicit GraphItemIt(const GR&) {}
1.581 +
1.582 + /// \brief Constructor for conversion from \c INVALID.
1.583 ///
1.584 - /// Sets the iterator to the first item of \c the graph.
1.585 - ///
1.586 - explicit GraphItemIt(const _Graph&) {}
1.587 - /// \brief Invalid constructor \& conversion.
1.588 - ///
1.589 - /// This constructor initializes the item to be invalid.
1.590 + /// Constructor for conversion from \c INVALID.
1.591 + /// It initializes the iterator to be invalid.
1.592 /// \sa Invalid for more details.
1.593 GraphItemIt(Invalid) {}
1.594 - /// \brief Assign operator for items.
1.595 +
1.596 + /// \brief Assignment operator.
1.597 ///
1.598 - /// The items are assignable.
1.599 + /// Assignment operator for the iterator.
1.600 + GraphItemIt& operator=(const GraphItemIt&) { return *this; }
1.601 +
1.602 + /// \brief Increment the iterator.
1.603 ///
1.604 - GraphItemIt& operator=(const GraphItemIt&) { return *this; }
1.605 - /// \brief Next item.
1.606 - ///
1.607 - /// Assign the iterator to the next item.
1.608 - ///
1.609 + /// This operator increments the iterator, i.e. assigns it to the
1.610 + /// next item.
1.611 GraphItemIt& operator++() { return *this; }
1.612 +
1.613 /// \brief Equality operator
1.614 ///
1.615 + /// Equality operator.
1.616 /// Two iterators are equal if and only if they point to the
1.617 /// same object or both are invalid.
1.618 bool operator==(const GraphItemIt&) const { return true;}
1.619 +
1.620 /// \brief Inequality operator
1.621 ///
1.622 - /// \sa operator==(Node n)
1.623 - ///
1.624 + /// Inequality operator.
1.625 + /// Two iterators are equal if and only if they point to the
1.626 + /// same object or both are invalid.
1.627 bool operator!=(const GraphItemIt&) const { return true;}
1.628
1.629 template<typename _GraphItemIt>
1.630 struct Constraints {
1.631 void constraints() {
1.632 + checkConcept<GraphItem<>, _GraphItemIt>();
1.633 _GraphItemIt it1(g);
1.634 _GraphItemIt it2;
1.635 + _GraphItemIt it3 = it1;
1.636 + _GraphItemIt it4 = INVALID;
1.637
1.638 it2 = ++it1;
1.639 ++it2 = it1;
1.640 ++(++it1);
1.641
1.642 - _Item bi = it1;
1.643 + Item bi = it1;
1.644 bi = it2;
1.645 }
1.646 - _Graph& g;
1.647 + const GR& g;
1.648 };
1.649 };
1.650
1.651 - /// \brief Skeleton class for graph InArcIt and OutArcIt
1.652 + /// \brief Concept class for \c InArcIt, \c OutArcIt and
1.653 + /// \c IncEdgeIt types.
1.654 ///
1.655 - /// \note Because InArcIt and OutArcIt may not inherit from the same
1.656 - /// base class, the _selector is a additional template parameter. For
1.657 - /// InArcIt you should instantiate it with character 'i' and for
1.658 - /// OutArcIt with 'o'.
1.659 - template <typename _Graph,
1.660 - typename _Item = typename _Graph::Arc,
1.661 - typename _Base = typename _Graph::Node,
1.662 - char _selector = '0'>
1.663 - class GraphIncIt : public _Item {
1.664 + /// This class describes the concept of \c InArcIt, \c OutArcIt
1.665 + /// and \c IncEdgeIt subtypes of digraph and graph types.
1.666 + ///
1.667 + /// \note Since these iterator classes do not inherit from the same
1.668 + /// base class, there is an additional template parameter (selector)
1.669 + /// \c sel. For \c InArcIt you should instantiate it with character
1.670 + /// \c 'i', for \c OutArcIt with \c 'o' and for \c IncEdgeIt with \c 'e'.
1.671 + template <typename GR,
1.672 + typename Item = typename GR::Arc,
1.673 + typename Base = typename GR::Node,
1.674 + char sel = '0'>
1.675 + class GraphIncIt : public Item {
1.676 public:
1.677 /// \brief Default constructor.
1.678 ///
1.679 - /// @warning The default constructor sets the iterator
1.680 - /// to an undefined value.
1.681 + /// Default constructor.
1.682 + /// \warning The default constructor is not required to set
1.683 + /// the iterator to some well-defined value. So you should consider it
1.684 + /// as uninitialized.
1.685 GraphIncIt() {}
1.686 +
1.687 /// \brief Copy constructor.
1.688 ///
1.689 /// Copy constructor.
1.690 + GraphIncIt(const GraphIncIt& it) : Item(it) {}
1.691 +
1.692 + /// \brief Constructor that sets the iterator to the first
1.693 + /// incoming or outgoing arc.
1.694 ///
1.695 - GraphIncIt(GraphIncIt const& gi) : _Item(gi) {}
1.696 - /// \brief Sets the iterator to the first arc incoming into or outgoing
1.697 - /// from the node.
1.698 + /// Constructor that sets the iterator to the first arc
1.699 + /// incoming to or outgoing from the given node.
1.700 + explicit GraphIncIt(const GR&, const Base&) {}
1.701 +
1.702 + /// \brief Constructor for conversion from \c INVALID.
1.703 ///
1.704 - /// Sets the iterator to the first arc incoming into or outgoing
1.705 - /// from the node.
1.706 - ///
1.707 - explicit GraphIncIt(const _Graph&, const _Base&) {}
1.708 - /// \brief Invalid constructor \& conversion.
1.709 - ///
1.710 - /// This constructor initializes the item to be invalid.
1.711 + /// Constructor for conversion from \c INVALID.
1.712 + /// It initializes the iterator to be invalid.
1.713 /// \sa Invalid for more details.
1.714 GraphIncIt(Invalid) {}
1.715 - /// \brief Assign operator for iterators.
1.716 +
1.717 + /// \brief Assignment operator.
1.718 ///
1.719 - /// The iterators are assignable.
1.720 + /// Assignment operator for the iterator.
1.721 + GraphIncIt& operator=(const GraphIncIt&) { return *this; }
1.722 +
1.723 + /// \brief Increment the iterator.
1.724 ///
1.725 - GraphIncIt& operator=(GraphIncIt const&) { return *this; }
1.726 - /// \brief Next item.
1.727 - ///
1.728 - /// Assign the iterator to the next item.
1.729 - ///
1.730 + /// This operator increments the iterator, i.e. assigns it to the
1.731 + /// next arc incoming to or outgoing from the given node.
1.732 GraphIncIt& operator++() { return *this; }
1.733
1.734 /// \brief Equality operator
1.735 ///
1.736 + /// Equality operator.
1.737 /// Two iterators are equal if and only if they point to the
1.738 /// same object or both are invalid.
1.739 bool operator==(const GraphIncIt&) const { return true;}
1.740
1.741 /// \brief Inequality operator
1.742 ///
1.743 - /// \sa operator==(Node n)
1.744 - ///
1.745 + /// Inequality operator.
1.746 + /// Two iterators are equal if and only if they point to the
1.747 + /// same object or both are invalid.
1.748 bool operator!=(const GraphIncIt&) const { return true;}
1.749
1.750 template <typename _GraphIncIt>
1.751 struct Constraints {
1.752 void constraints() {
1.753 - checkConcept<GraphItem<_selector>, _GraphIncIt>();
1.754 + checkConcept<GraphItem<sel>, _GraphIncIt>();
1.755 _GraphIncIt it1(graph, node);
1.756 _GraphIncIt it2;
1.757 + _GraphIncIt it3 = it1;
1.758 + _GraphIncIt it4 = INVALID;
1.759
1.760 it2 = ++it1;
1.761 ++it2 = it1;
1.762 ++(++it1);
1.763 - _Item e = it1;
1.764 + Item e = it1;
1.765 e = it2;
1.766 -
1.767 }
1.768 -
1.769 - _Item arc;
1.770 - _Base node;
1.771 - _Graph graph;
1.772 - _GraphIncIt it;
1.773 + const Base& node;
1.774 + const GR& graph;
1.775 };
1.776 };
1.777
1.778 -
1.779 - /// \brief An empty iterable digraph class.
1.780 + /// \brief Skeleton class for iterable directed graphs.
1.781 ///
1.782 - /// This class provides beside the core digraph features
1.783 - /// iterator based iterable interface for the digraph structure.
1.784 + /// This class describes the interface of iterable directed
1.785 + /// graphs. It extends \ref BaseDigraphComponent with the core
1.786 + /// iterable interface.
1.787 /// This concept is part of the Digraph concept.
1.788 - template <typename _Base = BaseDigraphComponent>
1.789 - class IterableDigraphComponent : public _Base {
1.790 + template <typename BAS = BaseDigraphComponent>
1.791 + class IterableDigraphComponent : public BAS {
1.792
1.793 public:
1.794
1.795 - typedef _Base Base;
1.796 + typedef BAS Base;
1.797 typedef typename Base::Node Node;
1.798 typedef typename Base::Arc Arc;
1.799
1.800 typedef IterableDigraphComponent Digraph;
1.801
1.802 - /// \name Base iteration
1.803 + /// \name Base Iteration
1.804 ///
1.805 - /// This interface provides functions for iteration on digraph items
1.806 + /// This interface provides functions for iteration on digraph items.
1.807 ///
1.808 /// @{
1.809
1.810 - /// \brief Gives back the first node in the iterating order.
1.811 + /// \brief Return the first node.
1.812 ///
1.813 - /// Gives back the first node in the iterating order.
1.814 - ///
1.815 + /// This function gives back the first node in the iteration order.
1.816 void first(Node&) const {}
1.817
1.818 - /// \brief Gives back the next node in the iterating order.
1.819 + /// \brief Return the next node.
1.820 ///
1.821 - /// Gives back the next node in the iterating order.
1.822 - ///
1.823 + /// This function gives back the next node in the iteration order.
1.824 void next(Node&) const {}
1.825
1.826 - /// \brief Gives back the first arc in the iterating order.
1.827 + /// \brief Return the first arc.
1.828 ///
1.829 - /// Gives back the first arc in the iterating order.
1.830 - ///
1.831 + /// This function gives back the first arc in the iteration order.
1.832 void first(Arc&) const {}
1.833
1.834 - /// \brief Gives back the next arc in the iterating order.
1.835 + /// \brief Return the next arc.
1.836 ///
1.837 - /// Gives back the next arc in the iterating order.
1.838 - ///
1.839 + /// This function gives back the next arc in the iteration order.
1.840 void next(Arc&) const {}
1.841
1.842 -
1.843 - /// \brief Gives back the first of the arcs point to the given
1.844 - /// node.
1.845 + /// \brief Return the first arc incomming to the given node.
1.846 ///
1.847 - /// Gives back the first of the arcs point to the given node.
1.848 - ///
1.849 + /// This function gives back the first arc incomming to the
1.850 + /// given node.
1.851 void firstIn(Arc&, const Node&) const {}
1.852
1.853 - /// \brief Gives back the next of the arcs points to the given
1.854 - /// node.
1.855 + /// \brief Return the next arc incomming to the given node.
1.856 ///
1.857 - /// Gives back the next of the arcs points to the given node.
1.858 - ///
1.859 + /// This function gives back the next arc incomming to the
1.860 + /// given node.
1.861 void nextIn(Arc&) const {}
1.862
1.863 - /// \brief Gives back the first of the arcs start from the
1.864 + /// \brief Return the first arc outgoing form the given node.
1.865 + ///
1.866 + /// This function gives back the first arc outgoing form the
1.867 /// given node.
1.868 - ///
1.869 - /// Gives back the first of the arcs start from the given node.
1.870 - ///
1.871 void firstOut(Arc&, const Node&) const {}
1.872
1.873 - /// \brief Gives back the next of the arcs start from the given
1.874 - /// node.
1.875 + /// \brief Return the next arc outgoing form the given node.
1.876 ///
1.877 - /// Gives back the next of the arcs start from the given node.
1.878 - ///
1.879 + /// This function gives back the next arc outgoing form the
1.880 + /// given node.
1.881 void nextOut(Arc&) const {}
1.882
1.883 /// @}
1.884
1.885 - /// \name Class based iteration
1.886 + /// \name Class Based Iteration
1.887 ///
1.888 - /// This interface provides functions for iteration on digraph items
1.889 + /// This interface provides iterator classes for digraph items.
1.890 ///
1.891 /// @{
1.892
1.893 @@ -655,15 +670,15 @@
1.894 ///
1.895 typedef GraphItemIt<Digraph, Node> NodeIt;
1.896
1.897 - /// \brief This iterator goes through each node.
1.898 + /// \brief This iterator goes through each arc.
1.899 ///
1.900 - /// This iterator goes through each node.
1.901 + /// This iterator goes through each arc.
1.902 ///
1.903 typedef GraphItemIt<Digraph, Arc> ArcIt;
1.904
1.905 /// \brief This iterator goes trough the incoming arcs of a node.
1.906 ///
1.907 - /// This iterator goes trough the \e inccoming arcs of a certain node
1.908 + /// This iterator goes trough the \e incoming arcs of a certain node
1.909 /// of a digraph.
1.910 typedef GraphIncIt<Digraph, Arc, Node, 'i'> InArcIt;
1.911
1.912 @@ -675,26 +690,26 @@
1.913
1.914 /// \brief The base node of the iterator.
1.915 ///
1.916 - /// Gives back the base node of the iterator.
1.917 - /// It is always the target of the pointed arc.
1.918 + /// This function gives back the base node of the iterator.
1.919 + /// It is always the target node of the pointed arc.
1.920 Node baseNode(const InArcIt&) const { return INVALID; }
1.921
1.922 /// \brief The running node of the iterator.
1.923 ///
1.924 - /// Gives back the running node of the iterator.
1.925 - /// It is always the source of the pointed arc.
1.926 + /// This function gives back the running node of the iterator.
1.927 + /// It is always the source node of the pointed arc.
1.928 Node runningNode(const InArcIt&) const { return INVALID; }
1.929
1.930 /// \brief The base node of the iterator.
1.931 ///
1.932 - /// Gives back the base node of the iterator.
1.933 - /// It is always the source of the pointed arc.
1.934 + /// This function gives back the base node of the iterator.
1.935 + /// It is always the source node of the pointed arc.
1.936 Node baseNode(const OutArcIt&) const { return INVALID; }
1.937
1.938 /// \brief The running node of the iterator.
1.939 ///
1.940 - /// Gives back the running node of the iterator.
1.941 - /// It is always the target of the pointed arc.
1.942 + /// This function gives back the running node of the iterator.
1.943 + /// It is always the target node of the pointed arc.
1.944 Node runningNode(const OutArcIt&) const { return INVALID; }
1.945
1.946 /// @}
1.947 @@ -736,31 +751,31 @@
1.948 typename _Digraph::Node, 'o'>, typename _Digraph::OutArcIt>();
1.949
1.950 typename _Digraph::Node n;
1.951 - typename _Digraph::InArcIt ieit(INVALID);
1.952 - typename _Digraph::OutArcIt oeit(INVALID);
1.953 - n = digraph.baseNode(ieit);
1.954 - n = digraph.runningNode(ieit);
1.955 - n = digraph.baseNode(oeit);
1.956 - n = digraph.runningNode(oeit);
1.957 + const typename _Digraph::InArcIt iait(INVALID);
1.958 + const typename _Digraph::OutArcIt oait(INVALID);
1.959 + n = digraph.baseNode(iait);
1.960 + n = digraph.runningNode(iait);
1.961 + n = digraph.baseNode(oait);
1.962 + n = digraph.runningNode(oait);
1.963 ignore_unused_variable_warning(n);
1.964 }
1.965 }
1.966
1.967 const _Digraph& digraph;
1.968 -
1.969 };
1.970 };
1.971
1.972 - /// \brief An empty iterable undirected graph class.
1.973 + /// \brief Skeleton class for iterable undirected graphs.
1.974 ///
1.975 - /// This class provides beside the core graph features iterator
1.976 - /// based iterable interface for the undirected graph structure.
1.977 + /// This class describes the interface of iterable undirected
1.978 + /// graphs. It extends \ref IterableDigraphComponent with the core
1.979 + /// iterable interface of undirected graphs.
1.980 /// This concept is part of the Graph concept.
1.981 - template <typename _Base = BaseGraphComponent>
1.982 - class IterableGraphComponent : public IterableDigraphComponent<_Base> {
1.983 + template <typename BAS = BaseGraphComponent>
1.984 + class IterableGraphComponent : public IterableDigraphComponent<BAS> {
1.985 public:
1.986
1.987 - typedef _Base Base;
1.988 + typedef BAS Base;
1.989 typedef typename Base::Node Node;
1.990 typedef typename Base::Arc Arc;
1.991 typedef typename Base::Edge Edge;
1.992 @@ -768,75 +783,71 @@
1.993
1.994 typedef IterableGraphComponent Graph;
1.995
1.996 - /// \name Base iteration
1.997 + /// \name Base Iteration
1.998 ///
1.999 - /// This interface provides functions for iteration on graph items
1.1000 + /// This interface provides functions for iteration on edges.
1.1001 + ///
1.1002 /// @{
1.1003
1.1004 - using IterableDigraphComponent<_Base>::first;
1.1005 - using IterableDigraphComponent<_Base>::next;
1.1006 + using IterableDigraphComponent<Base>::first;
1.1007 + using IterableDigraphComponent<Base>::next;
1.1008
1.1009 - /// \brief Gives back the first edge in the iterating
1.1010 - /// order.
1.1011 + /// \brief Return the first edge.
1.1012 ///
1.1013 - /// Gives back the first edge in the iterating order.
1.1014 - ///
1.1015 + /// This function gives back the first edge in the iteration order.
1.1016 void first(Edge&) const {}
1.1017
1.1018 - /// \brief Gives back the next edge in the iterating
1.1019 - /// order.
1.1020 + /// \brief Return the next edge.
1.1021 ///
1.1022 - /// Gives back the next edge in the iterating order.
1.1023 - ///
1.1024 + /// This function gives back the next edge in the iteration order.
1.1025 void next(Edge&) const {}
1.1026
1.1027 -
1.1028 - /// \brief Gives back the first of the edges from the
1.1029 + /// \brief Return the first edge incident to the given node.
1.1030 + ///
1.1031 + /// This function gives back the first edge incident to the given
1.1032 + /// node. The bool parameter gives back the direction for which the
1.1033 + /// source node of the directed arc representing the edge is the
1.1034 /// given node.
1.1035 - ///
1.1036 - /// Gives back the first of the edges from the given
1.1037 - /// node. The bool parameter gives back that direction which
1.1038 - /// gives a good direction of the edge so the source of the
1.1039 - /// directed arc is the given node.
1.1040 void firstInc(Edge&, bool&, const Node&) const {}
1.1041
1.1042 /// \brief Gives back the next of the edges from the
1.1043 /// given node.
1.1044 ///
1.1045 - /// Gives back the next of the edges from the given
1.1046 - /// node. The bool parameter should be used as the \c firstInc()
1.1047 - /// use it.
1.1048 + /// This function gives back the next edge incident to the given
1.1049 + /// node. The bool parameter should be used as \c firstInc() use it.
1.1050 void nextInc(Edge&, bool&) const {}
1.1051
1.1052 - using IterableDigraphComponent<_Base>::baseNode;
1.1053 - using IterableDigraphComponent<_Base>::runningNode;
1.1054 + using IterableDigraphComponent<Base>::baseNode;
1.1055 + using IterableDigraphComponent<Base>::runningNode;
1.1056
1.1057 /// @}
1.1058
1.1059 - /// \name Class based iteration
1.1060 + /// \name Class Based Iteration
1.1061 ///
1.1062 - /// This interface provides functions for iteration on graph items
1.1063 + /// This interface provides iterator classes for edges.
1.1064 ///
1.1065 /// @{
1.1066
1.1067 - /// \brief This iterator goes through each node.
1.1068 + /// \brief This iterator goes through each edge.
1.1069 ///
1.1070 - /// This iterator goes through each node.
1.1071 + /// This iterator goes through each edge.
1.1072 typedef GraphItemIt<Graph, Edge> EdgeIt;
1.1073 - /// \brief This iterator goes trough the incident arcs of a
1.1074 +
1.1075 + /// \brief This iterator goes trough the incident edges of a
1.1076 /// node.
1.1077 ///
1.1078 - /// This iterator goes trough the incident arcs of a certain
1.1079 + /// This iterator goes trough the incident edges of a certain
1.1080 /// node of a graph.
1.1081 - typedef GraphIncIt<Graph, Edge, Node, 'u'> IncEdgeIt;
1.1082 + typedef GraphIncIt<Graph, Edge, Node, 'e'> IncEdgeIt;
1.1083 +
1.1084 /// \brief The base node of the iterator.
1.1085 ///
1.1086 - /// Gives back the base node of the iterator.
1.1087 + /// This function gives back the base node of the iterator.
1.1088 Node baseNode(const IncEdgeIt&) const { return INVALID; }
1.1089
1.1090 /// \brief The running node of the iterator.
1.1091 ///
1.1092 - /// Gives back the running node of the iterator.
1.1093 + /// This function gives back the running node of the iterator.
1.1094 Node runningNode(const IncEdgeIt&) const { return INVALID; }
1.1095
1.1096 /// @}
1.1097 @@ -865,54 +876,54 @@
1.1098 checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
1.1099 typename _Graph::EdgeIt >();
1.1100 checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
1.1101 - typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
1.1102 + typename _Graph::Node, 'e'>, typename _Graph::IncEdgeIt>();
1.1103
1.1104 typename _Graph::Node n;
1.1105 - typename _Graph::IncEdgeIt ueit(INVALID);
1.1106 - n = graph.baseNode(ueit);
1.1107 - n = graph.runningNode(ueit);
1.1108 + const typename _Graph::IncEdgeIt ieit(INVALID);
1.1109 + n = graph.baseNode(ieit);
1.1110 + n = graph.runningNode(ieit);
1.1111 }
1.1112 }
1.1113
1.1114 const _Graph& graph;
1.1115 -
1.1116 };
1.1117 };
1.1118
1.1119 - /// \brief An empty alteration notifier digraph class.
1.1120 + /// \brief Skeleton class for alterable directed graphs.
1.1121 ///
1.1122 - /// This class provides beside the core digraph features alteration
1.1123 - /// notifier interface for the digraph structure. This implements
1.1124 + /// This class describes the interface of alterable directed
1.1125 + /// graphs. It extends \ref BaseDigraphComponent with the alteration
1.1126 + /// notifier interface. It implements
1.1127 /// an observer-notifier pattern for each digraph item. More
1.1128 /// obsevers can be registered into the notifier and whenever an
1.1129 - /// alteration occured in the digraph all the observers will
1.1130 + /// alteration occured in the digraph all the observers will be
1.1131 /// notified about it.
1.1132 - template <typename _Base = BaseDigraphComponent>
1.1133 - class AlterableDigraphComponent : public _Base {
1.1134 + template <typename BAS = BaseDigraphComponent>
1.1135 + class AlterableDigraphComponent : public BAS {
1.1136 public:
1.1137
1.1138 - typedef _Base Base;
1.1139 + typedef BAS Base;
1.1140 typedef typename Base::Node Node;
1.1141 typedef typename Base::Arc Arc;
1.1142
1.1143
1.1144 - /// The node observer registry.
1.1145 + /// Node alteration notifier class.
1.1146 typedef AlterationNotifier<AlterableDigraphComponent, Node>
1.1147 NodeNotifier;
1.1148 - /// The arc observer registry.
1.1149 + /// Arc alteration notifier class.
1.1150 typedef AlterationNotifier<AlterableDigraphComponent, Arc>
1.1151 ArcNotifier;
1.1152
1.1153 - /// \brief Gives back the node alteration notifier.
1.1154 + /// \brief Return the node alteration notifier.
1.1155 ///
1.1156 - /// Gives back the node alteration notifier.
1.1157 + /// This function gives back the node alteration notifier.
1.1158 NodeNotifier& notifier(Node) const {
1.1159 - return NodeNotifier();
1.1160 + return NodeNotifier();
1.1161 }
1.1162
1.1163 - /// \brief Gives back the arc alteration notifier.
1.1164 + /// \brief Return the arc alteration notifier.
1.1165 ///
1.1166 - /// Gives back the arc alteration notifier.
1.1167 + /// This function gives back the arc alteration notifier.
1.1168 ArcNotifier& notifier(Arc) const {
1.1169 return ArcNotifier();
1.1170 }
1.1171 @@ -932,34 +943,33 @@
1.1172 }
1.1173
1.1174 const _Digraph& digraph;
1.1175 -
1.1176 };
1.1177 -
1.1178 };
1.1179
1.1180 - /// \brief An empty alteration notifier undirected graph class.
1.1181 + /// \brief Skeleton class for alterable undirected graphs.
1.1182 ///
1.1183 - /// This class provides beside the core graph features alteration
1.1184 - /// notifier interface for the graph structure. This implements
1.1185 - /// an observer-notifier pattern for each graph item. More
1.1186 + /// This class describes the interface of alterable undirected
1.1187 + /// graphs. It extends \ref AlterableDigraphComponent with the alteration
1.1188 + /// notifier interface of undirected graphs. It implements
1.1189 + /// an observer-notifier pattern for the edges. More
1.1190 /// obsevers can be registered into the notifier and whenever an
1.1191 - /// alteration occured in the graph all the observers will
1.1192 + /// alteration occured in the graph all the observers will be
1.1193 /// notified about it.
1.1194 - template <typename _Base = BaseGraphComponent>
1.1195 - class AlterableGraphComponent : public AlterableDigraphComponent<_Base> {
1.1196 + template <typename BAS = BaseGraphComponent>
1.1197 + class AlterableGraphComponent : public AlterableDigraphComponent<BAS> {
1.1198 public:
1.1199
1.1200 - typedef _Base Base;
1.1201 + typedef BAS Base;
1.1202 typedef typename Base::Edge Edge;
1.1203
1.1204
1.1205 - /// The arc observer registry.
1.1206 + /// Edge alteration notifier class.
1.1207 typedef AlterationNotifier<AlterableGraphComponent, Edge>
1.1208 EdgeNotifier;
1.1209
1.1210 - /// \brief Gives back the arc alteration notifier.
1.1211 + /// \brief Return the edge alteration notifier.
1.1212 ///
1.1213 - /// Gives back the arc alteration notifier.
1.1214 + /// This function gives back the edge alteration notifier.
1.1215 EdgeNotifier& notifier(Edge) const {
1.1216 return EdgeNotifier();
1.1217 }
1.1218 @@ -967,44 +977,48 @@
1.1219 template <typename _Graph>
1.1220 struct Constraints {
1.1221 void constraints() {
1.1222 - checkConcept<AlterableGraphComponent<Base>, _Graph>();
1.1223 + checkConcept<AlterableDigraphComponent<Base>, _Graph>();
1.1224 typename _Graph::EdgeNotifier& uen
1.1225 = graph.notifier(typename _Graph::Edge());
1.1226 ignore_unused_variable_warning(uen);
1.1227 }
1.1228
1.1229 const _Graph& graph;
1.1230 -
1.1231 };
1.1232 -
1.1233 };
1.1234
1.1235 - /// \brief Class describing the concept of graph maps
1.1236 + /// \brief Concept class for standard graph maps.
1.1237 ///
1.1238 - /// This class describes the common interface of the graph maps
1.1239 - /// (NodeMap, ArcMap), that is maps that can be used to
1.1240 - /// associate data to graph descriptors (nodes or arcs).
1.1241 - template <typename _Graph, typename _Item, typename _Value>
1.1242 - class GraphMap : public ReadWriteMap<_Item, _Value> {
1.1243 + /// This class describes the concept of standard graph maps, i.e.
1.1244 + /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and
1.1245 + /// graph types, which can be used for associating data to graph items.
1.1246 + /// The standard graph maps must conform to the ReferenceMap concept.
1.1247 + template <typename GR, typename K, typename V>
1.1248 + class GraphMap : public ReferenceMap<K, V, V&, const V&> {
1.1249 + typedef ReferenceMap<K, V, V&, const V&> Parent;
1.1250 +
1.1251 public:
1.1252
1.1253 - typedef ReadWriteMap<_Item, _Value> Parent;
1.1254 + /// The key type of the map.
1.1255 + typedef K Key;
1.1256 + /// The value type of the map.
1.1257 + typedef V Value;
1.1258 + /// The reference type of the map.
1.1259 + typedef Value& Reference;
1.1260 + /// The const reference type of the map.
1.1261 + typedef const Value& ConstReference;
1.1262
1.1263 - /// The graph type of the map.
1.1264 - typedef _Graph Graph;
1.1265 - /// The key type of the map.
1.1266 - typedef _Item Key;
1.1267 - /// The value type of the map.
1.1268 - typedef _Value Value;
1.1269 + // The reference map tag.
1.1270 + typedef True ReferenceMapTag;
1.1271
1.1272 /// \brief Construct a new map.
1.1273 ///
1.1274 /// Construct a new map for the graph.
1.1275 - explicit GraphMap(const Graph&) {}
1.1276 + explicit GraphMap(const GR&) {}
1.1277 /// \brief Construct a new map with default value.
1.1278 ///
1.1279 - /// Construct a new map for the graph and initalise the values.
1.1280 - GraphMap(const Graph&, const Value&) {}
1.1281 + /// Construct a new map for the graph and initalize the values.
1.1282 + GraphMap(const GR&, const Value&) {}
1.1283
1.1284 private:
1.1285 /// \brief Copy constructor.
1.1286 @@ -1012,9 +1026,9 @@
1.1287 /// Copy Constructor.
1.1288 GraphMap(const GraphMap&) : Parent() {}
1.1289
1.1290 - /// \brief Assign operator.
1.1291 + /// \brief Assignment operator.
1.1292 ///
1.1293 - /// Assign operator. It does not mofify the underlying graph,
1.1294 + /// Assignment operator. It does not mofify the underlying graph,
1.1295 /// it just iterates on the current item set and set the map
1.1296 /// with the value returned by the assigned map.
1.1297 template <typename CMap>
1.1298 @@ -1027,53 +1041,55 @@
1.1299 template<typename _Map>
1.1300 struct Constraints {
1.1301 void constraints() {
1.1302 - checkConcept<ReadWriteMap<Key, Value>, _Map >();
1.1303 - // Construction with a graph parameter
1.1304 - _Map a(g);
1.1305 - // Constructor with a graph and a default value parameter
1.1306 - _Map a2(g,t);
1.1307 - // Copy constructor.
1.1308 - // _Map b(c);
1.1309 + checkConcept
1.1310 + <ReferenceMap<Key, Value, Value&, const Value&>, _Map>();
1.1311 + _Map m1(g);
1.1312 + _Map m2(g,t);
1.1313 +
1.1314 + // Copy constructor
1.1315 + // _Map m3(m);
1.1316
1.1317 + // Assignment operator
1.1318 // ReadMap<Key, Value> cmap;
1.1319 - // b = cmap;
1.1320 + // m3 = cmap;
1.1321
1.1322 - ignore_unused_variable_warning(a);
1.1323 - ignore_unused_variable_warning(a2);
1.1324 - // ignore_unused_variable_warning(b);
1.1325 + ignore_unused_variable_warning(m1);
1.1326 + ignore_unused_variable_warning(m2);
1.1327 + // ignore_unused_variable_warning(m3);
1.1328 }
1.1329
1.1330 - const _Map &c;
1.1331 - const Graph &g;
1.1332 + const _Map &m;
1.1333 + const GR &g;
1.1334 const typename GraphMap::Value &t;
1.1335 };
1.1336
1.1337 };
1.1338
1.1339 - /// \brief An empty mappable digraph class.
1.1340 + /// \brief Skeleton class for mappable directed graphs.
1.1341 ///
1.1342 - /// This class provides beside the core digraph features
1.1343 - /// map interface for the digraph structure.
1.1344 + /// This class describes the interface of mappable directed graphs.
1.1345 + /// It extends \ref BaseDigraphComponent with the standard digraph
1.1346 + /// map classes, namely \c NodeMap and \c ArcMap.
1.1347 /// This concept is part of the Digraph concept.
1.1348 - template <typename _Base = BaseDigraphComponent>
1.1349 - class MappableDigraphComponent : public _Base {
1.1350 + template <typename BAS = BaseDigraphComponent>
1.1351 + class MappableDigraphComponent : public BAS {
1.1352 public:
1.1353
1.1354 - typedef _Base Base;
1.1355 + typedef BAS Base;
1.1356 typedef typename Base::Node Node;
1.1357 typedef typename Base::Arc Arc;
1.1358
1.1359 typedef MappableDigraphComponent Digraph;
1.1360
1.1361 - /// \brief ReadWrite map of the nodes.
1.1362 + /// \brief Standard graph map for the nodes.
1.1363 ///
1.1364 - /// ReadWrite map of the nodes.
1.1365 - ///
1.1366 - template <typename _Value>
1.1367 - class NodeMap : public GraphMap<Digraph, Node, _Value> {
1.1368 + /// Standard graph map for the nodes.
1.1369 + /// It conforms to the ReferenceMap concept.
1.1370 + template <typename V>
1.1371 + class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
1.1372 + typedef GraphMap<MappableDigraphComponent, Node, V> Parent;
1.1373 +
1.1374 public:
1.1375 - typedef GraphMap<MappableDigraphComponent, Node, _Value> Parent;
1.1376 -
1.1377 /// \brief Construct a new map.
1.1378 ///
1.1379 /// Construct a new map for the digraph.
1.1380 @@ -1082,8 +1098,8 @@
1.1381
1.1382 /// \brief Construct a new map with default value.
1.1383 ///
1.1384 - /// Construct a new map for the digraph and initalise the values.
1.1385 - NodeMap(const MappableDigraphComponent& digraph, const _Value& value)
1.1386 + /// Construct a new map for the digraph and initalize the values.
1.1387 + NodeMap(const MappableDigraphComponent& digraph, const V& value)
1.1388 : Parent(digraph, value) {}
1.1389
1.1390 private:
1.1391 @@ -1092,26 +1108,26 @@
1.1392 /// Copy Constructor.
1.1393 NodeMap(const NodeMap& nm) : Parent(nm) {}
1.1394
1.1395 - /// \brief Assign operator.
1.1396 + /// \brief Assignment operator.
1.1397 ///
1.1398 - /// Assign operator.
1.1399 + /// Assignment operator.
1.1400 template <typename CMap>
1.1401 NodeMap& operator=(const CMap&) {
1.1402 - checkConcept<ReadMap<Node, _Value>, CMap>();
1.1403 + checkConcept<ReadMap<Node, V>, CMap>();
1.1404 return *this;
1.1405 }
1.1406
1.1407 };
1.1408
1.1409 - /// \brief ReadWrite map of the arcs.
1.1410 + /// \brief Standard graph map for the arcs.
1.1411 ///
1.1412 - /// ReadWrite map of the arcs.
1.1413 - ///
1.1414 - template <typename _Value>
1.1415 - class ArcMap : public GraphMap<Digraph, Arc, _Value> {
1.1416 + /// Standard graph map for the arcs.
1.1417 + /// It conforms to the ReferenceMap concept.
1.1418 + template <typename V>
1.1419 + class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
1.1420 + typedef GraphMap<MappableDigraphComponent, Arc, V> Parent;
1.1421 +
1.1422 public:
1.1423 - typedef GraphMap<MappableDigraphComponent, Arc, _Value> Parent;
1.1424 -
1.1425 /// \brief Construct a new map.
1.1426 ///
1.1427 /// Construct a new map for the digraph.
1.1428 @@ -1120,8 +1136,8 @@
1.1429
1.1430 /// \brief Construct a new map with default value.
1.1431 ///
1.1432 - /// Construct a new map for the digraph and initalise the values.
1.1433 - ArcMap(const MappableDigraphComponent& digraph, const _Value& value)
1.1434 + /// Construct a new map for the digraph and initalize the values.
1.1435 + ArcMap(const MappableDigraphComponent& digraph, const V& value)
1.1436 : Parent(digraph, value) {}
1.1437
1.1438 private:
1.1439 @@ -1130,12 +1146,12 @@
1.1440 /// Copy Constructor.
1.1441 ArcMap(const ArcMap& nm) : Parent(nm) {}
1.1442
1.1443 - /// \brief Assign operator.
1.1444 + /// \brief Assignment operator.
1.1445 ///
1.1446 - /// Assign operator.
1.1447 + /// Assignment operator.
1.1448 template <typename CMap>
1.1449 ArcMap& operator=(const CMap&) {
1.1450 - checkConcept<ReadMap<Arc, _Value>, CMap>();
1.1451 + checkConcept<ReadMap<Arc, V>, CMap>();
1.1452 return *this;
1.1453 }
1.1454
1.1455 @@ -1182,33 +1198,34 @@
1.1456 }
1.1457 }
1.1458
1.1459 - _Digraph& digraph;
1.1460 + const _Digraph& digraph;
1.1461 };
1.1462 };
1.1463
1.1464 - /// \brief An empty mappable base bipartite graph class.
1.1465 + /// \brief Skeleton class for mappable undirected graphs.
1.1466 ///
1.1467 - /// This class provides beside the core graph features
1.1468 - /// map interface for the graph structure.
1.1469 + /// This class describes the interface of mappable undirected graphs.
1.1470 + /// It extends \ref MappableDigraphComponent with the standard graph
1.1471 + /// map class for edges (\c EdgeMap).
1.1472 /// This concept is part of the Graph concept.
1.1473 - template <typename _Base = BaseGraphComponent>
1.1474 - class MappableGraphComponent : public MappableDigraphComponent<_Base> {
1.1475 + template <typename BAS = BaseGraphComponent>
1.1476 + class MappableGraphComponent : public MappableDigraphComponent<BAS> {
1.1477 public:
1.1478
1.1479 - typedef _Base Base;
1.1480 + typedef BAS Base;
1.1481 typedef typename Base::Edge Edge;
1.1482
1.1483 typedef MappableGraphComponent Graph;
1.1484
1.1485 - /// \brief ReadWrite map of the edges.
1.1486 + /// \brief Standard graph map for the edges.
1.1487 ///
1.1488 - /// ReadWrite map of the edges.
1.1489 - ///
1.1490 - template <typename _Value>
1.1491 - class EdgeMap : public GraphMap<Graph, Edge, _Value> {
1.1492 + /// Standard graph map for the edges.
1.1493 + /// It conforms to the ReferenceMap concept.
1.1494 + template <typename V>
1.1495 + class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
1.1496 + typedef GraphMap<MappableGraphComponent, Edge, V> Parent;
1.1497 +
1.1498 public:
1.1499 - typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent;
1.1500 -
1.1501 /// \brief Construct a new map.
1.1502 ///
1.1503 /// Construct a new map for the graph.
1.1504 @@ -1217,8 +1234,8 @@
1.1505
1.1506 /// \brief Construct a new map with default value.
1.1507 ///
1.1508 - /// Construct a new map for the graph and initalise the values.
1.1509 - EdgeMap(const MappableGraphComponent& graph, const _Value& value)
1.1510 + /// Construct a new map for the graph and initalize the values.
1.1511 + EdgeMap(const MappableGraphComponent& graph, const V& value)
1.1512 : Parent(graph, value) {}
1.1513
1.1514 private:
1.1515 @@ -1227,12 +1244,12 @@
1.1516 /// Copy Constructor.
1.1517 EdgeMap(const EdgeMap& nm) : Parent(nm) {}
1.1518
1.1519 - /// \brief Assign operator.
1.1520 + /// \brief Assignment operator.
1.1521 ///
1.1522 - /// Assign operator.
1.1523 + /// Assignment operator.
1.1524 template <typename CMap>
1.1525 EdgeMap& operator=(const CMap&) {
1.1526 - checkConcept<ReadMap<Edge, _Value>, CMap>();
1.1527 + checkConcept<ReadMap<Edge, V>, CMap>();
1.1528 return *this;
1.1529 }
1.1530
1.1531 @@ -1249,7 +1266,7 @@
1.1532 };
1.1533
1.1534 void constraints() {
1.1535 - checkConcept<MappableGraphComponent<Base>, _Graph>();
1.1536 + checkConcept<MappableDigraphComponent<Base>, _Graph>();
1.1537
1.1538 { // int map test
1.1539 typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
1.1540 @@ -1266,35 +1283,35 @@
1.1541 }
1.1542 }
1.1543
1.1544 - _Graph& graph;
1.1545 + const _Graph& graph;
1.1546 };
1.1547 };
1.1548
1.1549 - /// \brief An empty extendable digraph class.
1.1550 + /// \brief Skeleton class for extendable directed graphs.
1.1551 ///
1.1552 - /// This class provides beside the core digraph features digraph
1.1553 - /// extendable interface for the digraph structure. The main
1.1554 - /// difference between the base and this interface is that the
1.1555 - /// digraph alterations should handled already on this level.
1.1556 - template <typename _Base = BaseDigraphComponent>
1.1557 - class ExtendableDigraphComponent : public _Base {
1.1558 + /// This class describes the interface of extendable directed graphs.
1.1559 + /// It extends \ref BaseDigraphComponent with functions for adding
1.1560 + /// nodes and arcs to the digraph.
1.1561 + /// This concept requires \ref AlterableDigraphComponent.
1.1562 + template <typename BAS = BaseDigraphComponent>
1.1563 + class ExtendableDigraphComponent : public BAS {
1.1564 public:
1.1565 - typedef _Base Base;
1.1566 + typedef BAS Base;
1.1567
1.1568 - typedef typename _Base::Node Node;
1.1569 - typedef typename _Base::Arc Arc;
1.1570 + typedef typename Base::Node Node;
1.1571 + typedef typename Base::Arc Arc;
1.1572
1.1573 - /// \brief Adds a new node to the digraph.
1.1574 + /// \brief Add a new node to the digraph.
1.1575 ///
1.1576 - /// Adds a new node to the digraph.
1.1577 - ///
1.1578 + /// This function adds a new node to the digraph.
1.1579 Node addNode() {
1.1580 return INVALID;
1.1581 }
1.1582
1.1583 - /// \brief Adds a new arc connects the given two nodes.
1.1584 + /// \brief Add a new arc connecting the given two nodes.
1.1585 ///
1.1586 - /// Adds a new arc connects the the given two nodes.
1.1587 + /// This function adds a new arc connecting the given two nodes
1.1588 + /// of the digraph.
1.1589 Arc addArc(const Node&, const Node&) {
1.1590 return INVALID;
1.1591 }
1.1592 @@ -1314,33 +1331,32 @@
1.1593 };
1.1594 };
1.1595
1.1596 - /// \brief An empty extendable base undirected graph class.
1.1597 + /// \brief Skeleton class for extendable undirected graphs.
1.1598 ///
1.1599 - /// This class provides beside the core undirected graph features
1.1600 - /// core undircted graph extend interface for the graph structure.
1.1601 - /// The main difference between the base and this interface is
1.1602 - /// that the graph alterations should handled already on this
1.1603 - /// level.
1.1604 - template <typename _Base = BaseGraphComponent>
1.1605 - class ExtendableGraphComponent : public _Base {
1.1606 + /// This class describes the interface of extendable undirected graphs.
1.1607 + /// It extends \ref BaseGraphComponent with functions for adding
1.1608 + /// nodes and edges to the graph.
1.1609 + /// This concept requires \ref AlterableGraphComponent.
1.1610 + template <typename BAS = BaseGraphComponent>
1.1611 + class ExtendableGraphComponent : public BAS {
1.1612 public:
1.1613
1.1614 - typedef _Base Base;
1.1615 - typedef typename _Base::Node Node;
1.1616 - typedef typename _Base::Edge Edge;
1.1617 + typedef BAS Base;
1.1618 + typedef typename Base::Node Node;
1.1619 + typedef typename Base::Edge Edge;
1.1620
1.1621 - /// \brief Adds a new node to the graph.
1.1622 + /// \brief Add a new node to the digraph.
1.1623 ///
1.1624 - /// Adds a new node to the graph.
1.1625 - ///
1.1626 + /// This function adds a new node to the digraph.
1.1627 Node addNode() {
1.1628 return INVALID;
1.1629 }
1.1630
1.1631 - /// \brief Adds a new arc connects the given two nodes.
1.1632 + /// \brief Add a new edge connecting the given two nodes.
1.1633 ///
1.1634 - /// Adds a new arc connects the the given two nodes.
1.1635 - Edge addArc(const Node&, const Node&) {
1.1636 + /// This function adds a new edge connecting the given two nodes
1.1637 + /// of the graph.
1.1638 + Edge addEdge(const Node&, const Node&) {
1.1639 return INVALID;
1.1640 }
1.1641
1.1642 @@ -1359,39 +1375,38 @@
1.1643 };
1.1644 };
1.1645
1.1646 - /// \brief An empty erasable digraph class.
1.1647 + /// \brief Skeleton class for erasable directed graphs.
1.1648 ///
1.1649 - /// This class provides beside the core digraph features core erase
1.1650 - /// functions for the digraph structure. The main difference between
1.1651 - /// the base and this interface is that the digraph alterations
1.1652 - /// should handled already on this level.
1.1653 - template <typename _Base = BaseDigraphComponent>
1.1654 - class ErasableDigraphComponent : public _Base {
1.1655 + /// This class describes the interface of erasable directed graphs.
1.1656 + /// It extends \ref BaseDigraphComponent with functions for removing
1.1657 + /// nodes and arcs from the digraph.
1.1658 + /// This concept requires \ref AlterableDigraphComponent.
1.1659 + template <typename BAS = BaseDigraphComponent>
1.1660 + class ErasableDigraphComponent : public BAS {
1.1661 public:
1.1662
1.1663 - typedef _Base Base;
1.1664 + typedef BAS Base;
1.1665 typedef typename Base::Node Node;
1.1666 typedef typename Base::Arc Arc;
1.1667
1.1668 /// \brief Erase a node from the digraph.
1.1669 ///
1.1670 - /// Erase a node from the digraph. This function should
1.1671 - /// erase all arcs connecting to the node.
1.1672 + /// This function erases the given node from the digraph and all arcs
1.1673 + /// connected to the node.
1.1674 void erase(const Node&) {}
1.1675
1.1676 /// \brief Erase an arc from the digraph.
1.1677 ///
1.1678 - /// Erase an arc from the digraph.
1.1679 - ///
1.1680 + /// This function erases the given arc from the digraph.
1.1681 void erase(const Arc&) {}
1.1682
1.1683 template <typename _Digraph>
1.1684 struct Constraints {
1.1685 void constraints() {
1.1686 checkConcept<Base, _Digraph>();
1.1687 - typename _Digraph::Node node;
1.1688 + const typename _Digraph::Node node(INVALID);
1.1689 digraph.erase(node);
1.1690 - typename _Digraph::Arc arc;
1.1691 + const typename _Digraph::Arc arc(INVALID);
1.1692 digraph.erase(arc);
1.1693 }
1.1694
1.1695 @@ -1399,39 +1414,38 @@
1.1696 };
1.1697 };
1.1698
1.1699 - /// \brief An empty erasable base undirected graph class.
1.1700 + /// \brief Skeleton class for erasable undirected graphs.
1.1701 ///
1.1702 - /// This class provides beside the core undirected graph features
1.1703 - /// core erase functions for the undirceted graph structure. The
1.1704 - /// main difference between the base and this interface is that
1.1705 - /// the graph alterations should handled already on this level.
1.1706 - template <typename _Base = BaseGraphComponent>
1.1707 - class ErasableGraphComponent : public _Base {
1.1708 + /// This class describes the interface of erasable undirected graphs.
1.1709 + /// It extends \ref BaseGraphComponent with functions for removing
1.1710 + /// nodes and edges from the graph.
1.1711 + /// This concept requires \ref AlterableGraphComponent.
1.1712 + template <typename BAS = BaseGraphComponent>
1.1713 + class ErasableGraphComponent : public BAS {
1.1714 public:
1.1715
1.1716 - typedef _Base Base;
1.1717 + typedef BAS Base;
1.1718 typedef typename Base::Node Node;
1.1719 typedef typename Base::Edge Edge;
1.1720
1.1721 /// \brief Erase a node from the graph.
1.1722 ///
1.1723 - /// Erase a node from the graph. This function should erase
1.1724 - /// arcs connecting to the node.
1.1725 + /// This function erases the given node from the graph and all edges
1.1726 + /// connected to the node.
1.1727 void erase(const Node&) {}
1.1728
1.1729 - /// \brief Erase an arc from the graph.
1.1730 + /// \brief Erase an edge from the digraph.
1.1731 ///
1.1732 - /// Erase an arc from the graph.
1.1733 - ///
1.1734 + /// This function erases the given edge from the digraph.
1.1735 void erase(const Edge&) {}
1.1736
1.1737 template <typename _Graph>
1.1738 struct Constraints {
1.1739 void constraints() {
1.1740 checkConcept<Base, _Graph>();
1.1741 - typename _Graph::Node node;
1.1742 + const typename _Graph::Node node(INVALID);
1.1743 graph.erase(node);
1.1744 - typename _Graph::Edge edge;
1.1745 + const typename _Graph::Edge edge(INVALID);
1.1746 graph.erase(edge);
1.1747 }
1.1748
1.1749 @@ -1439,22 +1453,21 @@
1.1750 };
1.1751 };
1.1752
1.1753 - /// \brief An empty clearable base digraph class.
1.1754 + /// \brief Skeleton class for clearable directed graphs.
1.1755 ///
1.1756 - /// This class provides beside the core digraph features core clear
1.1757 - /// functions for the digraph structure. The main difference between
1.1758 - /// the base and this interface is that the digraph alterations
1.1759 - /// should handled already on this level.
1.1760 - template <typename _Base = BaseDigraphComponent>
1.1761 - class ClearableDigraphComponent : public _Base {
1.1762 + /// This class describes the interface of clearable directed graphs.
1.1763 + /// It extends \ref BaseDigraphComponent with a function for clearing
1.1764 + /// the digraph.
1.1765 + /// This concept requires \ref AlterableDigraphComponent.
1.1766 + template <typename BAS = BaseDigraphComponent>
1.1767 + class ClearableDigraphComponent : public BAS {
1.1768 public:
1.1769
1.1770 - typedef _Base Base;
1.1771 + typedef BAS Base;
1.1772
1.1773 /// \brief Erase all nodes and arcs from the digraph.
1.1774 ///
1.1775 - /// Erase all nodes and arcs from the digraph.
1.1776 - ///
1.1777 + /// This function erases all nodes and arcs from the digraph.
1.1778 void clear() {}
1.1779
1.1780 template <typename _Digraph>
1.1781 @@ -1464,29 +1477,35 @@
1.1782 digraph.clear();
1.1783 }
1.1784
1.1785 - _Digraph digraph;
1.1786 + _Digraph& digraph;
1.1787 };
1.1788 };
1.1789
1.1790 - /// \brief An empty clearable base undirected graph class.
1.1791 + /// \brief Skeleton class for clearable undirected graphs.
1.1792 ///
1.1793 - /// This class provides beside the core undirected graph features
1.1794 - /// core clear functions for the undirected graph structure. The
1.1795 - /// main difference between the base and this interface is that
1.1796 - /// the graph alterations should handled already on this level.
1.1797 - template <typename _Base = BaseGraphComponent>
1.1798 - class ClearableGraphComponent : public ClearableDigraphComponent<_Base> {
1.1799 + /// This class describes the interface of clearable undirected graphs.
1.1800 + /// It extends \ref BaseGraphComponent with a function for clearing
1.1801 + /// the graph.
1.1802 + /// This concept requires \ref AlterableGraphComponent.
1.1803 + template <typename BAS = BaseGraphComponent>
1.1804 + class ClearableGraphComponent : public ClearableDigraphComponent<BAS> {
1.1805 public:
1.1806
1.1807 - typedef _Base Base;
1.1808 + typedef BAS Base;
1.1809 +
1.1810 + /// \brief Erase all nodes and edges from the graph.
1.1811 + ///
1.1812 + /// This function erases all nodes and edges from the graph.
1.1813 + void clear() {}
1.1814
1.1815 template <typename _Graph>
1.1816 struct Constraints {
1.1817 void constraints() {
1.1818 - checkConcept<ClearableGraphComponent<Base>, _Graph>();
1.1819 + checkConcept<Base, _Graph>();
1.1820 + graph.clear();
1.1821 }
1.1822
1.1823 - _Graph graph;
1.1824 + _Graph& graph;
1.1825 };
1.1826 };
1.1827