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