[959] | 1 | /* -*- C++ -*- |
---|
| 2 | * |
---|
[1956] | 3 | * This file is a part of LEMON, a generic C++ optimization library |
---|
| 4 | * |
---|
| 5 | * Copyright (C) 2003-2006 |
---|
| 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
---|
[1359] | 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). |
---|
[959] | 8 | * |
---|
| 9 | * Permission to use, modify and distribute this software is granted |
---|
| 10 | * provided that this copyright notice appears in all copies. For |
---|
| 11 | * precise terms see the accompanying LICENSE file. |
---|
| 12 | * |
---|
| 13 | * This software is provided "AS IS" with no warranty of any kind, |
---|
| 14 | * express or implied, and with no claim as to its suitability for any |
---|
| 15 | * purpose. |
---|
| 16 | * |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | #ifndef LEMON_CONCEPT_GRAPH_H |
---|
| 20 | #define LEMON_CONCEPT_GRAPH_H |
---|
| 21 | |
---|
[1030] | 22 | ///\ingroup graph_concepts |
---|
[959] | 23 | ///\file |
---|
| 24 | ///\brief Declaration of Graph. |
---|
| 25 | |
---|
[1993] | 26 | #include <lemon/bits/invalid.h> |
---|
| 27 | #include <lemon/bits/utility.h> |
---|
[959] | 28 | #include <lemon/concept/maps.h> |
---|
| 29 | #include <lemon/concept_check.h> |
---|
| 30 | #include <lemon/concept/graph_component.h> |
---|
| 31 | |
---|
| 32 | namespace lemon { |
---|
| 33 | namespace concept { |
---|
[1136] | 34 | |
---|
[959] | 35 | |
---|
[961] | 36 | /**************** The full-featured graph concepts ****************/ |
---|
[959] | 37 | |
---|
[1136] | 38 | |
---|
[1760] | 39 | // \brief Modular static graph class. |
---|
| 40 | // |
---|
| 41 | // It should be the same as the \c StaticGraph class. |
---|
[1136] | 42 | class _StaticGraph |
---|
[961] | 43 | : virtual public BaseGraphComponent, |
---|
[1426] | 44 | public IterableGraphComponent, public MappableGraphComponent { |
---|
[959] | 45 | public: |
---|
[1448] | 46 | |
---|
[959] | 47 | typedef BaseGraphComponent::Node Node; |
---|
| 48 | typedef BaseGraphComponent::Edge Edge; |
---|
| 49 | |
---|
[989] | 50 | template <typename _Graph> |
---|
| 51 | struct Constraints { |
---|
[1426] | 52 | void constraints() { |
---|
| 53 | checkConcept<IterableGraphComponent, _Graph>(); |
---|
| 54 | checkConcept<MappableGraphComponent, _Graph>(); |
---|
| 55 | } |
---|
[989] | 56 | }; |
---|
[959] | 57 | }; |
---|
| 58 | |
---|
[1760] | 59 | // \brief Modular extendable graph class. |
---|
| 60 | // |
---|
| 61 | // It should be the same as the \c ExtendableGraph class. |
---|
[1136] | 62 | class _ExtendableGraph |
---|
| 63 | : virtual public BaseGraphComponent, public _StaticGraph, |
---|
[1426] | 64 | public ExtendableGraphComponent, public ClearableGraphComponent { |
---|
[959] | 65 | public: |
---|
| 66 | typedef BaseGraphComponent::Node Node; |
---|
| 67 | typedef BaseGraphComponent::Edge Edge; |
---|
| 68 | |
---|
[989] | 69 | template <typename _Graph> |
---|
| 70 | struct Constraints { |
---|
[1426] | 71 | void constraints() { |
---|
| 72 | checkConcept<_StaticGraph, _Graph >(); |
---|
| 73 | checkConcept<ExtendableGraphComponent, _Graph >(); |
---|
| 74 | checkConcept<ClearableGraphComponent, _Graph >(); |
---|
| 75 | } |
---|
[989] | 76 | }; |
---|
[959] | 77 | }; |
---|
| 78 | |
---|
[1760] | 79 | // \brief Modular erasable graph class. |
---|
| 80 | // |
---|
| 81 | // It should be the same as the \c ErasableGraph class. |
---|
[1136] | 82 | class _ErasableGraph |
---|
| 83 | : virtual public BaseGraphComponent, public _ExtendableGraph, |
---|
[1426] | 84 | public ErasableGraphComponent { |
---|
[959] | 85 | public: |
---|
| 86 | typedef BaseGraphComponent::Node Node; |
---|
| 87 | typedef BaseGraphComponent::Edge Edge; |
---|
| 88 | |
---|
[989] | 89 | template <typename _Graph> |
---|
| 90 | struct Constraints { |
---|
[1426] | 91 | void constraints() { |
---|
| 92 | checkConcept<_ExtendableGraph, _Graph >(); |
---|
| 93 | checkConcept<ErasableGraphComponent, _Graph >(); |
---|
| 94 | } |
---|
[989] | 95 | }; |
---|
[959] | 96 | }; |
---|
| 97 | |
---|
[1620] | 98 | /// \addtogroup graph_concepts |
---|
| 99 | /// @{ |
---|
| 100 | |
---|
[1136] | 101 | /// An empty static graph class. |
---|
| 102 | |
---|
| 103 | /// This class provides all the common features of a graph structure, |
---|
| 104 | /// however completely without implementations and real data structures |
---|
| 105 | /// behind the interface. |
---|
| 106 | /// All graph algorithms should compile with this class, but it will not |
---|
| 107 | /// run properly, of course. |
---|
| 108 | /// |
---|
| 109 | /// It can be used for checking the interface compatibility, |
---|
| 110 | /// or it can serve as a skeleton of a new graph structure. |
---|
| 111 | /// |
---|
| 112 | /// Also, you will find here the full documentation of a certain graph |
---|
| 113 | /// feature, the documentation of a real graph imlementation |
---|
| 114 | /// like @ref ListGraph or |
---|
| 115 | /// @ref SmartGraph will just refer to this structure. |
---|
| 116 | /// |
---|
| 117 | /// \todo A pages describing the concept of concept description would |
---|
| 118 | /// be nice. |
---|
| 119 | class StaticGraph |
---|
| 120 | { |
---|
[2090] | 121 | // ///Copy consructor. |
---|
| 122 | |
---|
| 123 | // ///\todo It is not clear, what we expect from a copy constructor. |
---|
| 124 | // ///E.g. How to assign the nodes/edges to each other? What about maps? |
---|
| 125 | // StaticGraph(const StaticGraph& g) { } |
---|
[1136] | 126 | public: |
---|
[1448] | 127 | ///\e |
---|
| 128 | |
---|
[1136] | 129 | /// Defalult constructor. |
---|
| 130 | |
---|
| 131 | /// Defalult constructor. |
---|
| 132 | /// |
---|
| 133 | StaticGraph() { } |
---|
| 134 | |
---|
| 135 | /// The base type of node iterators, |
---|
| 136 | /// or in other words, the trivial node iterator. |
---|
| 137 | |
---|
| 138 | /// This is the base type of each node iterator, |
---|
| 139 | /// thus each kind of node iterator converts to this. |
---|
| 140 | /// More precisely each kind of node iterator should be inherited |
---|
| 141 | /// from the trivial node iterator. |
---|
| 142 | class Node { |
---|
| 143 | public: |
---|
[1426] | 144 | /// Default constructor |
---|
[1136] | 145 | |
---|
[1426] | 146 | /// @warning The default constructor sets the iterator |
---|
| 147 | /// to an undefined value. |
---|
| 148 | Node() { } |
---|
| 149 | /// Copy constructor. |
---|
[1136] | 150 | |
---|
[1426] | 151 | /// Copy constructor. |
---|
| 152 | /// |
---|
| 153 | Node(const Node&) { } |
---|
[1136] | 154 | |
---|
[1426] | 155 | /// Invalid constructor \& conversion. |
---|
[1136] | 156 | |
---|
[1426] | 157 | /// This constructor initializes the iterator to be invalid. |
---|
| 158 | /// \sa Invalid for more details. |
---|
| 159 | Node(Invalid) { } |
---|
| 160 | /// Equality operator |
---|
[1136] | 161 | |
---|
[1426] | 162 | /// Two iterators are equal if and only if they point to the |
---|
| 163 | /// same object or both are invalid. |
---|
| 164 | bool operator==(Node) const { return true; } |
---|
[1136] | 165 | |
---|
[1426] | 166 | /// Inequality operator |
---|
| 167 | |
---|
| 168 | /// \sa operator==(Node n) |
---|
| 169 | /// |
---|
| 170 | bool operator!=(Node) const { return true; } |
---|
[1136] | 171 | |
---|
[1622] | 172 | /// Artificial ordering operator. |
---|
| 173 | |
---|
| 174 | /// To allow the use of graph descriptors as key type in std::map or |
---|
| 175 | /// similar associative container we require this. |
---|
| 176 | /// |
---|
| 177 | /// \note This operator only have to define some strict ordering of |
---|
| 178 | /// the items; this order has nothing to do with the iteration |
---|
| 179 | /// ordering of the items. |
---|
| 180 | /// |
---|
| 181 | /// \bug This is a technical requirement. Do we really need this? |
---|
| 182 | bool operator<(Node) const { return false; } |
---|
| 183 | |
---|
[1136] | 184 | }; |
---|
| 185 | |
---|
| 186 | /// This iterator goes through each node. |
---|
| 187 | |
---|
| 188 | /// This iterator goes through each node. |
---|
| 189 | /// Its usage is quite simple, for example you can count the number |
---|
| 190 | /// of nodes in graph \c g of type \c Graph like this: |
---|
[1946] | 191 | ///\code |
---|
[1136] | 192 | /// int count=0; |
---|
[1426] | 193 | /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count; |
---|
[1946] | 194 | ///\endcode |
---|
[1136] | 195 | class NodeIt : public Node { |
---|
| 196 | public: |
---|
[1426] | 197 | /// Default constructor |
---|
[1136] | 198 | |
---|
[1426] | 199 | /// @warning The default constructor sets the iterator |
---|
| 200 | /// to an undefined value. |
---|
| 201 | NodeIt() { } |
---|
| 202 | /// Copy constructor. |
---|
| 203 | |
---|
| 204 | /// Copy constructor. |
---|
| 205 | /// |
---|
| 206 | NodeIt(const NodeIt& n) : Node(n) { } |
---|
| 207 | /// Invalid constructor \& conversion. |
---|
[1136] | 208 | |
---|
[1426] | 209 | /// Initialize the iterator to be invalid. |
---|
| 210 | /// \sa Invalid for more details. |
---|
| 211 | NodeIt(Invalid) { } |
---|
| 212 | /// Sets the iterator to the first node. |
---|
[1136] | 213 | |
---|
[1426] | 214 | /// Sets the iterator to the first node of \c g. |
---|
| 215 | /// |
---|
| 216 | NodeIt(const StaticGraph&) { } |
---|
| 217 | /// Node -> NodeIt conversion. |
---|
[1136] | 218 | |
---|
[1470] | 219 | /// Sets the iterator to the node of \c the graph pointed by |
---|
| 220 | /// the trivial iterator. |
---|
[1426] | 221 | /// This feature necessitates that each time we |
---|
| 222 | /// iterate the edge-set, the iteration order is the same. |
---|
[1470] | 223 | NodeIt(const StaticGraph&, const Node&) { } |
---|
[1426] | 224 | /// Next node. |
---|
[1136] | 225 | |
---|
[1426] | 226 | /// Assign the iterator to the next node. |
---|
| 227 | /// |
---|
| 228 | NodeIt& operator++() { return *this; } |
---|
[1136] | 229 | }; |
---|
| 230 | |
---|
| 231 | |
---|
| 232 | /// The base type of the edge iterators. |
---|
| 233 | |
---|
| 234 | /// The base type of the edge iterators. |
---|
| 235 | /// |
---|
| 236 | class Edge { |
---|
| 237 | public: |
---|
[1426] | 238 | /// Default constructor |
---|
[1136] | 239 | |
---|
[1426] | 240 | /// @warning The default constructor sets the iterator |
---|
| 241 | /// to an undefined value. |
---|
| 242 | Edge() { } |
---|
| 243 | /// Copy constructor. |
---|
[1136] | 244 | |
---|
[1426] | 245 | /// Copy constructor. |
---|
| 246 | /// |
---|
| 247 | Edge(const Edge&) { } |
---|
| 248 | /// Initialize the iterator to be invalid. |
---|
[1136] | 249 | |
---|
[1426] | 250 | /// Initialize the iterator to be invalid. |
---|
| 251 | /// |
---|
| 252 | Edge(Invalid) { } |
---|
| 253 | /// Equality operator |
---|
[1136] | 254 | |
---|
[1426] | 255 | /// Two iterators are equal if and only if they point to the |
---|
| 256 | /// same object or both are invalid. |
---|
| 257 | bool operator==(Edge) const { return true; } |
---|
| 258 | /// Inequality operator |
---|
[1136] | 259 | |
---|
[1620] | 260 | /// \sa operator==(Edge n) |
---|
[1426] | 261 | /// |
---|
| 262 | bool operator!=(Edge) const { return true; } |
---|
[1622] | 263 | |
---|
| 264 | /// Artificial ordering operator. |
---|
| 265 | |
---|
| 266 | /// To allow the use of graph descriptors as key type in std::map or |
---|
| 267 | /// similar associative container we require this. |
---|
| 268 | /// |
---|
| 269 | /// \note This operator only have to define some strict ordering of |
---|
| 270 | /// the items; this order has nothing to do with the iteration |
---|
| 271 | /// ordering of the items. |
---|
| 272 | /// |
---|
| 273 | /// \bug This is a technical requirement. Do we really need this? |
---|
| 274 | bool operator<(Edge) const { return false; } |
---|
[1136] | 275 | }; |
---|
| 276 | |
---|
| 277 | /// This iterator goes trough the outgoing edges of a node. |
---|
| 278 | |
---|
| 279 | /// This iterator goes trough the \e outgoing edges of a certain node |
---|
| 280 | /// of a graph. |
---|
| 281 | /// Its usage is quite simple, for example you can count the number |
---|
| 282 | /// of outgoing edges of a node \c n |
---|
| 283 | /// in graph \c g of type \c Graph as follows. |
---|
[1946] | 284 | ///\code |
---|
[1136] | 285 | /// int count=0; |
---|
| 286 | /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
---|
[1946] | 287 | ///\endcode |
---|
[1136] | 288 | |
---|
| 289 | class OutEdgeIt : public Edge { |
---|
| 290 | public: |
---|
[1426] | 291 | /// Default constructor |
---|
[1136] | 292 | |
---|
[1426] | 293 | /// @warning The default constructor sets the iterator |
---|
| 294 | /// to an undefined value. |
---|
| 295 | OutEdgeIt() { } |
---|
| 296 | /// Copy constructor. |
---|
[1136] | 297 | |
---|
[1426] | 298 | /// Copy constructor. |
---|
| 299 | /// |
---|
| 300 | OutEdgeIt(const OutEdgeIt& e) : Edge(e) { } |
---|
| 301 | /// Initialize the iterator to be invalid. |
---|
[1136] | 302 | |
---|
[1426] | 303 | /// Initialize the iterator to be invalid. |
---|
| 304 | /// |
---|
| 305 | OutEdgeIt(Invalid) { } |
---|
| 306 | /// This constructor sets the iterator to the first outgoing edge. |
---|
[1136] | 307 | |
---|
[1426] | 308 | /// This constructor sets the iterator to the first outgoing edge of |
---|
| 309 | /// the node. |
---|
| 310 | OutEdgeIt(const StaticGraph&, const Node&) { } |
---|
| 311 | /// Edge -> OutEdgeIt conversion |
---|
[1136] | 312 | |
---|
[1470] | 313 | /// Sets the iterator to the value of the trivial iterator. |
---|
| 314 | /// This feature necessitates that each time we |
---|
[1426] | 315 | /// iterate the edge-set, the iteration order is the same. |
---|
[1470] | 316 | OutEdgeIt(const StaticGraph&, const Edge&) { } |
---|
[1426] | 317 | ///Next outgoing edge |
---|
| 318 | |
---|
| 319 | /// Assign the iterator to the next |
---|
| 320 | /// outgoing edge of the corresponding node. |
---|
| 321 | OutEdgeIt& operator++() { return *this; } |
---|
[1136] | 322 | }; |
---|
| 323 | |
---|
| 324 | /// This iterator goes trough the incoming edges of a node. |
---|
| 325 | |
---|
| 326 | /// This iterator goes trough the \e incoming edges of a certain node |
---|
| 327 | /// of a graph. |
---|
| 328 | /// Its usage is quite simple, for example you can count the number |
---|
| 329 | /// of outgoing edges of a node \c n |
---|
| 330 | /// in graph \c g of type \c Graph as follows. |
---|
[1946] | 331 | ///\code |
---|
[1136] | 332 | /// int count=0; |
---|
| 333 | /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
---|
[1946] | 334 | ///\endcode |
---|
[1136] | 335 | |
---|
| 336 | class InEdgeIt : public Edge { |
---|
| 337 | public: |
---|
[1426] | 338 | /// Default constructor |
---|
[1136] | 339 | |
---|
[1426] | 340 | /// @warning The default constructor sets the iterator |
---|
| 341 | /// to an undefined value. |
---|
| 342 | InEdgeIt() { } |
---|
| 343 | /// Copy constructor. |
---|
[1136] | 344 | |
---|
[1426] | 345 | /// Copy constructor. |
---|
| 346 | /// |
---|
| 347 | InEdgeIt(const InEdgeIt& e) : Edge(e) { } |
---|
| 348 | /// Initialize the iterator to be invalid. |
---|
[1136] | 349 | |
---|
[1426] | 350 | /// Initialize the iterator to be invalid. |
---|
| 351 | /// |
---|
| 352 | InEdgeIt(Invalid) { } |
---|
| 353 | /// This constructor sets the iterator to first incoming edge. |
---|
[1136] | 354 | |
---|
[1426] | 355 | /// This constructor set the iterator to the first incoming edge of |
---|
| 356 | /// the node. |
---|
| 357 | InEdgeIt(const StaticGraph&, const Node&) { } |
---|
| 358 | /// Edge -> InEdgeIt conversion |
---|
[1136] | 359 | |
---|
[1426] | 360 | /// Sets the iterator to the value of the trivial iterator \c e. |
---|
| 361 | /// This feature necessitates that each time we |
---|
| 362 | /// iterate the edge-set, the iteration order is the same. |
---|
| 363 | InEdgeIt(const StaticGraph&, const Edge&) { } |
---|
| 364 | /// Next incoming edge |
---|
[1136] | 365 | |
---|
[1426] | 366 | /// Assign the iterator to the next inedge of the corresponding node. |
---|
| 367 | /// |
---|
| 368 | InEdgeIt& operator++() { return *this; } |
---|
[1136] | 369 | }; |
---|
| 370 | /// This iterator goes through each edge. |
---|
| 371 | |
---|
| 372 | /// This iterator goes through each edge of a graph. |
---|
| 373 | /// Its usage is quite simple, for example you can count the number |
---|
| 374 | /// of edges in a graph \c g of type \c Graph as follows: |
---|
[1946] | 375 | ///\code |
---|
[1136] | 376 | /// int count=0; |
---|
| 377 | /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count; |
---|
[1946] | 378 | ///\endcode |
---|
[1136] | 379 | class EdgeIt : public Edge { |
---|
| 380 | public: |
---|
[1426] | 381 | /// Default constructor |
---|
[1136] | 382 | |
---|
[1426] | 383 | /// @warning The default constructor sets the iterator |
---|
| 384 | /// to an undefined value. |
---|
| 385 | EdgeIt() { } |
---|
| 386 | /// Copy constructor. |
---|
[1136] | 387 | |
---|
[1426] | 388 | /// Copy constructor. |
---|
| 389 | /// |
---|
| 390 | EdgeIt(const EdgeIt& e) : Edge(e) { } |
---|
| 391 | /// Initialize the iterator to be invalid. |
---|
[1136] | 392 | |
---|
[1426] | 393 | /// Initialize the iterator to be invalid. |
---|
| 394 | /// |
---|
| 395 | EdgeIt(Invalid) { } |
---|
| 396 | /// This constructor sets the iterator to the first edge. |
---|
[1136] | 397 | |
---|
[1426] | 398 | /// This constructor sets the iterator to the first edge of \c g. |
---|
| 399 | ///@param g the graph |
---|
[1643] | 400 | EdgeIt(const StaticGraph& g) { ignore_unused_variable_warning(g); } |
---|
[1426] | 401 | /// Edge -> EdgeIt conversion |
---|
[1136] | 402 | |
---|
[1426] | 403 | /// Sets the iterator to the value of the trivial iterator \c e. |
---|
| 404 | /// This feature necessitates that each time we |
---|
| 405 | /// iterate the edge-set, the iteration order is the same. |
---|
| 406 | EdgeIt(const StaticGraph&, const Edge&) { } |
---|
| 407 | ///Next edge |
---|
| 408 | |
---|
| 409 | /// Assign the iterator to the next edge. |
---|
| 410 | EdgeIt& operator++() { return *this; } |
---|
[1136] | 411 | }; |
---|
| 412 | ///Gives back the target node of an edge. |
---|
| 413 | |
---|
| 414 | ///Gives back the target node of an edge. |
---|
| 415 | /// |
---|
| 416 | Node target(Edge) const { return INVALID; } |
---|
| 417 | ///Gives back the source node of an edge. |
---|
| 418 | |
---|
| 419 | ///Gives back the source node of an edge. |
---|
| 420 | /// |
---|
| 421 | Node source(Edge) const { return INVALID; } |
---|
[1563] | 422 | |
---|
[1630] | 423 | // /// Gives back the first Node in the iterating order. |
---|
[1563] | 424 | |
---|
[1630] | 425 | // /// Gives back the first Node in the iterating order. |
---|
| 426 | // /// |
---|
[1563] | 427 | void first(Node&) const {} |
---|
| 428 | |
---|
[1630] | 429 | // /// Gives back the next Node in the iterating order. |
---|
[1563] | 430 | |
---|
[1630] | 431 | // /// Gives back the next Node in the iterating order. |
---|
| 432 | // /// |
---|
[1563] | 433 | void next(Node&) const {} |
---|
| 434 | |
---|
[1630] | 435 | // /// Gives back the first Edge in the iterating order. |
---|
[1563] | 436 | |
---|
[1630] | 437 | // /// Gives back the first Edge in the iterating order. |
---|
| 438 | // /// |
---|
[1563] | 439 | void first(Edge&) const {} |
---|
[1630] | 440 | // /// Gives back the next Edge in the iterating order. |
---|
[1563] | 441 | |
---|
[1630] | 442 | // /// Gives back the next Edge in the iterating order. |
---|
| 443 | // /// |
---|
[1563] | 444 | void next(Edge&) const {} |
---|
| 445 | |
---|
| 446 | |
---|
[1630] | 447 | // /// Gives back the first of the Edges point to the given Node. |
---|
[1563] | 448 | |
---|
[1630] | 449 | // /// Gives back the first of the Edges point to the given Node. |
---|
| 450 | // /// |
---|
[1563] | 451 | void firstIn(Edge&, const Node&) const {} |
---|
| 452 | |
---|
[1630] | 453 | // /// Gives back the next of the Edges points to the given Node. |
---|
[1563] | 454 | |
---|
| 455 | |
---|
[1630] | 456 | // /// Gives back the next of the Edges points to the given Node. |
---|
| 457 | // /// |
---|
[1563] | 458 | void nextIn(Edge&) const {} |
---|
| 459 | |
---|
[1630] | 460 | // /// Gives back the first of the Edges start from the given Node. |
---|
[1563] | 461 | |
---|
[1630] | 462 | // /// Gives back the first of the Edges start from the given Node. |
---|
| 463 | // /// |
---|
[1563] | 464 | void firstOut(Edge&, const Node&) const {} |
---|
| 465 | |
---|
[1630] | 466 | // /// Gives back the next of the Edges start from the given Node. |
---|
[1563] | 467 | |
---|
[1630] | 468 | // /// Gives back the next of the Edges start from the given Node. |
---|
| 469 | // /// |
---|
[1563] | 470 | void nextOut(Edge&) const {} |
---|
| 471 | |
---|
| 472 | /// \brief The base node of the iterator. |
---|
| 473 | /// |
---|
| 474 | /// Gives back the base node of the iterator. |
---|
[1627] | 475 | /// It is always the target of the pointed edge. |
---|
[1563] | 476 | Node baseNode(const InEdgeIt&) const { return INVALID; } |
---|
| 477 | |
---|
| 478 | /// \brief The running node of the iterator. |
---|
| 479 | /// |
---|
| 480 | /// Gives back the running node of the iterator. |
---|
[1627] | 481 | /// It is always the source of the pointed edge. |
---|
[1563] | 482 | Node runningNode(const InEdgeIt&) const { return INVALID; } |
---|
| 483 | |
---|
| 484 | /// \brief The base node of the iterator. |
---|
| 485 | /// |
---|
| 486 | /// Gives back the base node of the iterator. |
---|
[1627] | 487 | /// It is always the source of the pointed edge. |
---|
[1563] | 488 | Node baseNode(const OutEdgeIt&) const { return INVALID; } |
---|
| 489 | |
---|
| 490 | /// \brief The running node of the iterator. |
---|
| 491 | /// |
---|
| 492 | /// Gives back the running node of the iterator. |
---|
[1627] | 493 | /// It is always the target of the pointed edge. |
---|
[1563] | 494 | Node runningNode(const OutEdgeIt&) const { return INVALID; } |
---|
[1136] | 495 | |
---|
[1627] | 496 | /// \brief The opposite node on the given edge. |
---|
| 497 | /// |
---|
| 498 | /// Gives back the opposite node on the given edge. |
---|
| 499 | Node oppositeNode(const Node&, const Edge&) const { return INVALID; } |
---|
| 500 | |
---|
| 501 | /// \brief Read write map of the nodes to type \c T. |
---|
| 502 | /// |
---|
[1136] | 503 | /// ReadWrite map of the nodes to type \c T. |
---|
| 504 | /// \sa Reference |
---|
| 505 | /// \warning Making maps that can handle bool type (NodeMap<bool>) |
---|
| 506 | /// needs some extra attention! |
---|
[1630] | 507 | /// \todo Wrong documentation |
---|
[1136] | 508 | template<class T> |
---|
| 509 | class NodeMap : public ReadWriteMap< Node, T > |
---|
| 510 | { |
---|
| 511 | public: |
---|
| 512 | |
---|
[1426] | 513 | ///\e |
---|
| 514 | NodeMap(const StaticGraph&) { } |
---|
| 515 | ///\e |
---|
| 516 | NodeMap(const StaticGraph&, T) { } |
---|
[1136] | 517 | |
---|
[1426] | 518 | ///Copy constructor |
---|
| 519 | NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } |
---|
| 520 | ///Assignment operator |
---|
| 521 | NodeMap& operator=(const NodeMap&) { return *this; } |
---|
| 522 | // \todo fix this concept |
---|
[1136] | 523 | }; |
---|
| 524 | |
---|
[1627] | 525 | /// \brief Read write map of the edges to type \c T. |
---|
| 526 | /// |
---|
| 527 | /// Reference map of the edges to type \c T. |
---|
[1136] | 528 | /// \sa Reference |
---|
| 529 | /// \warning Making maps that can handle bool type (EdgeMap<bool>) |
---|
| 530 | /// needs some extra attention! |
---|
[1630] | 531 | /// \todo Wrong documentation |
---|
[1136] | 532 | template<class T> |
---|
| 533 | class EdgeMap : public ReadWriteMap<Edge,T> |
---|
| 534 | { |
---|
| 535 | public: |
---|
| 536 | |
---|
[1426] | 537 | ///\e |
---|
| 538 | EdgeMap(const StaticGraph&) { } |
---|
| 539 | ///\e |
---|
| 540 | EdgeMap(const StaticGraph&, T) { } |
---|
| 541 | ///Copy constructor |
---|
| 542 | EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { } |
---|
| 543 | ///Assignment operator |
---|
| 544 | EdgeMap& operator=(const EdgeMap&) { return *this; } |
---|
| 545 | // \todo fix this concept |
---|
[1136] | 546 | }; |
---|
| 547 | |
---|
| 548 | template <typename _Graph> |
---|
| 549 | struct Constraints : public _StaticGraph::Constraints<_Graph> {}; |
---|
| 550 | |
---|
| 551 | }; |
---|
| 552 | |
---|
| 553 | /// An empty non-static graph class. |
---|
| 554 | |
---|
[1426] | 555 | /// This class provides everything that \ref StaticGraph does. |
---|
| 556 | /// Additionally it enables building graphs from scratch. |
---|
[1136] | 557 | class ExtendableGraph : public StaticGraph |
---|
| 558 | { |
---|
| 559 | public: |
---|
| 560 | /// Defalult constructor. |
---|
| 561 | |
---|
| 562 | /// Defalult constructor. |
---|
| 563 | /// |
---|
| 564 | ExtendableGraph() { } |
---|
| 565 | ///Add a new node to the graph. |
---|
| 566 | |
---|
| 567 | /// \return the new node. |
---|
| 568 | /// |
---|
| 569 | Node addNode() { return INVALID; } |
---|
| 570 | ///Add a new edge to the graph. |
---|
| 571 | |
---|
| 572 | ///Add a new edge to the graph with source node \c s |
---|
| 573 | ///and target node \c t. |
---|
| 574 | ///\return the new edge. |
---|
[1367] | 575 | Edge addEdge(Node, Node) { return INVALID; } |
---|
[1136] | 576 | |
---|
| 577 | /// Resets the graph. |
---|
| 578 | |
---|
| 579 | /// This function deletes all edges and nodes of the graph. |
---|
| 580 | /// It also frees the memory allocated to store them. |
---|
| 581 | /// \todo It might belong to \ref ErasableGraph. |
---|
| 582 | void clear() { } |
---|
| 583 | |
---|
| 584 | template <typename _Graph> |
---|
| 585 | struct Constraints : public _ExtendableGraph::Constraints<_Graph> {}; |
---|
| 586 | |
---|
| 587 | }; |
---|
| 588 | |
---|
| 589 | /// An empty erasable graph class. |
---|
| 590 | |
---|
[1426] | 591 | /// This class is an extension of \ref ExtendableGraph. It makes it |
---|
[1136] | 592 | /// possible to erase edges or nodes. |
---|
| 593 | class ErasableGraph : public ExtendableGraph |
---|
| 594 | { |
---|
| 595 | public: |
---|
| 596 | /// Defalult constructor. |
---|
| 597 | |
---|
| 598 | /// Defalult constructor. |
---|
| 599 | /// |
---|
| 600 | ErasableGraph() { } |
---|
| 601 | /// Deletes a node. |
---|
| 602 | |
---|
| 603 | /// Deletes node \c n node. |
---|
| 604 | /// |
---|
[1367] | 605 | void erase(Node) { } |
---|
[1136] | 606 | /// Deletes an edge. |
---|
| 607 | |
---|
| 608 | /// Deletes edge \c e edge. |
---|
| 609 | /// |
---|
[1367] | 610 | void erase(Edge) { } |
---|
[1136] | 611 | |
---|
| 612 | template <typename _Graph> |
---|
| 613 | struct Constraints : public _ErasableGraph::Constraints<_Graph> {}; |
---|
| 614 | |
---|
| 615 | }; |
---|
| 616 | |
---|
[959] | 617 | // @} |
---|
| 618 | } //namespace concept |
---|
| 619 | } //namespace lemon |
---|
| 620 | |
---|
| 621 | |
---|
| 622 | |
---|
| 623 | #endif // LEMON_CONCEPT_GRAPH_H |
---|