[962] | 1 | /* -*- C++ -*- |
---|
| 2 | * |
---|
[1956] | 3 | * This file is a part of LEMON, a generic C++ optimization library |
---|
[962] | 4 | * |
---|
[1956] | 5 | * Copyright (C) 2003-2006 |
---|
| 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
---|
| 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). |
---|
[962] | 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 | |
---|
[1030] | 19 | ///\ingroup graph_concepts |
---|
[962] | 20 | ///\file |
---|
[2111] | 21 | ///\brief The concept of the undirected graphs. |
---|
[962] | 22 | |
---|
| 23 | |
---|
[1910] | 24 | #ifndef LEMON_CONCEPT_UGRAPH_H |
---|
| 25 | #define LEMON_CONCEPT_UGRAPH_H |
---|
[962] | 26 | |
---|
| 27 | #include <lemon/concept/graph_component.h> |
---|
[1620] | 28 | #include <lemon/concept/graph.h> |
---|
[1993] | 29 | #include <lemon/bits/utility.h> |
---|
[962] | 30 | |
---|
| 31 | namespace lemon { |
---|
| 32 | namespace concept { |
---|
| 33 | |
---|
[1620] | 34 | /// \addtogroup graph_concepts |
---|
| 35 | /// @{ |
---|
| 36 | |
---|
| 37 | |
---|
[1030] | 38 | /// Class describing the concept of Undirected Graphs. |
---|
| 39 | |
---|
| 40 | /// This class describes the common interface of all Undirected |
---|
| 41 | /// Graphs. |
---|
| 42 | /// |
---|
| 43 | /// As all concept describing classes it provides only interface |
---|
| 44 | /// without any sensible implementation. So any algorithm for |
---|
| 45 | /// undirected graph should compile with this class, but it will not |
---|
| 46 | /// run properly, of couse. |
---|
| 47 | /// |
---|
| 48 | /// In LEMON undirected graphs also fulfill the concept of directed |
---|
[2111] | 49 | /// graphs (\ref lemon::concept::Graph "Graph Concept"). For |
---|
| 50 | /// explanation of this and more see also the page \ref graphs, |
---|
| 51 | /// a tutorial about graphs. |
---|
[1627] | 52 | /// |
---|
| 53 | /// You can assume that all undirected graph can be handled |
---|
[2111] | 54 | /// as a directed graph. This way it is fully conform |
---|
| 55 | /// to the Graph concept. |
---|
[1030] | 56 | |
---|
[1909] | 57 | class UGraph { |
---|
[1022] | 58 | public: |
---|
[1448] | 59 | ///\e |
---|
| 60 | |
---|
| 61 | ///\todo undocumented |
---|
| 62 | /// |
---|
[1979] | 63 | typedef True UndirectedTag; |
---|
[1022] | 64 | |
---|
[1669] | 65 | /// \brief The base type of node iterators, |
---|
[1627] | 66 | /// or in other words, the trivial node iterator. |
---|
[1669] | 67 | /// |
---|
[1627] | 68 | /// This is the base type of each node iterator, |
---|
| 69 | /// thus each kind of node iterator converts to this. |
---|
| 70 | /// More precisely each kind of node iterator should be inherited |
---|
| 71 | /// from the trivial node iterator. |
---|
| 72 | class Node { |
---|
| 73 | public: |
---|
| 74 | /// Default constructor |
---|
| 75 | |
---|
| 76 | /// @warning The default constructor sets the iterator |
---|
| 77 | /// to an undefined value. |
---|
| 78 | Node() { } |
---|
| 79 | /// Copy constructor. |
---|
| 80 | |
---|
| 81 | /// Copy constructor. |
---|
| 82 | /// |
---|
| 83 | Node(const Node&) { } |
---|
| 84 | |
---|
| 85 | /// Invalid constructor \& conversion. |
---|
| 86 | |
---|
| 87 | /// This constructor initializes the iterator to be invalid. |
---|
| 88 | /// \sa Invalid for more details. |
---|
| 89 | Node(Invalid) { } |
---|
| 90 | /// Equality operator |
---|
| 91 | |
---|
| 92 | /// Two iterators are equal if and only if they point to the |
---|
| 93 | /// same object or both are invalid. |
---|
| 94 | bool operator==(Node) const { return true; } |
---|
| 95 | |
---|
| 96 | /// Inequality operator |
---|
| 97 | |
---|
| 98 | /// \sa operator==(Node n) |
---|
| 99 | /// |
---|
| 100 | bool operator!=(Node) const { return true; } |
---|
| 101 | |
---|
| 102 | /// Artificial ordering operator. |
---|
| 103 | |
---|
| 104 | /// To allow the use of graph descriptors as key type in std::map or |
---|
| 105 | /// similar associative container we require this. |
---|
| 106 | /// |
---|
| 107 | /// \note This operator only have to define some strict ordering of |
---|
| 108 | /// the items; this order has nothing to do with the iteration |
---|
| 109 | /// ordering of the items. |
---|
| 110 | bool operator<(Node) const { return false; } |
---|
| 111 | |
---|
| 112 | }; |
---|
| 113 | |
---|
| 114 | /// This iterator goes through each node. |
---|
| 115 | |
---|
| 116 | /// This iterator goes through each node. |
---|
| 117 | /// Its usage is quite simple, for example you can count the number |
---|
| 118 | /// of nodes in graph \c g of type \c Graph like this: |
---|
[1946] | 119 | ///\code |
---|
[1627] | 120 | /// int count=0; |
---|
| 121 | /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count; |
---|
[1946] | 122 | ///\endcode |
---|
[1627] | 123 | class NodeIt : public Node { |
---|
| 124 | public: |
---|
| 125 | /// Default constructor |
---|
| 126 | |
---|
| 127 | /// @warning The default constructor sets the iterator |
---|
| 128 | /// to an undefined value. |
---|
| 129 | NodeIt() { } |
---|
| 130 | /// Copy constructor. |
---|
| 131 | |
---|
| 132 | /// Copy constructor. |
---|
| 133 | /// |
---|
| 134 | NodeIt(const NodeIt& n) : Node(n) { } |
---|
| 135 | /// Invalid constructor \& conversion. |
---|
| 136 | |
---|
| 137 | /// Initialize the iterator to be invalid. |
---|
| 138 | /// \sa Invalid for more details. |
---|
| 139 | NodeIt(Invalid) { } |
---|
| 140 | /// Sets the iterator to the first node. |
---|
| 141 | |
---|
| 142 | /// Sets the iterator to the first node of \c g. |
---|
| 143 | /// |
---|
[1909] | 144 | NodeIt(const UGraph&) { } |
---|
[1627] | 145 | /// Node -> NodeIt conversion. |
---|
| 146 | |
---|
| 147 | /// Sets the iterator to the node of \c the graph pointed by |
---|
| 148 | /// the trivial iterator. |
---|
| 149 | /// This feature necessitates that each time we |
---|
| 150 | /// iterate the edge-set, the iteration order is the same. |
---|
[1909] | 151 | NodeIt(const UGraph&, const Node&) { } |
---|
[1627] | 152 | /// Next node. |
---|
| 153 | |
---|
| 154 | /// Assign the iterator to the next node. |
---|
| 155 | /// |
---|
| 156 | NodeIt& operator++() { return *this; } |
---|
| 157 | }; |
---|
| 158 | |
---|
| 159 | |
---|
[1620] | 160 | /// The base type of the undirected edge iterators. |
---|
[1627] | 161 | |
---|
[1620] | 162 | /// The base type of the undirected edge iterators. |
---|
| 163 | /// |
---|
[1909] | 164 | class UEdge { |
---|
[1620] | 165 | public: |
---|
| 166 | /// Default constructor |
---|
[1030] | 167 | |
---|
[1620] | 168 | /// @warning The default constructor sets the iterator |
---|
| 169 | /// to an undefined value. |
---|
[1909] | 170 | UEdge() { } |
---|
[1620] | 171 | /// Copy constructor. |
---|
[1030] | 172 | |
---|
[1620] | 173 | /// Copy constructor. |
---|
| 174 | /// |
---|
[1909] | 175 | UEdge(const UEdge&) { } |
---|
[1620] | 176 | /// Initialize the iterator to be invalid. |
---|
[1030] | 177 | |
---|
[1620] | 178 | /// Initialize the iterator to be invalid. |
---|
| 179 | /// |
---|
[1909] | 180 | UEdge(Invalid) { } |
---|
[1620] | 181 | /// Equality operator |
---|
[1030] | 182 | |
---|
[1620] | 183 | /// Two iterators are equal if and only if they point to the |
---|
| 184 | /// same object or both are invalid. |
---|
[1909] | 185 | bool operator==(UEdge) const { return true; } |
---|
[1620] | 186 | /// Inequality operator |
---|
[1030] | 187 | |
---|
[1909] | 188 | /// \sa operator==(UEdge n) |
---|
[1620] | 189 | /// |
---|
[1909] | 190 | bool operator!=(UEdge) const { return true; } |
---|
[1030] | 191 | |
---|
[1627] | 192 | /// Artificial ordering operator. |
---|
| 193 | |
---|
| 194 | /// To allow the use of graph descriptors as key type in std::map or |
---|
| 195 | /// similar associative container we require this. |
---|
| 196 | /// |
---|
| 197 | /// \note This operator only have to define some strict ordering of |
---|
| 198 | /// the items; this order has nothing to do with the iteration |
---|
| 199 | /// ordering of the items. |
---|
[1909] | 200 | bool operator<(UEdge) const { return false; } |
---|
[1627] | 201 | }; |
---|
[1030] | 202 | |
---|
[1620] | 203 | /// This iterator goes through each undirected edge. |
---|
[1030] | 204 | |
---|
[1620] | 205 | /// This iterator goes through each undirected edge of a graph. |
---|
| 206 | /// Its usage is quite simple, for example you can count the number |
---|
[1627] | 207 | /// of undirected edges in a graph \c g of type \c Graph as follows: |
---|
[1946] | 208 | ///\code |
---|
[1620] | 209 | /// int count=0; |
---|
[1909] | 210 | /// for(Graph::UEdgeIt e(g); e!=INVALID; ++e) ++count; |
---|
[1946] | 211 | ///\endcode |
---|
[1909] | 212 | class UEdgeIt : public UEdge { |
---|
[1620] | 213 | public: |
---|
| 214 | /// Default constructor |
---|
[1627] | 215 | |
---|
[1620] | 216 | /// @warning The default constructor sets the iterator |
---|
| 217 | /// to an undefined value. |
---|
[1909] | 218 | UEdgeIt() { } |
---|
[1620] | 219 | /// Copy constructor. |
---|
[1627] | 220 | |
---|
[1620] | 221 | /// Copy constructor. |
---|
| 222 | /// |
---|
[1909] | 223 | UEdgeIt(const UEdgeIt& e) : UEdge(e) { } |
---|
[1620] | 224 | /// Initialize the iterator to be invalid. |
---|
[1030] | 225 | |
---|
[1620] | 226 | /// Initialize the iterator to be invalid. |
---|
| 227 | /// |
---|
[1909] | 228 | UEdgeIt(Invalid) { } |
---|
[1627] | 229 | /// This constructor sets the iterator to the first undirected edge. |
---|
[1620] | 230 | |
---|
[1627] | 231 | /// This constructor sets the iterator to the first undirected edge. |
---|
[1909] | 232 | UEdgeIt(const UGraph&) { } |
---|
| 233 | /// UEdge -> UEdgeIt conversion |
---|
[1030] | 234 | |
---|
[1627] | 235 | /// Sets the iterator to the value of the trivial iterator. |
---|
| 236 | /// This feature necessitates that each time we |
---|
| 237 | /// iterate the undirected edge-set, the iteration order is the |
---|
| 238 | /// same. |
---|
[1909] | 239 | UEdgeIt(const UGraph&, const UEdge&) { } |
---|
[1627] | 240 | /// Next undirected edge |
---|
[1620] | 241 | |
---|
[1627] | 242 | /// Assign the iterator to the next undirected edge. |
---|
[1909] | 243 | UEdgeIt& operator++() { return *this; } |
---|
[1620] | 244 | }; |
---|
[1030] | 245 | |
---|
[1627] | 246 | /// \brief This iterator goes trough the incident undirected |
---|
| 247 | /// edges of a node. |
---|
| 248 | /// |
---|
[1620] | 249 | /// This iterator goes trough the incident undirected edges |
---|
[2021] | 250 | /// of a certain node of a graph. You should assume that the |
---|
| 251 | /// loop edges will be iterated twice. |
---|
| 252 | /// |
---|
[1620] | 253 | /// Its usage is quite simple, for example you can compute the |
---|
[2021] | 254 | /// degree (i.e. count the number of incident edges of a node \c n |
---|
| 255 | /// in graph \c g of type \c Graph as follows. |
---|
| 256 | /// |
---|
[1946] | 257 | ///\code |
---|
[1620] | 258 | /// int count=0; |
---|
| 259 | /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
---|
[1946] | 260 | ///\endcode |
---|
[1909] | 261 | class IncEdgeIt : public UEdge { |
---|
[1620] | 262 | public: |
---|
| 263 | /// Default constructor |
---|
[1030] | 264 | |
---|
[1620] | 265 | /// @warning The default constructor sets the iterator |
---|
| 266 | /// to an undefined value. |
---|
| 267 | IncEdgeIt() { } |
---|
| 268 | /// Copy constructor. |
---|
| 269 | |
---|
| 270 | /// Copy constructor. |
---|
| 271 | /// |
---|
[1909] | 272 | IncEdgeIt(const IncEdgeIt& e) : UEdge(e) { } |
---|
[1620] | 273 | /// Initialize the iterator to be invalid. |
---|
| 274 | |
---|
| 275 | /// Initialize the iterator to be invalid. |
---|
| 276 | /// |
---|
| 277 | IncEdgeIt(Invalid) { } |
---|
| 278 | /// This constructor sets the iterator to first incident edge. |
---|
| 279 | |
---|
| 280 | /// This constructor set the iterator to the first incident edge of |
---|
| 281 | /// the node. |
---|
[1909] | 282 | IncEdgeIt(const UGraph&, const Node&) { } |
---|
| 283 | /// UEdge -> IncEdgeIt conversion |
---|
[1620] | 284 | |
---|
| 285 | /// Sets the iterator to the value of the trivial iterator \c e. |
---|
| 286 | /// This feature necessitates that each time we |
---|
| 287 | /// iterate the edge-set, the iteration order is the same. |
---|
[1909] | 288 | IncEdgeIt(const UGraph&, const UEdge&) { } |
---|
[1620] | 289 | /// Next incident edge |
---|
| 290 | |
---|
| 291 | /// Assign the iterator to the next incident edge |
---|
| 292 | /// of the corresponding node. |
---|
| 293 | IncEdgeIt& operator++() { return *this; } |
---|
| 294 | }; |
---|
| 295 | |
---|
[1627] | 296 | /// The directed edge type. |
---|
| 297 | |
---|
| 298 | /// The directed edge type. It can be converted to the |
---|
| 299 | /// undirected edge. |
---|
[1909] | 300 | class Edge : public UEdge { |
---|
[1627] | 301 | public: |
---|
| 302 | /// Default constructor |
---|
| 303 | |
---|
| 304 | /// @warning The default constructor sets the iterator |
---|
| 305 | /// to an undefined value. |
---|
| 306 | Edge() { } |
---|
| 307 | /// Copy constructor. |
---|
| 308 | |
---|
| 309 | /// Copy constructor. |
---|
| 310 | /// |
---|
[1909] | 311 | Edge(const Edge& e) : UEdge(e) { } |
---|
[1627] | 312 | /// Initialize the iterator to be invalid. |
---|
| 313 | |
---|
| 314 | /// Initialize the iterator to be invalid. |
---|
| 315 | /// |
---|
| 316 | Edge(Invalid) { } |
---|
| 317 | /// Equality operator |
---|
| 318 | |
---|
| 319 | /// Two iterators are equal if and only if they point to the |
---|
| 320 | /// same object or both are invalid. |
---|
| 321 | bool operator==(Edge) const { return true; } |
---|
| 322 | /// Inequality operator |
---|
| 323 | |
---|
| 324 | /// \sa operator==(Edge n) |
---|
| 325 | /// |
---|
| 326 | bool operator!=(Edge) const { return true; } |
---|
| 327 | |
---|
| 328 | /// Artificial ordering operator. |
---|
| 329 | |
---|
| 330 | /// To allow the use of graph descriptors as key type in std::map or |
---|
| 331 | /// similar associative container we require this. |
---|
| 332 | /// |
---|
| 333 | /// \note This operator only have to define some strict ordering of |
---|
| 334 | /// the items; this order has nothing to do with the iteration |
---|
| 335 | /// ordering of the items. |
---|
| 336 | bool operator<(Edge) const { return false; } |
---|
| 337 | |
---|
| 338 | }; |
---|
| 339 | /// This iterator goes through each directed edge. |
---|
| 340 | |
---|
| 341 | /// This iterator goes through each edge of a graph. |
---|
| 342 | /// Its usage is quite simple, for example you can count the number |
---|
| 343 | /// of edges in a graph \c g of type \c Graph as follows: |
---|
[1946] | 344 | ///\code |
---|
[1627] | 345 | /// int count=0; |
---|
| 346 | /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count; |
---|
[1946] | 347 | ///\endcode |
---|
[1627] | 348 | class EdgeIt : public Edge { |
---|
| 349 | public: |
---|
| 350 | /// Default constructor |
---|
| 351 | |
---|
| 352 | /// @warning The default constructor sets the iterator |
---|
| 353 | /// to an undefined value. |
---|
| 354 | EdgeIt() { } |
---|
| 355 | /// Copy constructor. |
---|
| 356 | |
---|
| 357 | /// Copy constructor. |
---|
| 358 | /// |
---|
| 359 | EdgeIt(const EdgeIt& e) : Edge(e) { } |
---|
| 360 | /// Initialize the iterator to be invalid. |
---|
| 361 | |
---|
| 362 | /// Initialize the iterator to be invalid. |
---|
| 363 | /// |
---|
| 364 | EdgeIt(Invalid) { } |
---|
| 365 | /// This constructor sets the iterator to the first edge. |
---|
| 366 | |
---|
| 367 | /// This constructor sets the iterator to the first edge of \c g. |
---|
| 368 | ///@param g the graph |
---|
[1909] | 369 | EdgeIt(const UGraph &g) { ignore_unused_variable_warning(g); } |
---|
[1627] | 370 | /// Edge -> EdgeIt conversion |
---|
| 371 | |
---|
| 372 | /// Sets the iterator to the value of the trivial iterator \c e. |
---|
| 373 | /// This feature necessitates that each time we |
---|
| 374 | /// iterate the edge-set, the iteration order is the same. |
---|
[1909] | 375 | EdgeIt(const UGraph&, const Edge&) { } |
---|
[1627] | 376 | ///Next edge |
---|
| 377 | |
---|
| 378 | /// Assign the iterator to the next edge. |
---|
| 379 | EdgeIt& operator++() { return *this; } |
---|
| 380 | }; |
---|
| 381 | |
---|
| 382 | /// This iterator goes trough the outgoing directed edges of a node. |
---|
| 383 | |
---|
| 384 | /// This iterator goes trough the \e outgoing edges of a certain node |
---|
| 385 | /// of a graph. |
---|
| 386 | /// Its usage is quite simple, for example you can count the number |
---|
| 387 | /// of outgoing edges of a node \c n |
---|
| 388 | /// in graph \c g of type \c Graph as follows. |
---|
[1946] | 389 | ///\code |
---|
[1627] | 390 | /// int count=0; |
---|
| 391 | /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
---|
[1946] | 392 | ///\endcode |
---|
[1627] | 393 | |
---|
| 394 | class OutEdgeIt : public Edge { |
---|
| 395 | public: |
---|
| 396 | /// Default constructor |
---|
| 397 | |
---|
| 398 | /// @warning The default constructor sets the iterator |
---|
| 399 | /// to an undefined value. |
---|
| 400 | OutEdgeIt() { } |
---|
| 401 | /// Copy constructor. |
---|
| 402 | |
---|
| 403 | /// Copy constructor. |
---|
| 404 | /// |
---|
| 405 | OutEdgeIt(const OutEdgeIt& e) : Edge(e) { } |
---|
| 406 | /// Initialize the iterator to be invalid. |
---|
| 407 | |
---|
| 408 | /// Initialize the iterator to be invalid. |
---|
| 409 | /// |
---|
| 410 | OutEdgeIt(Invalid) { } |
---|
| 411 | /// This constructor sets the iterator to the first outgoing edge. |
---|
| 412 | |
---|
| 413 | /// This constructor sets the iterator to the first outgoing edge of |
---|
| 414 | /// the node. |
---|
| 415 | ///@param n the node |
---|
| 416 | ///@param g the graph |
---|
[1909] | 417 | OutEdgeIt(const UGraph& n, const Node& g) { |
---|
[1643] | 418 | ignore_unused_variable_warning(n); |
---|
| 419 | ignore_unused_variable_warning(g); |
---|
| 420 | } |
---|
[1627] | 421 | /// Edge -> OutEdgeIt conversion |
---|
| 422 | |
---|
| 423 | /// Sets the iterator to the value of the trivial iterator. |
---|
| 424 | /// This feature necessitates that each time we |
---|
| 425 | /// iterate the edge-set, the iteration order is the same. |
---|
[1909] | 426 | OutEdgeIt(const UGraph&, const Edge&) { } |
---|
[1627] | 427 | ///Next outgoing edge |
---|
| 428 | |
---|
| 429 | /// Assign the iterator to the next |
---|
| 430 | /// outgoing edge of the corresponding node. |
---|
| 431 | OutEdgeIt& operator++() { return *this; } |
---|
| 432 | }; |
---|
| 433 | |
---|
| 434 | /// This iterator goes trough the incoming directed edges of a node. |
---|
| 435 | |
---|
| 436 | /// This iterator goes trough the \e incoming edges of a certain node |
---|
| 437 | /// of a graph. |
---|
| 438 | /// Its usage is quite simple, for example you can count the number |
---|
| 439 | /// of outgoing edges of a node \c n |
---|
| 440 | /// in graph \c g of type \c Graph as follows. |
---|
[1946] | 441 | ///\code |
---|
[1627] | 442 | /// int count=0; |
---|
| 443 | /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
---|
[1946] | 444 | ///\endcode |
---|
[1627] | 445 | |
---|
| 446 | class InEdgeIt : public Edge { |
---|
| 447 | public: |
---|
| 448 | /// Default constructor |
---|
| 449 | |
---|
| 450 | /// @warning The default constructor sets the iterator |
---|
| 451 | /// to an undefined value. |
---|
| 452 | InEdgeIt() { } |
---|
| 453 | /// Copy constructor. |
---|
| 454 | |
---|
| 455 | /// Copy constructor. |
---|
| 456 | /// |
---|
| 457 | InEdgeIt(const InEdgeIt& e) : Edge(e) { } |
---|
| 458 | /// Initialize the iterator to be invalid. |
---|
| 459 | |
---|
| 460 | /// Initialize the iterator to be invalid. |
---|
| 461 | /// |
---|
| 462 | InEdgeIt(Invalid) { } |
---|
| 463 | /// This constructor sets the iterator to first incoming edge. |
---|
| 464 | |
---|
| 465 | /// This constructor set the iterator to the first incoming edge of |
---|
| 466 | /// the node. |
---|
| 467 | ///@param n the node |
---|
| 468 | ///@param g the graph |
---|
[1909] | 469 | InEdgeIt(const UGraph& g, const Node& n) { |
---|
[1643] | 470 | ignore_unused_variable_warning(n); |
---|
| 471 | ignore_unused_variable_warning(g); |
---|
| 472 | } |
---|
[1627] | 473 | /// Edge -> InEdgeIt conversion |
---|
| 474 | |
---|
| 475 | /// Sets the iterator to the value of the trivial iterator \c e. |
---|
| 476 | /// This feature necessitates that each time we |
---|
| 477 | /// iterate the edge-set, the iteration order is the same. |
---|
[1909] | 478 | InEdgeIt(const UGraph&, const Edge&) { } |
---|
[1627] | 479 | /// Next incoming edge |
---|
| 480 | |
---|
| 481 | /// Assign the iterator to the next inedge of the corresponding node. |
---|
| 482 | /// |
---|
| 483 | InEdgeIt& operator++() { return *this; } |
---|
| 484 | }; |
---|
| 485 | |
---|
| 486 | /// \brief Read write map of the nodes to type \c T. |
---|
| 487 | /// |
---|
| 488 | /// ReadWrite map of the nodes to type \c T. |
---|
| 489 | /// \sa Reference |
---|
| 490 | /// \warning Making maps that can handle bool type (NodeMap<bool>) |
---|
| 491 | /// needs some extra attention! |
---|
[1630] | 492 | /// \todo Wrong documentation |
---|
[1627] | 493 | template<class T> |
---|
| 494 | class NodeMap : public ReadWriteMap< Node, T > |
---|
| 495 | { |
---|
| 496 | public: |
---|
| 497 | |
---|
| 498 | ///\e |
---|
[1909] | 499 | NodeMap(const UGraph&) { } |
---|
[1627] | 500 | ///\e |
---|
[1909] | 501 | NodeMap(const UGraph&, T) { } |
---|
[1627] | 502 | |
---|
| 503 | ///Copy constructor |
---|
| 504 | NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } |
---|
| 505 | ///Assignment operator |
---|
| 506 | NodeMap& operator=(const NodeMap&) { return *this; } |
---|
| 507 | // \todo fix this concept |
---|
| 508 | }; |
---|
| 509 | |
---|
| 510 | /// \brief Read write map of the directed edges to type \c T. |
---|
| 511 | /// |
---|
| 512 | /// Reference map of the directed edges to type \c T. |
---|
| 513 | /// \sa Reference |
---|
| 514 | /// \warning Making maps that can handle bool type (EdgeMap<bool>) |
---|
| 515 | /// needs some extra attention! |
---|
[1630] | 516 | /// \todo Wrong documentation |
---|
[1627] | 517 | template<class T> |
---|
| 518 | class EdgeMap : public ReadWriteMap<Edge,T> |
---|
| 519 | { |
---|
| 520 | public: |
---|
| 521 | |
---|
| 522 | ///\e |
---|
[1909] | 523 | EdgeMap(const UGraph&) { } |
---|
[1627] | 524 | ///\e |
---|
[1909] | 525 | EdgeMap(const UGraph&, T) { } |
---|
[1627] | 526 | ///Copy constructor |
---|
| 527 | EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { } |
---|
| 528 | ///Assignment operator |
---|
| 529 | EdgeMap& operator=(const EdgeMap&) { return *this; } |
---|
| 530 | // \todo fix this concept |
---|
| 531 | }; |
---|
| 532 | |
---|
[1620] | 533 | /// Read write map of the undirected edges to type \c T. |
---|
| 534 | |
---|
| 535 | /// Reference map of the edges to type \c T. |
---|
| 536 | /// \sa Reference |
---|
[1909] | 537 | /// \warning Making maps that can handle bool type (UEdgeMap<bool>) |
---|
[1620] | 538 | /// needs some extra attention! |
---|
[1630] | 539 | /// \todo Wrong documentation |
---|
[1620] | 540 | template<class T> |
---|
[1909] | 541 | class UEdgeMap : public ReadWriteMap<UEdge,T> |
---|
[1620] | 542 | { |
---|
[1030] | 543 | public: |
---|
| 544 | |
---|
[1620] | 545 | ///\e |
---|
[1909] | 546 | UEdgeMap(const UGraph&) { } |
---|
[1620] | 547 | ///\e |
---|
[1909] | 548 | UEdgeMap(const UGraph&, T) { } |
---|
[1620] | 549 | ///Copy constructor |
---|
[1909] | 550 | UEdgeMap(const UEdgeMap& em) : ReadWriteMap<UEdge,T>(em) {} |
---|
[1620] | 551 | ///Assignment operator |
---|
[1909] | 552 | UEdgeMap &operator=(const UEdgeMap&) { return *this; } |
---|
[1620] | 553 | // \todo fix this concept |
---|
[1030] | 554 | }; |
---|
| 555 | |
---|
[1627] | 556 | /// \brief Direct the given undirected edge. |
---|
| 557 | /// |
---|
| 558 | /// Direct the given undirected edge. The returned edge source |
---|
| 559 | /// will be the given edge. |
---|
[1909] | 560 | Edge direct(const UEdge&, const Node&) const { |
---|
[1627] | 561 | return INVALID; |
---|
| 562 | } |
---|
[1030] | 563 | |
---|
[1627] | 564 | /// \brief Direct the given undirected edge. |
---|
| 565 | /// |
---|
| 566 | /// Direct the given undirected edge. The returned edge source |
---|
| 567 | /// will be the source of the undirected edge if the given bool |
---|
| 568 | /// is true. |
---|
[1909] | 569 | Edge direct(const UEdge&, bool) const { |
---|
[1627] | 570 | return INVALID; |
---|
| 571 | } |
---|
| 572 | |
---|
| 573 | /// \brief Returns true if the edge has default orientation. |
---|
| 574 | /// |
---|
[1030] | 575 | /// Returns whether the given directed edge is same orientation as |
---|
| 576 | /// the corresponding undirected edge. |
---|
[1627] | 577 | bool direction(Edge) const { return true; } |
---|
| 578 | |
---|
| 579 | /// \brief Returns the opposite directed edge. |
---|
[1030] | 580 | /// |
---|
[1627] | 581 | /// Returns the opposite directed edge. |
---|
| 582 | Edge oppositeEdge(Edge) const { return INVALID; } |
---|
[1030] | 583 | |
---|
[1627] | 584 | /// \brief Opposite node on an edge |
---|
| 585 | /// |
---|
[1030] | 586 | /// \return the opposite of the given Node on the given Edge |
---|
[1909] | 587 | Node oppositeNode(Node, UEdge) const { return INVALID; } |
---|
[1030] | 588 | |
---|
[1627] | 589 | /// \brief First node of the undirected edge. |
---|
| 590 | /// |
---|
[1909] | 591 | /// \return the first node of the given UEdge. |
---|
[1030] | 592 | /// |
---|
[1909] | 593 | /// Naturally uectected edges don't have direction and thus |
---|
[1030] | 594 | /// don't have source and target node. But we use these two methods |
---|
| 595 | /// to query the two endnodes of the edge. The direction of the edge |
---|
| 596 | /// which arises this way is called the inherent direction of the |
---|
[1627] | 597 | /// undirected edge, and is used to define the "default" direction |
---|
[1030] | 598 | /// of the directed versions of the edges. |
---|
[1627] | 599 | /// \sa direction |
---|
[1909] | 600 | Node source(UEdge) const { return INVALID; } |
---|
[1030] | 601 | |
---|
[1627] | 602 | /// \brief Second node of the undirected edge. |
---|
[1909] | 603 | Node target(UEdge) const { return INVALID; } |
---|
[1030] | 604 | |
---|
[1627] | 605 | /// \brief Source node of the directed edge. |
---|
[1030] | 606 | Node source(Edge) const { return INVALID; } |
---|
| 607 | |
---|
[1627] | 608 | /// \brief Target node of the directed edge. |
---|
[1030] | 609 | Node target(Edge) const { return INVALID; } |
---|
| 610 | |
---|
| 611 | void first(Node&) const {} |
---|
| 612 | void next(Node&) const {} |
---|
| 613 | |
---|
[1909] | 614 | void first(UEdge&) const {} |
---|
| 615 | void next(UEdge&) const {} |
---|
[1030] | 616 | |
---|
| 617 | void first(Edge&) const {} |
---|
| 618 | void next(Edge&) const {} |
---|
| 619 | |
---|
| 620 | void firstOut(Edge&, Node) const {} |
---|
| 621 | void nextOut(Edge&) const {} |
---|
| 622 | |
---|
| 623 | void firstIn(Edge&, Node) const {} |
---|
| 624 | void nextIn(Edge&) const {} |
---|
| 625 | |
---|
| 626 | |
---|
[1980] | 627 | void firstInc(UEdge &, bool &, const Node &) const {} |
---|
| 628 | void nextInc(UEdge &, bool &) const {} |
---|
| 629 | |
---|
[1627] | 630 | /// \brief Base node of the iterator |
---|
[1158] | 631 | /// |
---|
| 632 | /// Returns the base node (the source in this case) of the iterator |
---|
| 633 | Node baseNode(OutEdgeIt e) const { |
---|
| 634 | return source(e); |
---|
| 635 | } |
---|
[1627] | 636 | /// \brief Running node of the iterator |
---|
[1158] | 637 | /// |
---|
| 638 | /// Returns the running node (the target in this case) of the |
---|
| 639 | /// iterator |
---|
| 640 | Node runningNode(OutEdgeIt e) const { |
---|
| 641 | return target(e); |
---|
| 642 | } |
---|
| 643 | |
---|
[1627] | 644 | /// \brief Base node of the iterator |
---|
[1158] | 645 | /// |
---|
| 646 | /// Returns the base node (the target in this case) of the iterator |
---|
| 647 | Node baseNode(InEdgeIt e) const { |
---|
| 648 | return target(e); |
---|
| 649 | } |
---|
[1627] | 650 | /// \brief Running node of the iterator |
---|
[1158] | 651 | /// |
---|
| 652 | /// Returns the running node (the source in this case) of the |
---|
| 653 | /// iterator |
---|
| 654 | Node runningNode(InEdgeIt e) const { |
---|
| 655 | return source(e); |
---|
| 656 | } |
---|
| 657 | |
---|
[1627] | 658 | /// \brief Base node of the iterator |
---|
[1158] | 659 | /// |
---|
| 660 | /// Returns the base node of the iterator |
---|
[1367] | 661 | Node baseNode(IncEdgeIt) const { |
---|
[1158] | 662 | return INVALID; |
---|
| 663 | } |
---|
[1627] | 664 | |
---|
| 665 | /// \brief Running node of the iterator |
---|
[1158] | 666 | /// |
---|
| 667 | /// Returns the running node of the iterator |
---|
[1367] | 668 | Node runningNode(IncEdgeIt) const { |
---|
[1158] | 669 | return INVALID; |
---|
| 670 | } |
---|
| 671 | |
---|
[1022] | 672 | template <typename Graph> |
---|
| 673 | struct Constraints { |
---|
| 674 | void constraints() { |
---|
[1909] | 675 | checkConcept<BaseIterableUGraphConcept, Graph>(); |
---|
| 676 | checkConcept<IterableUGraphConcept, Graph>(); |
---|
| 677 | checkConcept<MappableUGraphConcept, Graph>(); |
---|
[1022] | 678 | } |
---|
| 679 | }; |
---|
| 680 | |
---|
| 681 | }; |
---|
| 682 | |
---|
[1030] | 683 | /// @} |
---|
| 684 | |
---|
[962] | 685 | } |
---|
| 686 | |
---|
| 687 | } |
---|
| 688 | |
---|
| 689 | #endif |
---|