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