1.1 --- a/lemon/concepts/graph.h Thu Dec 10 17:05:35 2009 +0100
1.2 +++ b/lemon/concepts/graph.h Thu Dec 10 17:18:25 2009 +0100
1.3 @@ -18,12 +18,14 @@
1.4
1.5 ///\ingroup graph_concepts
1.6 ///\file
1.7 -///\brief The concept of Undirected Graphs.
1.8 +///\brief The concept of undirected graphs.
1.9
1.10 #ifndef LEMON_CONCEPTS_GRAPH_H
1.11 #define LEMON_CONCEPTS_GRAPH_H
1.12
1.13 #include <lemon/concepts/graph_components.h>
1.14 +#include <lemon/concepts/maps.h>
1.15 +#include <lemon/concept_check.h>
1.16 #include <lemon/core.h>
1.17
1.18 namespace lemon {
1.19 @@ -31,63 +33,74 @@
1.20
1.21 /// \ingroup graph_concepts
1.22 ///
1.23 - /// \brief Class describing the concept of Undirected Graphs.
1.24 + /// \brief Class describing the concept of undirected graphs.
1.25 ///
1.26 - /// This class describes the common interface of all Undirected
1.27 - /// Graphs.
1.28 + /// This class describes the common interface of all undirected
1.29 + /// graphs.
1.30 ///
1.31 - /// As all concept describing classes it provides only interface
1.32 - /// without any sensible implementation. So any algorithm for
1.33 - /// undirected graph should compile with this class, but it will not
1.34 + /// Like all concept classes, it only provides an interface
1.35 + /// without any sensible implementation. So any general algorithm for
1.36 + /// undirected graphs should compile with this class, but it will not
1.37 /// run properly, of course.
1.38 + /// An actual graph implementation like \ref ListGraph or
1.39 + /// \ref SmartGraph may have additional functionality.
1.40 ///
1.41 - /// The LEMON undirected graphs also fulfill the concept of
1.42 - /// directed graphs (\ref lemon::concepts::Digraph "Digraph
1.43 - /// Concept"). Each edges can be seen as two opposite
1.44 - /// directed arc and consequently the undirected graph can be
1.45 - /// seen as the direceted graph of these directed arcs. The
1.46 - /// Graph has the Edge inner class for the edges and
1.47 - /// the Arc type for the directed arcs. The Arc type is
1.48 - /// convertible to Edge or inherited from it so from a directed
1.49 - /// arc we can get the represented edge.
1.50 + /// The undirected graphs also fulfill the concept of \ref Digraph
1.51 + /// "directed graphs", since each edge can also be regarded as two
1.52 + /// oppositely directed arcs.
1.53 + /// Undirected graphs provide an Edge type for the undirected edges and
1.54 + /// an Arc type for the directed arcs. The Arc type is convertible to
1.55 + /// Edge or inherited from it, i.e. the corresponding edge can be
1.56 + /// obtained from an arc.
1.57 + /// EdgeIt and EdgeMap classes can be used for the edges, while ArcIt
1.58 + /// and ArcMap classes can be used for the arcs (just like in digraphs).
1.59 + /// Both InArcIt and OutArcIt iterates on the same edges but with
1.60 + /// opposite direction. IncEdgeIt also iterates on the same edges
1.61 + /// as OutArcIt and InArcIt, but it is not convertible to Arc,
1.62 + /// only to Edge.
1.63 ///
1.64 - /// In the sense of the LEMON each edge has a default
1.65 - /// direction (it should be in every computer implementation,
1.66 - /// because the order of edge's nodes defines an
1.67 - /// orientation). With the default orientation we can define that
1.68 - /// the directed arc is forward or backward directed. With the \c
1.69 - /// direction() and \c direct() function we can get the direction
1.70 - /// of the directed arc and we can direct an edge.
1.71 + /// In LEMON, each undirected edge has an inherent orientation.
1.72 + /// Thus it can defined if an arc is forward or backward oriented in
1.73 + /// an undirected graph with respect to this default oriantation of
1.74 + /// the represented edge.
1.75 + /// With the direction() and direct() functions the direction
1.76 + /// of an arc can be obtained and set, respectively.
1.77 ///
1.78 - /// The EdgeIt is an iterator for the edges. We can use
1.79 - /// the EdgeMap to map values for the edges. The InArcIt and
1.80 - /// OutArcIt iterates on the same edges but with opposite
1.81 - /// direction. The IncEdgeIt iterates also on the same edges
1.82 - /// as the OutArcIt and InArcIt but it is not convertible to Arc just
1.83 - /// to Edge.
1.84 + /// Only nodes and edges can be added to or removed from an undirected
1.85 + /// graph and the corresponding arcs are added or removed automatically.
1.86 + ///
1.87 + /// \sa Digraph
1.88 class Graph {
1.89 + private:
1.90 + /// Graphs are \e not copy constructible. Use DigraphCopy instead.
1.91 + Graph(const Graph&) {}
1.92 + /// \brief Assignment of a graph to another one is \e not allowed.
1.93 + /// Use DigraphCopy instead.
1.94 + void operator=(const Graph&) {}
1.95 +
1.96 public:
1.97 - /// \brief The undirected graph should be tagged by the
1.98 - /// UndirectedTag.
1.99 + /// Default constructor.
1.100 + Graph() {}
1.101 +
1.102 + /// \brief Undirected graphs should be tagged with \c UndirectedTag.
1.103 ///
1.104 - /// The undirected graph should be tagged by the UndirectedTag. This
1.105 - /// tag helps the enable_if technics to make compile time
1.106 + /// Undirected graphs should be tagged with \c UndirectedTag.
1.107 + ///
1.108 + /// This tag helps the \c enable_if technics to make compile time
1.109 /// specializations for undirected graphs.
1.110 typedef True UndirectedTag;
1.111
1.112 - /// \brief The base type of node iterators,
1.113 - /// or in other words, the trivial node iterator.
1.114 - ///
1.115 - /// This is the base type of each node iterator,
1.116 - /// thus each kind of node iterator converts to this.
1.117 - /// More precisely each kind of node iterator should be inherited
1.118 - /// from the trivial node iterator.
1.119 + /// The node type of the graph
1.120 +
1.121 + /// This class identifies a node of the graph. It also serves
1.122 + /// as a base class of the node iterators,
1.123 + /// thus they convert to this type.
1.124 class Node {
1.125 public:
1.126 /// Default constructor
1.127
1.128 - /// @warning The default constructor sets the iterator
1.129 - /// to an undefined value.
1.130 + /// Default constructor.
1.131 + /// \warning It sets the object to an undefined value.
1.132 Node() { }
1.133 /// Copy constructor.
1.134
1.135 @@ -95,40 +108,40 @@
1.136 ///
1.137 Node(const Node&) { }
1.138
1.139 - /// Invalid constructor \& conversion.
1.140 + /// %Invalid constructor \& conversion.
1.141
1.142 - /// This constructor initializes the iterator to be invalid.
1.143 + /// Initializes the object to be invalid.
1.144 /// \sa Invalid for more details.
1.145 Node(Invalid) { }
1.146 /// Equality operator
1.147
1.148 + /// Equality operator.
1.149 + ///
1.150 /// Two iterators are equal if and only if they point to the
1.151 - /// same object or both are invalid.
1.152 + /// same object or both are \c INVALID.
1.153 bool operator==(Node) const { return true; }
1.154
1.155 /// Inequality operator
1.156
1.157 - /// \sa operator==(Node n)
1.158 - ///
1.159 + /// Inequality operator.
1.160 bool operator!=(Node) const { return true; }
1.161
1.162 /// Artificial ordering operator.
1.163
1.164 - /// To allow the use of graph descriptors as key type in std::map or
1.165 - /// similar associative container we require this.
1.166 + /// Artificial ordering operator.
1.167 ///
1.168 - /// \note This operator only have to define some strict ordering of
1.169 + /// \note This operator only has to define some strict ordering of
1.170 /// the items; this order has nothing to do with the iteration
1.171 /// ordering of the items.
1.172 bool operator<(Node) const { return false; }
1.173
1.174 };
1.175
1.176 - /// This iterator goes through each node.
1.177 + /// Iterator class for the nodes.
1.178
1.179 - /// This iterator goes through each node.
1.180 - /// Its usage is quite simple, for example you can count the number
1.181 - /// of nodes in graph \c g of type \c Graph like this:
1.182 + /// This iterator goes through each node of the graph.
1.183 + /// Its usage is quite simple, for example, you can count the number
1.184 + /// of nodes in a graph \c g of type \c %Graph like this:
1.185 ///\code
1.186 /// int count=0;
1.187 /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
1.188 @@ -137,30 +150,28 @@
1.189 public:
1.190 /// Default constructor
1.191
1.192 - /// @warning The default constructor sets the iterator
1.193 - /// to an undefined value.
1.194 + /// Default constructor.
1.195 + /// \warning It sets the iterator to an undefined value.
1.196 NodeIt() { }
1.197 /// Copy constructor.
1.198
1.199 /// Copy constructor.
1.200 ///
1.201 NodeIt(const NodeIt& n) : Node(n) { }
1.202 - /// Invalid constructor \& conversion.
1.203 + /// %Invalid constructor \& conversion.
1.204
1.205 - /// Initialize the iterator to be invalid.
1.206 + /// Initializes the iterator to be invalid.
1.207 /// \sa Invalid for more details.
1.208 NodeIt(Invalid) { }
1.209 /// Sets the iterator to the first node.
1.210
1.211 - /// Sets the iterator to the first node of \c g.
1.212 + /// Sets the iterator to the first node of the given digraph.
1.213 ///
1.214 - NodeIt(const Graph&) { }
1.215 - /// Node -> NodeIt conversion.
1.216 + explicit NodeIt(const Graph&) { }
1.217 + /// Sets the iterator to the given node.
1.218
1.219 - /// Sets the iterator to the node of \c the graph pointed by
1.220 - /// the trivial iterator.
1.221 - /// This feature necessitates that each time we
1.222 - /// iterate the arc-set, the iteration order is the same.
1.223 + /// Sets the iterator to the given node of the given digraph.
1.224 + ///
1.225 NodeIt(const Graph&, const Node&) { }
1.226 /// Next node.
1.227
1.228 @@ -170,54 +181,55 @@
1.229 };
1.230
1.231
1.232 - /// The base type of the edge iterators.
1.233 + /// The edge type of the graph
1.234
1.235 - /// The base type of the edge iterators.
1.236 - ///
1.237 + /// This class identifies an edge of the graph. It also serves
1.238 + /// as a base class of the edge iterators,
1.239 + /// thus they will convert to this type.
1.240 class Edge {
1.241 public:
1.242 /// Default constructor
1.243
1.244 - /// @warning The default constructor sets the iterator
1.245 - /// to an undefined value.
1.246 + /// Default constructor.
1.247 + /// \warning It sets the object to an undefined value.
1.248 Edge() { }
1.249 /// Copy constructor.
1.250
1.251 /// Copy constructor.
1.252 ///
1.253 Edge(const Edge&) { }
1.254 - /// Initialize the iterator to be invalid.
1.255 + /// %Invalid constructor \& conversion.
1.256
1.257 - /// Initialize the iterator to be invalid.
1.258 - ///
1.259 + /// Initializes the object to be invalid.
1.260 + /// \sa Invalid for more details.
1.261 Edge(Invalid) { }
1.262 /// Equality operator
1.263
1.264 + /// Equality operator.
1.265 + ///
1.266 /// Two iterators are equal if and only if they point to the
1.267 - /// same object or both are invalid.
1.268 + /// same object or both are \c INVALID.
1.269 bool operator==(Edge) const { return true; }
1.270 /// Inequality operator
1.271
1.272 - /// \sa operator==(Edge n)
1.273 - ///
1.274 + /// Inequality operator.
1.275 bool operator!=(Edge) const { return true; }
1.276
1.277 /// Artificial ordering operator.
1.278
1.279 - /// To allow the use of graph descriptors as key type in std::map or
1.280 - /// similar associative container we require this.
1.281 + /// Artificial ordering operator.
1.282 ///
1.283 - /// \note This operator only have to define some strict ordering of
1.284 - /// the items; this order has nothing to do with the iteration
1.285 - /// ordering of the items.
1.286 + /// \note This operator only has to define some strict ordering of
1.287 + /// the edges; this order has nothing to do with the iteration
1.288 + /// ordering of the edges.
1.289 bool operator<(Edge) const { return false; }
1.290 };
1.291
1.292 - /// This iterator goes through each edge.
1.293 + /// Iterator class for the edges.
1.294
1.295 - /// This iterator goes through each edge of a graph.
1.296 - /// Its usage is quite simple, for example you can count the number
1.297 - /// of edges in a graph \c g of type \c Graph as follows:
1.298 + /// This iterator goes through each edge of the graph.
1.299 + /// Its usage is quite simple, for example, you can count the number
1.300 + /// of edges in a graph \c g of type \c %Graph as follows:
1.301 ///\code
1.302 /// int count=0;
1.303 /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
1.304 @@ -226,290 +238,285 @@
1.305 public:
1.306 /// Default constructor
1.307
1.308 - /// @warning The default constructor sets the iterator
1.309 - /// to an undefined value.
1.310 + /// Default constructor.
1.311 + /// \warning It sets the iterator to an undefined value.
1.312 EdgeIt() { }
1.313 /// Copy constructor.
1.314
1.315 /// Copy constructor.
1.316 ///
1.317 EdgeIt(const EdgeIt& e) : Edge(e) { }
1.318 - /// Initialize the iterator to be invalid.
1.319 + /// %Invalid constructor \& conversion.
1.320
1.321 - /// Initialize the iterator to be invalid.
1.322 + /// Initializes the iterator to be invalid.
1.323 + /// \sa Invalid for more details.
1.324 + EdgeIt(Invalid) { }
1.325 + /// Sets the iterator to the first edge.
1.326 +
1.327 + /// Sets the iterator to the first edge of the given graph.
1.328 ///
1.329 - EdgeIt(Invalid) { }
1.330 - /// This constructor sets the iterator to the first edge.
1.331 + explicit EdgeIt(const Graph&) { }
1.332 + /// Sets the iterator to the given edge.
1.333
1.334 - /// This constructor sets the iterator to the first edge.
1.335 - EdgeIt(const Graph&) { }
1.336 - /// Edge -> EdgeIt conversion
1.337 -
1.338 - /// Sets the iterator to the value of the trivial iterator.
1.339 - /// This feature necessitates that each time we
1.340 - /// iterate the edge-set, the iteration order is the
1.341 - /// same.
1.342 + /// Sets the iterator to the given edge of the given graph.
1.343 + ///
1.344 EdgeIt(const Graph&, const Edge&) { }
1.345 /// Next edge
1.346
1.347 /// Assign the iterator to the next edge.
1.348 + ///
1.349 EdgeIt& operator++() { return *this; }
1.350 };
1.351
1.352 - /// \brief This iterator goes trough the incident undirected
1.353 - /// arcs of a node.
1.354 - ///
1.355 - /// This iterator goes trough the incident edges
1.356 - /// of a certain node of a graph. You should assume that the
1.357 - /// loop arcs will be iterated twice.
1.358 - ///
1.359 - /// Its usage is quite simple, for example you can compute the
1.360 - /// degree (i.e. count the number of incident arcs of a node \c n
1.361 - /// in graph \c g of type \c Graph as follows.
1.362 + /// Iterator class for the incident edges of a node.
1.363 +
1.364 + /// This iterator goes trough the incident undirected edges
1.365 + /// of a certain node of a graph.
1.366 + /// Its usage is quite simple, for example, you can compute the
1.367 + /// degree (i.e. the number of incident edges) of a node \c n
1.368 + /// in a graph \c g of type \c %Graph as follows.
1.369 ///
1.370 ///\code
1.371 /// int count=0;
1.372 /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
1.373 ///\endcode
1.374 + ///
1.375 + /// \warning Loop edges will be iterated twice.
1.376 class IncEdgeIt : public Edge {
1.377 public:
1.378 /// Default constructor
1.379
1.380 - /// @warning The default constructor sets the iterator
1.381 - /// to an undefined value.
1.382 + /// Default constructor.
1.383 + /// \warning It sets the iterator to an undefined value.
1.384 IncEdgeIt() { }
1.385 /// Copy constructor.
1.386
1.387 /// Copy constructor.
1.388 ///
1.389 IncEdgeIt(const IncEdgeIt& e) : Edge(e) { }
1.390 - /// Initialize the iterator to be invalid.
1.391 + /// %Invalid constructor \& conversion.
1.392
1.393 - /// Initialize the iterator to be invalid.
1.394 + /// Initializes the iterator to be invalid.
1.395 + /// \sa Invalid for more details.
1.396 + IncEdgeIt(Invalid) { }
1.397 + /// Sets the iterator to the first incident edge.
1.398 +
1.399 + /// Sets the iterator to the first incident edge of the given node.
1.400 ///
1.401 - IncEdgeIt(Invalid) { }
1.402 - /// This constructor sets the iterator to first incident arc.
1.403 + IncEdgeIt(const Graph&, const Node&) { }
1.404 + /// Sets the iterator to the given edge.
1.405
1.406 - /// This constructor set the iterator to the first incident arc of
1.407 - /// the node.
1.408 - IncEdgeIt(const Graph&, const Node&) { }
1.409 - /// Edge -> IncEdgeIt conversion
1.410 + /// Sets the iterator to the given edge of the given graph.
1.411 + ///
1.412 + IncEdgeIt(const Graph&, const Edge&) { }
1.413 + /// Next incident edge
1.414
1.415 - /// Sets the iterator to the value of the trivial iterator \c e.
1.416 - /// This feature necessitates that each time we
1.417 - /// iterate the arc-set, the iteration order is the same.
1.418 - IncEdgeIt(const Graph&, const Edge&) { }
1.419 - /// Next incident arc
1.420 -
1.421 - /// Assign the iterator to the next incident arc
1.422 + /// Assign the iterator to the next incident edge
1.423 /// of the corresponding node.
1.424 IncEdgeIt& operator++() { return *this; }
1.425 };
1.426
1.427 - /// The directed arc type.
1.428 + /// The arc type of the graph
1.429
1.430 - /// The directed arc type. It can be converted to the
1.431 - /// edge or it should be inherited from the undirected
1.432 - /// edge.
1.433 + /// This class identifies a directed arc of the graph. It also serves
1.434 + /// as a base class of the arc iterators,
1.435 + /// thus they will convert to this type.
1.436 class Arc {
1.437 public:
1.438 /// Default constructor
1.439
1.440 - /// @warning The default constructor sets the iterator
1.441 - /// to an undefined value.
1.442 + /// Default constructor.
1.443 + /// \warning It sets the object to an undefined value.
1.444 Arc() { }
1.445 /// Copy constructor.
1.446
1.447 /// Copy constructor.
1.448 ///
1.449 Arc(const Arc&) { }
1.450 - /// Initialize the iterator to be invalid.
1.451 + /// %Invalid constructor \& conversion.
1.452
1.453 - /// Initialize the iterator to be invalid.
1.454 - ///
1.455 + /// Initializes the object to be invalid.
1.456 + /// \sa Invalid for more details.
1.457 Arc(Invalid) { }
1.458 /// Equality operator
1.459
1.460 + /// Equality operator.
1.461 + ///
1.462 /// Two iterators are equal if and only if they point to the
1.463 - /// same object or both are invalid.
1.464 + /// same object or both are \c INVALID.
1.465 bool operator==(Arc) const { return true; }
1.466 /// Inequality operator
1.467
1.468 - /// \sa operator==(Arc n)
1.469 - ///
1.470 + /// Inequality operator.
1.471 bool operator!=(Arc) const { return true; }
1.472
1.473 /// Artificial ordering operator.
1.474
1.475 - /// To allow the use of graph descriptors as key type in std::map or
1.476 - /// similar associative container we require this.
1.477 + /// Artificial ordering operator.
1.478 ///
1.479 - /// \note This operator only have to define some strict ordering of
1.480 - /// the items; this order has nothing to do with the iteration
1.481 - /// ordering of the items.
1.482 + /// \note This operator only has to define some strict ordering of
1.483 + /// the arcs; this order has nothing to do with the iteration
1.484 + /// ordering of the arcs.
1.485 bool operator<(Arc) const { return false; }
1.486
1.487 - /// Converison to Edge
1.488 + /// Converison to \c Edge
1.489 +
1.490 + /// Converison to \c Edge.
1.491 + ///
1.492 operator Edge() const { return Edge(); }
1.493 };
1.494 - /// This iterator goes through each directed arc.
1.495
1.496 - /// This iterator goes through each arc of a graph.
1.497 - /// Its usage is quite simple, for example you can count the number
1.498 - /// of arcs in a graph \c g of type \c Graph as follows:
1.499 + /// Iterator class for the arcs.
1.500 +
1.501 + /// This iterator goes through each directed arc of the graph.
1.502 + /// Its usage is quite simple, for example, you can count the number
1.503 + /// of arcs in a graph \c g of type \c %Graph as follows:
1.504 ///\code
1.505 /// int count=0;
1.506 - /// for(Graph::ArcIt e(g); e!=INVALID; ++e) ++count;
1.507 + /// for(Graph::ArcIt a(g); a!=INVALID; ++a) ++count;
1.508 ///\endcode
1.509 class ArcIt : public Arc {
1.510 public:
1.511 /// Default constructor
1.512
1.513 - /// @warning The default constructor sets the iterator
1.514 - /// to an undefined value.
1.515 + /// Default constructor.
1.516 + /// \warning It sets the iterator to an undefined value.
1.517 ArcIt() { }
1.518 /// Copy constructor.
1.519
1.520 /// Copy constructor.
1.521 ///
1.522 ArcIt(const ArcIt& e) : Arc(e) { }
1.523 - /// Initialize the iterator to be invalid.
1.524 + /// %Invalid constructor \& conversion.
1.525
1.526 - /// Initialize the iterator to be invalid.
1.527 + /// Initializes the iterator to be invalid.
1.528 + /// \sa Invalid for more details.
1.529 + ArcIt(Invalid) { }
1.530 + /// Sets the iterator to the first arc.
1.531 +
1.532 + /// Sets the iterator to the first arc of the given graph.
1.533 ///
1.534 - ArcIt(Invalid) { }
1.535 - /// This constructor sets the iterator to the first arc.
1.536 + explicit ArcIt(const Graph &g) { ignore_unused_variable_warning(g); }
1.537 + /// Sets the iterator to the given arc.
1.538
1.539 - /// This constructor sets the iterator to the first arc of \c g.
1.540 - ///@param g the graph
1.541 - ArcIt(const Graph &g) { ignore_unused_variable_warning(g); }
1.542 - /// Arc -> ArcIt conversion
1.543 -
1.544 - /// Sets the iterator to the value of the trivial iterator \c e.
1.545 - /// This feature necessitates that each time we
1.546 - /// iterate the arc-set, the iteration order is the same.
1.547 + /// Sets the iterator to the given arc of the given graph.
1.548 + ///
1.549 ArcIt(const Graph&, const Arc&) { }
1.550 - ///Next arc
1.551 + /// Next arc
1.552
1.553 /// Assign the iterator to the next arc.
1.554 + ///
1.555 ArcIt& operator++() { return *this; }
1.556 };
1.557
1.558 - /// This iterator goes trough the outgoing directed arcs of a node.
1.559 + /// Iterator class for the outgoing arcs of a node.
1.560
1.561 - /// This iterator goes trough the \e outgoing arcs of a certain node
1.562 - /// of a graph.
1.563 - /// Its usage is quite simple, for example you can count the number
1.564 + /// This iterator goes trough the \e outgoing directed arcs of a
1.565 + /// certain node of a graph.
1.566 + /// Its usage is quite simple, for example, you can count the number
1.567 /// of outgoing arcs of a node \c n
1.568 - /// in graph \c g of type \c Graph as follows.
1.569 + /// in a graph \c g of type \c %Graph as follows.
1.570 ///\code
1.571 /// int count=0;
1.572 - /// for (Graph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
1.573 + /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
1.574 ///\endcode
1.575 -
1.576 class OutArcIt : public Arc {
1.577 public:
1.578 /// Default constructor
1.579
1.580 - /// @warning The default constructor sets the iterator
1.581 - /// to an undefined value.
1.582 + /// Default constructor.
1.583 + /// \warning It sets the iterator to an undefined value.
1.584 OutArcIt() { }
1.585 /// Copy constructor.
1.586
1.587 /// Copy constructor.
1.588 ///
1.589 OutArcIt(const OutArcIt& e) : Arc(e) { }
1.590 - /// Initialize the iterator to be invalid.
1.591 + /// %Invalid constructor \& conversion.
1.592
1.593 - /// Initialize the iterator to be invalid.
1.594 + /// Initializes the iterator to be invalid.
1.595 + /// \sa Invalid for more details.
1.596 + OutArcIt(Invalid) { }
1.597 + /// Sets the iterator to the first outgoing arc.
1.598 +
1.599 + /// Sets the iterator to the first outgoing arc of the given node.
1.600 ///
1.601 - OutArcIt(Invalid) { }
1.602 - /// This constructor sets the iterator to the first outgoing arc.
1.603 -
1.604 - /// This constructor sets the iterator to the first outgoing arc of
1.605 - /// the node.
1.606 - ///@param n the node
1.607 - ///@param g the graph
1.608 OutArcIt(const Graph& n, const Node& g) {
1.609 ignore_unused_variable_warning(n);
1.610 ignore_unused_variable_warning(g);
1.611 }
1.612 - /// Arc -> OutArcIt conversion
1.613 + /// Sets the iterator to the given arc.
1.614
1.615 - /// Sets the iterator to the value of the trivial iterator.
1.616 - /// This feature necessitates that each time we
1.617 - /// iterate the arc-set, the iteration order is the same.
1.618 + /// Sets the iterator to the given arc of the given graph.
1.619 + ///
1.620 OutArcIt(const Graph&, const Arc&) { }
1.621 - ///Next outgoing arc
1.622 + /// Next outgoing arc
1.623
1.624 /// Assign the iterator to the next
1.625 /// outgoing arc of the corresponding node.
1.626 OutArcIt& operator++() { return *this; }
1.627 };
1.628
1.629 - /// This iterator goes trough the incoming directed arcs of a node.
1.630 + /// Iterator class for the incoming arcs of a node.
1.631
1.632 - /// This iterator goes trough the \e incoming arcs of a certain node
1.633 - /// of a graph.
1.634 - /// Its usage is quite simple, for example you can count the number
1.635 - /// of outgoing arcs of a node \c n
1.636 - /// in graph \c g of type \c Graph as follows.
1.637 + /// This iterator goes trough the \e incoming directed arcs of a
1.638 + /// certain node of a graph.
1.639 + /// Its usage is quite simple, for example, you can count the number
1.640 + /// of incoming arcs of a node \c n
1.641 + /// in a graph \c g of type \c %Graph as follows.
1.642 ///\code
1.643 /// int count=0;
1.644 - /// for(Graph::InArcIt e(g, n); e!=INVALID; ++e) ++count;
1.645 + /// for (Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
1.646 ///\endcode
1.647 -
1.648 class InArcIt : public Arc {
1.649 public:
1.650 /// Default constructor
1.651
1.652 - /// @warning The default constructor sets the iterator
1.653 - /// to an undefined value.
1.654 + /// Default constructor.
1.655 + /// \warning It sets the iterator to an undefined value.
1.656 InArcIt() { }
1.657 /// Copy constructor.
1.658
1.659 /// Copy constructor.
1.660 ///
1.661 InArcIt(const InArcIt& e) : Arc(e) { }
1.662 - /// Initialize the iterator to be invalid.
1.663 + /// %Invalid constructor \& conversion.
1.664
1.665 - /// Initialize the iterator to be invalid.
1.666 + /// Initializes the iterator to be invalid.
1.667 + /// \sa Invalid for more details.
1.668 + InArcIt(Invalid) { }
1.669 + /// Sets the iterator to the first incoming arc.
1.670 +
1.671 + /// Sets the iterator to the first incoming arc of the given node.
1.672 ///
1.673 - InArcIt(Invalid) { }
1.674 - /// This constructor sets the iterator to first incoming arc.
1.675 -
1.676 - /// This constructor set the iterator to the first incoming arc of
1.677 - /// the node.
1.678 - ///@param n the node
1.679 - ///@param g the graph
1.680 InArcIt(const Graph& g, const Node& n) {
1.681 ignore_unused_variable_warning(n);
1.682 ignore_unused_variable_warning(g);
1.683 }
1.684 - /// Arc -> InArcIt conversion
1.685 + /// Sets the iterator to the given arc.
1.686
1.687 - /// Sets the iterator to the value of the trivial iterator \c e.
1.688 - /// This feature necessitates that each time we
1.689 - /// iterate the arc-set, the iteration order is the same.
1.690 + /// Sets the iterator to the given arc of the given graph.
1.691 + ///
1.692 InArcIt(const Graph&, const Arc&) { }
1.693 /// Next incoming arc
1.694
1.695 - /// Assign the iterator to the next inarc of the corresponding node.
1.696 - ///
1.697 + /// Assign the iterator to the next
1.698 + /// incoming arc of the corresponding node.
1.699 InArcIt& operator++() { return *this; }
1.700 };
1.701
1.702 - /// \brief Reference map of the nodes to type \c T.
1.703 + /// \brief Standard graph map type for the nodes.
1.704 ///
1.705 - /// Reference map of the nodes to type \c T.
1.706 + /// Standard graph map type for the nodes.
1.707 + /// It conforms to the ReferenceMap concept.
1.708 template<class T>
1.709 class NodeMap : public ReferenceMap<Node, T, T&, const T&>
1.710 {
1.711 public:
1.712
1.713 - ///\e
1.714 - NodeMap(const Graph&) { }
1.715 - ///\e
1.716 + /// Constructor
1.717 + explicit NodeMap(const Graph&) { }
1.718 + /// Constructor with given initial value
1.719 NodeMap(const Graph&, T) { }
1.720
1.721 private:
1.722 @@ -524,18 +531,20 @@
1.723 }
1.724 };
1.725
1.726 - /// \brief Reference map of the arcs to type \c T.
1.727 + /// \brief Standard graph map type for the arcs.
1.728 ///
1.729 - /// Reference map of the arcs to type \c T.
1.730 + /// Standard graph map type for the arcs.
1.731 + /// It conforms to the ReferenceMap concept.
1.732 template<class T>
1.733 class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
1.734 {
1.735 public:
1.736
1.737 - ///\e
1.738 - ArcMap(const Graph&) { }
1.739 - ///\e
1.740 + /// Constructor
1.741 + explicit ArcMap(const Graph&) { }
1.742 + /// Constructor with given initial value
1.743 ArcMap(const Graph&, T) { }
1.744 +
1.745 private:
1.746 ///Copy constructor
1.747 ArcMap(const ArcMap& em) :
1.748 @@ -548,18 +557,20 @@
1.749 }
1.750 };
1.751
1.752 - /// Reference map of the edges to type \c T.
1.753 -
1.754 - /// Reference map of the edges to type \c T.
1.755 + /// \brief Standard graph map type for the edges.
1.756 + ///
1.757 + /// Standard graph map type for the edges.
1.758 + /// It conforms to the ReferenceMap concept.
1.759 template<class T>
1.760 class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
1.761 {
1.762 public:
1.763
1.764 - ///\e
1.765 - EdgeMap(const Graph&) { }
1.766 - ///\e
1.767 + /// Constructor
1.768 + explicit EdgeMap(const Graph&) { }
1.769 + /// Constructor with given initial value
1.770 EdgeMap(const Graph&, T) { }
1.771 +
1.772 private:
1.773 ///Copy constructor
1.774 EdgeMap(const EdgeMap& em) :
1.775 @@ -572,107 +583,124 @@
1.776 }
1.777 };
1.778
1.779 - /// \brief Direct the given edge.
1.780 + /// \brief The first node of the edge.
1.781 ///
1.782 - /// Direct the given edge. The returned arc source
1.783 - /// will be the given node.
1.784 - Arc direct(const Edge&, const Node&) const {
1.785 - return INVALID;
1.786 - }
1.787 -
1.788 - /// \brief Direct the given edge.
1.789 + /// Returns the first node of the given edge.
1.790 ///
1.791 - /// Direct the given edge. The returned arc
1.792 - /// represents the given edge and the direction comes
1.793 - /// from the bool parameter. The source of the edge and
1.794 - /// the directed arc is the same when the given bool is true.
1.795 - Arc direct(const Edge&, bool) const {
1.796 - return INVALID;
1.797 - }
1.798 -
1.799 - /// \brief Returns true if the arc has default orientation.
1.800 - ///
1.801 - /// Returns whether the given directed arc is same orientation as
1.802 - /// the corresponding edge's default orientation.
1.803 - bool direction(Arc) const { return true; }
1.804 -
1.805 - /// \brief Returns the opposite directed arc.
1.806 - ///
1.807 - /// Returns the opposite directed arc.
1.808 - Arc oppositeArc(Arc) const { return INVALID; }
1.809 -
1.810 - /// \brief Opposite node on an arc
1.811 - ///
1.812 - /// \return The opposite of the given node on the given edge.
1.813 - Node oppositeNode(Node, Edge) const { return INVALID; }
1.814 -
1.815 - /// \brief First node of the edge.
1.816 - ///
1.817 - /// \return The first node of the given edge.
1.818 - ///
1.819 - /// Naturally edges don't have direction and thus
1.820 - /// don't have source and target node. However we use \c u() and \c v()
1.821 - /// methods to query the two nodes of the arc. The direction of the
1.822 - /// arc which arises this way is called the inherent direction of the
1.823 - /// edge, and is used to define the "default" direction
1.824 - /// of the directed versions of the arcs.
1.825 + /// Edges don't have source and target nodes, however, methods
1.826 + /// u() and v() are used to query the two end-nodes of an edge.
1.827 + /// The orientation of an edge that arises this way is called
1.828 + /// the inherent direction, it is used to define the default
1.829 + /// direction for the corresponding arcs.
1.830 /// \sa v()
1.831 /// \sa direction()
1.832 Node u(Edge) const { return INVALID; }
1.833
1.834 - /// \brief Second node of the edge.
1.835 + /// \brief The second node of the edge.
1.836 ///
1.837 - /// \return The second node of the given edge.
1.838 + /// Returns the second node of the given edge.
1.839 ///
1.840 - /// Naturally edges don't have direction and thus
1.841 - /// don't have source and target node. However we use \c u() and \c v()
1.842 - /// methods to query the two nodes of the arc. The direction of the
1.843 - /// arc which arises this way is called the inherent direction of the
1.844 - /// edge, and is used to define the "default" direction
1.845 - /// of the directed versions of the arcs.
1.846 + /// Edges don't have source and target nodes, however, methods
1.847 + /// u() and v() are used to query the two end-nodes of an edge.
1.848 + /// The orientation of an edge that arises this way is called
1.849 + /// the inherent direction, it is used to define the default
1.850 + /// direction for the corresponding arcs.
1.851 /// \sa u()
1.852 /// \sa direction()
1.853 Node v(Edge) const { return INVALID; }
1.854
1.855 - /// \brief Source node of the directed arc.
1.856 + /// \brief The source node of the arc.
1.857 + ///
1.858 + /// Returns the source node of the given arc.
1.859 Node source(Arc) const { return INVALID; }
1.860
1.861 - /// \brief Target node of the directed arc.
1.862 + /// \brief The target node of the arc.
1.863 + ///
1.864 + /// Returns the target node of the given arc.
1.865 Node target(Arc) const { return INVALID; }
1.866
1.867 - /// \brief Returns the id of the node.
1.868 + /// \brief The ID of the node.
1.869 + ///
1.870 + /// Returns the ID of the given node.
1.871 int id(Node) const { return -1; }
1.872
1.873 - /// \brief Returns the id of the edge.
1.874 + /// \brief The ID of the edge.
1.875 + ///
1.876 + /// Returns the ID of the given edge.
1.877 int id(Edge) const { return -1; }
1.878
1.879 - /// \brief Returns the id of the arc.
1.880 + /// \brief The ID of the arc.
1.881 + ///
1.882 + /// Returns the ID of the given arc.
1.883 int id(Arc) const { return -1; }
1.884
1.885 - /// \brief Returns the node with the given id.
1.886 + /// \brief The node with the given ID.
1.887 ///
1.888 - /// \pre The argument should be a valid node id in the graph.
1.889 + /// Returns the node with the given ID.
1.890 + /// \pre The argument should be a valid node ID in the graph.
1.891 Node nodeFromId(int) const { return INVALID; }
1.892
1.893 - /// \brief Returns the edge with the given id.
1.894 + /// \brief The edge with the given ID.
1.895 ///
1.896 - /// \pre The argument should be a valid edge id in the graph.
1.897 + /// Returns the edge with the given ID.
1.898 + /// \pre The argument should be a valid edge ID in the graph.
1.899 Edge edgeFromId(int) const { return INVALID; }
1.900
1.901 - /// \brief Returns the arc with the given id.
1.902 + /// \brief The arc with the given ID.
1.903 ///
1.904 - /// \pre The argument should be a valid arc id in the graph.
1.905 + /// Returns the arc with the given ID.
1.906 + /// \pre The argument should be a valid arc ID in the graph.
1.907 Arc arcFromId(int) const { return INVALID; }
1.908
1.909 - /// \brief Returns an upper bound on the node IDs.
1.910 + /// \brief An upper bound on the node IDs.
1.911 + ///
1.912 + /// Returns an upper bound on the node IDs.
1.913 int maxNodeId() const { return -1; }
1.914
1.915 - /// \brief Returns an upper bound on the edge IDs.
1.916 + /// \brief An upper bound on the edge IDs.
1.917 + ///
1.918 + /// Returns an upper bound on the edge IDs.
1.919 int maxEdgeId() const { return -1; }
1.920
1.921 - /// \brief Returns an upper bound on the arc IDs.
1.922 + /// \brief An upper bound on the arc IDs.
1.923 + ///
1.924 + /// Returns an upper bound on the arc IDs.
1.925 int maxArcId() const { return -1; }
1.926
1.927 + /// \brief The direction of the arc.
1.928 + ///
1.929 + /// Returns \c true if the direction of the given arc is the same as
1.930 + /// the inherent orientation of the represented edge.
1.931 + bool direction(Arc) const { return true; }
1.932 +
1.933 + /// \brief Direct the edge.
1.934 + ///
1.935 + /// Direct the given edge. The returned arc
1.936 + /// represents the given edge and its direction comes
1.937 + /// from the bool parameter. If it is \c true, then the direction
1.938 + /// of the arc is the same as the inherent orientation of the edge.
1.939 + Arc direct(Edge, bool) const {
1.940 + return INVALID;
1.941 + }
1.942 +
1.943 + /// \brief Direct the edge.
1.944 + ///
1.945 + /// Direct the given edge. The returned arc represents the given
1.946 + /// edge and its source node is the given node.
1.947 + Arc direct(Edge, Node) const {
1.948 + return INVALID;
1.949 + }
1.950 +
1.951 + /// \brief The oppositely directed arc.
1.952 + ///
1.953 + /// Returns the oppositely directed arc representing the same edge.
1.954 + Arc oppositeArc(Arc) const { return INVALID; }
1.955 +
1.956 + /// \brief The opposite node on the edge.
1.957 + ///
1.958 + /// Returns the opposite node on the given edge.
1.959 + Node oppositeNode(Node, Edge) const { return INVALID; }
1.960 +
1.961 void first(Node&) const {}
1.962 void next(Node&) const {}
1.963
1.964 @@ -705,47 +733,39 @@
1.965 // Dummy parameter.
1.966 int maxId(Arc) const { return -1; }
1.967
1.968 - /// \brief Base node of the iterator
1.969 + /// \brief The base node of the iterator.
1.970 ///
1.971 - /// Returns the base node (the source in this case) of the iterator
1.972 - Node baseNode(OutArcIt e) const {
1.973 - return source(e);
1.974 - }
1.975 - /// \brief Running node of the iterator
1.976 + /// Returns the base node of the given incident edge iterator.
1.977 + Node baseNode(IncEdgeIt) const { return INVALID; }
1.978 +
1.979 + /// \brief The running node of the iterator.
1.980 ///
1.981 - /// Returns the running node (the target in this case) of the
1.982 - /// iterator
1.983 - Node runningNode(OutArcIt e) const {
1.984 - return target(e);
1.985 - }
1.986 + /// Returns the running node of the given incident edge iterator.
1.987 + Node runningNode(IncEdgeIt) const { return INVALID; }
1.988
1.989 - /// \brief Base node of the iterator
1.990 + /// \brief The base node of the iterator.
1.991 ///
1.992 - /// Returns the base node (the target in this case) of the iterator
1.993 - Node baseNode(InArcIt e) const {
1.994 - return target(e);
1.995 - }
1.996 - /// \brief Running node of the iterator
1.997 + /// Returns the base node of the given outgoing arc iterator
1.998 + /// (i.e. the source node of the corresponding arc).
1.999 + Node baseNode(OutArcIt) const { return INVALID; }
1.1000 +
1.1001 + /// \brief The running node of the iterator.
1.1002 ///
1.1003 - /// Returns the running node (the source in this case) of the
1.1004 - /// iterator
1.1005 - Node runningNode(InArcIt e) const {
1.1006 - return source(e);
1.1007 - }
1.1008 + /// Returns the running node of the given outgoing arc iterator
1.1009 + /// (i.e. the target node of the corresponding arc).
1.1010 + Node runningNode(OutArcIt) const { return INVALID; }
1.1011
1.1012 - /// \brief Base node of the iterator
1.1013 + /// \brief The base node of the iterator.
1.1014 ///
1.1015 - /// Returns the base node of the iterator
1.1016 - Node baseNode(IncEdgeIt) const {
1.1017 - return INVALID;
1.1018 - }
1.1019 + /// Returns the base node of the given incomming arc iterator
1.1020 + /// (i.e. the target node of the corresponding arc).
1.1021 + Node baseNode(InArcIt) const { return INVALID; }
1.1022
1.1023 - /// \brief Running node of the iterator
1.1024 + /// \brief The running node of the iterator.
1.1025 ///
1.1026 - /// Returns the running node of the iterator
1.1027 - Node runningNode(IncEdgeIt) const {
1.1028 - return INVALID;
1.1029 - }
1.1030 + /// Returns the running node of the given incomming arc iterator
1.1031 + /// (i.e. the source node of the corresponding arc).
1.1032 + Node runningNode(InArcIt) const { return INVALID; }
1.1033
1.1034 template <typename _Graph>
1.1035 struct Constraints {