[1911] | 1 | /* -*- C++ -*- |
---|
| 2 | * |
---|
| 3 | * lemon/concept/ugraph_component.h - Part of LEMON, a generic |
---|
| 4 | * C++ optimization library |
---|
| 5 | * |
---|
| 6 | * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi |
---|
| 7 | * Kutatocsoport (Egervary Research Group on Combinatorial Optimization, |
---|
| 8 | * EGRES). |
---|
| 9 | * |
---|
| 10 | * Permission to use, modify and distribute this software is granted |
---|
| 11 | * provided that this copyright notice appears in all copies. For |
---|
| 12 | * precise terms see the accompanying LICENSE file. |
---|
| 13 | * |
---|
| 14 | * This software is provided "AS IS" with no warranty of any kind, |
---|
| 15 | * express or implied, and with no claim as to its suitability for any |
---|
| 16 | * purpose. |
---|
| 17 | * |
---|
| 18 | */ |
---|
| 19 | |
---|
| 20 | /// \ingroup graph_concepts |
---|
| 21 | /// \file |
---|
| 22 | /// \brief Undirected bipartite graphs and components of. |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | #ifndef LEMON_CONCEPT_BPUGRAPH_H |
---|
| 26 | #define LEMON_CONCEPT_BPUGRAPH_H |
---|
| 27 | |
---|
| 28 | #include <lemon/concept/graph_component.h> |
---|
| 29 | |
---|
| 30 | #include <lemon/concept/graph.h> |
---|
| 31 | #include <lemon/concept/ugraph.h> |
---|
| 32 | |
---|
| 33 | #include <lemon/utility.h> |
---|
| 34 | |
---|
| 35 | namespace lemon { |
---|
| 36 | namespace concept { |
---|
| 37 | |
---|
| 38 | /// \addtogroup graph_concepts |
---|
| 39 | /// @{ |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | /// \brief Class describing the concept of Bipartite Undirected Graphs. |
---|
| 43 | /// |
---|
| 44 | /// This class describes the common interface of all |
---|
| 45 | /// Undirected Bipartite Graphs. |
---|
| 46 | /// |
---|
| 47 | /// As all concept describing classes it provides only interface |
---|
| 48 | /// without any sensible implementation. So any algorithm for |
---|
| 49 | /// bipartite undirected graph should compile with this class, but it |
---|
| 50 | /// will not run properly, of course. |
---|
| 51 | /// |
---|
| 52 | /// In LEMON bipartite undirected graphs also fulfill the concept of |
---|
| 53 | /// the undirected graphs (\ref lemon::concept::UGraph "UGraph Concept"). |
---|
| 54 | /// |
---|
| 55 | /// You can assume that all undirected bipartite graph can be handled |
---|
| 56 | /// as an undirected graph and consequently as a static graph. |
---|
| 57 | /// |
---|
| 58 | /// The bipartite graph stores two types of nodes which are named |
---|
| 59 | /// ANode and BNode. Even so the graph type does not contain ANode |
---|
| 60 | /// and BNode classes, becaue the nodes can be accessed just with the |
---|
| 61 | /// common Node class. |
---|
| 62 | /// |
---|
| 63 | /// The iteration on the partition can be done with the ANodeIt and |
---|
| 64 | /// BNodeIt classes. The node map can be used to map values to the nodes |
---|
| 65 | /// and similarly we can use to map values for just the ANodes and |
---|
| 66 | /// BNodes the ANodeMap and BNodeMap template classes. |
---|
| 67 | |
---|
| 68 | class BpUGraph { |
---|
| 69 | public: |
---|
| 70 | /// \todo undocumented |
---|
| 71 | /// |
---|
| 72 | typedef True UTag; |
---|
| 73 | |
---|
| 74 | /// \brief The base type of node iterators, |
---|
| 75 | /// or in other words, the trivial node iterator. |
---|
| 76 | /// |
---|
| 77 | /// This is the base type of each node iterator, |
---|
| 78 | /// thus each kind of node iterator converts to this. |
---|
| 79 | /// More precisely each kind of node iterator should be inherited |
---|
| 80 | /// from the trivial node iterator. The Node class represents |
---|
| 81 | /// both of two types of nodes. |
---|
| 82 | class Node { |
---|
| 83 | public: |
---|
| 84 | /// Default constructor |
---|
| 85 | |
---|
| 86 | /// @warning The default constructor sets the iterator |
---|
| 87 | /// to an undefined value. |
---|
| 88 | Node() { } |
---|
| 89 | /// Copy constructor. |
---|
| 90 | |
---|
| 91 | /// Copy constructor. |
---|
| 92 | /// |
---|
| 93 | Node(const Node&) { } |
---|
| 94 | |
---|
| 95 | /// Invalid constructor \& conversion. |
---|
| 96 | |
---|
| 97 | /// This constructor initializes the iterator to be invalid. |
---|
| 98 | /// \sa Invalid for more details. |
---|
| 99 | Node(Invalid) { } |
---|
| 100 | /// Equality operator |
---|
| 101 | |
---|
| 102 | /// Two iterators are equal if and only if they point to the |
---|
| 103 | /// same object or both are invalid. |
---|
| 104 | bool operator==(Node) const { return true; } |
---|
| 105 | |
---|
| 106 | /// Inequality operator |
---|
| 107 | |
---|
| 108 | /// \sa operator==(Node n) |
---|
| 109 | /// |
---|
| 110 | bool operator!=(Node) const { return true; } |
---|
| 111 | |
---|
| 112 | /// Artificial ordering operator. |
---|
| 113 | |
---|
| 114 | /// To allow the use of graph descriptors as key type in std::map or |
---|
| 115 | /// similar associative container we require this. |
---|
| 116 | /// |
---|
| 117 | /// \note This operator only have to define some strict ordering of |
---|
| 118 | /// the items; this order has nothing to do with the iteration |
---|
| 119 | /// ordering of the items. |
---|
| 120 | /// |
---|
| 121 | /// \bug This is a technical requirement. Do we really need this? |
---|
| 122 | bool operator<(Node) const { return false; } |
---|
| 123 | |
---|
| 124 | }; |
---|
| 125 | |
---|
| 126 | /// This iterator goes through each node. |
---|
| 127 | |
---|
| 128 | /// This iterator goes through each node. |
---|
| 129 | /// Its usage is quite simple, for example you can count the number |
---|
| 130 | /// of nodes in graph \c g of type \c Graph like this: |
---|
| 131 | /// \code |
---|
| 132 | /// int count=0; |
---|
| 133 | /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count; |
---|
| 134 | /// \endcode |
---|
| 135 | class NodeIt : public Node { |
---|
| 136 | public: |
---|
| 137 | /// Default constructor |
---|
| 138 | |
---|
| 139 | /// @warning The default constructor sets the iterator |
---|
| 140 | /// to an undefined value. |
---|
| 141 | NodeIt() { } |
---|
| 142 | /// Copy constructor. |
---|
| 143 | |
---|
| 144 | /// Copy constructor. |
---|
| 145 | /// |
---|
| 146 | NodeIt(const NodeIt& n) : Node(n) { } |
---|
| 147 | /// Invalid constructor \& conversion. |
---|
| 148 | |
---|
| 149 | /// Initialize the iterator to be invalid. |
---|
| 150 | /// \sa Invalid for more details. |
---|
| 151 | NodeIt(Invalid) { } |
---|
| 152 | /// Sets the iterator to the first node. |
---|
| 153 | |
---|
| 154 | /// Sets the iterator to the first node of \c g. |
---|
| 155 | /// |
---|
| 156 | NodeIt(const BpUGraph&) { } |
---|
| 157 | /// Node -> NodeIt conversion. |
---|
| 158 | |
---|
| 159 | /// Sets the iterator to the node of \c the graph pointed by |
---|
| 160 | /// the trivial iterator. |
---|
| 161 | /// This feature necessitates that each time we |
---|
| 162 | /// iterate the edge-set, the iteration order is the same. |
---|
| 163 | NodeIt(const BpUGraph&, const Node&) { } |
---|
| 164 | /// Next node. |
---|
| 165 | |
---|
| 166 | /// Assign the iterator to the next node. |
---|
| 167 | /// |
---|
| 168 | NodeIt& operator++() { return *this; } |
---|
| 169 | }; |
---|
| 170 | |
---|
| 171 | /// This iterator goes through each ANode. |
---|
| 172 | |
---|
| 173 | /// This iterator goes through each ANode. |
---|
| 174 | /// Its usage is quite simple, for example you can count the number |
---|
| 175 | /// of nodes in graph \c g of type \c Graph like this: |
---|
| 176 | /// \code |
---|
| 177 | /// int count=0; |
---|
| 178 | /// for (Graph::ANodeIt n(g); n!=INVALID; ++n) ++count; |
---|
| 179 | /// \endcode |
---|
| 180 | class ANodeIt : public Node { |
---|
| 181 | public: |
---|
| 182 | /// Default constructor |
---|
| 183 | |
---|
| 184 | /// @warning The default constructor sets the iterator |
---|
| 185 | /// to an undefined value. |
---|
| 186 | ANodeIt() { } |
---|
| 187 | /// Copy constructor. |
---|
| 188 | |
---|
| 189 | /// Copy constructor. |
---|
| 190 | /// |
---|
| 191 | ANodeIt(const ANodeIt& n) : Node(n) { } |
---|
| 192 | /// Invalid constructor \& conversion. |
---|
| 193 | |
---|
| 194 | /// Initialize the iterator to be invalid. |
---|
| 195 | /// \sa Invalid for more details. |
---|
| 196 | ANodeIt(Invalid) { } |
---|
| 197 | /// Sets the iterator to the first node. |
---|
| 198 | |
---|
| 199 | /// Sets the iterator to the first node of \c g. |
---|
| 200 | /// |
---|
| 201 | ANodeIt(const BpUGraph&) { } |
---|
| 202 | /// Node -> ANodeIt conversion. |
---|
| 203 | |
---|
| 204 | /// Sets the iterator to the node of \c the graph pointed by |
---|
| 205 | /// the trivial iterator. |
---|
| 206 | /// This feature necessitates that each time we |
---|
| 207 | /// iterate the edge-set, the iteration order is the same. |
---|
| 208 | ANodeIt(const BpUGraph&, const Node&) { } |
---|
| 209 | /// Next node. |
---|
| 210 | |
---|
| 211 | /// Assign the iterator to the next node. |
---|
| 212 | /// |
---|
| 213 | ANodeIt& operator++() { return *this; } |
---|
| 214 | }; |
---|
| 215 | |
---|
| 216 | /// This iterator goes through each BNode. |
---|
| 217 | |
---|
| 218 | /// This iterator goes through each BNode. |
---|
| 219 | /// Its usage is quite simple, for example you can count the number |
---|
| 220 | /// of nodes in graph \c g of type \c Graph like this: |
---|
| 221 | /// \code |
---|
| 222 | /// int count=0; |
---|
| 223 | /// for (Graph::BNodeIt n(g); n!=INVALID; ++n) ++count; |
---|
| 224 | /// \endcode |
---|
| 225 | class BNodeIt : public Node { |
---|
| 226 | public: |
---|
| 227 | /// Default constructor |
---|
| 228 | |
---|
| 229 | /// @warning The default constructor sets the iterator |
---|
| 230 | /// to an undefined value. |
---|
| 231 | BNodeIt() { } |
---|
| 232 | /// Copy constructor. |
---|
| 233 | |
---|
| 234 | /// Copy constructor. |
---|
| 235 | /// |
---|
| 236 | BNodeIt(const BNodeIt& n) : Node(n) { } |
---|
| 237 | /// Invalid constructor \& conversion. |
---|
| 238 | |
---|
| 239 | /// Initialize the iterator to be invalid. |
---|
| 240 | /// \sa Invalid for more details. |
---|
| 241 | BNodeIt(Invalid) { } |
---|
| 242 | /// Sets the iterator to the first node. |
---|
| 243 | |
---|
| 244 | /// Sets the iterator to the first node of \c g. |
---|
| 245 | /// |
---|
| 246 | BNodeIt(const BpUGraph&) { } |
---|
| 247 | /// Node -> BNodeIt conversion. |
---|
| 248 | |
---|
| 249 | /// Sets the iterator to the node of \c the graph pointed by |
---|
| 250 | /// the trivial iterator. |
---|
| 251 | /// This feature necessitates that each time we |
---|
| 252 | /// iterate the edge-set, the iteration order is the same. |
---|
| 253 | BNodeIt(const BpUGraph&, const Node&) { } |
---|
| 254 | /// Next node. |
---|
| 255 | |
---|
| 256 | /// Assign the iterator to the next node. |
---|
| 257 | /// |
---|
| 258 | BNodeIt& operator++() { return *this; } |
---|
| 259 | }; |
---|
| 260 | |
---|
| 261 | |
---|
| 262 | /// The base type of the undirected edge iterators. |
---|
| 263 | |
---|
| 264 | /// The base type of the undirected edge iterators. |
---|
| 265 | /// |
---|
| 266 | class UEdge { |
---|
| 267 | public: |
---|
| 268 | /// Default constructor |
---|
| 269 | |
---|
| 270 | /// @warning The default constructor sets the iterator |
---|
| 271 | /// to an undefined value. |
---|
| 272 | UEdge() { } |
---|
| 273 | /// Copy constructor. |
---|
| 274 | |
---|
| 275 | /// Copy constructor. |
---|
| 276 | /// |
---|
| 277 | UEdge(const UEdge&) { } |
---|
| 278 | /// Initialize the iterator to be invalid. |
---|
| 279 | |
---|
| 280 | /// Initialize the iterator to be invalid. |
---|
| 281 | /// |
---|
| 282 | UEdge(Invalid) { } |
---|
| 283 | /// Equality operator |
---|
| 284 | |
---|
| 285 | /// Two iterators are equal if and only if they point to the |
---|
| 286 | /// same object or both are invalid. |
---|
| 287 | bool operator==(UEdge) const { return true; } |
---|
| 288 | /// Inequality operator |
---|
| 289 | |
---|
| 290 | /// \sa operator==(UEdge n) |
---|
| 291 | /// |
---|
| 292 | bool operator!=(UEdge) const { return true; } |
---|
| 293 | |
---|
| 294 | /// Artificial ordering operator. |
---|
| 295 | |
---|
| 296 | /// To allow the use of graph descriptors as key type in std::map or |
---|
| 297 | /// similar associative container we require this. |
---|
| 298 | /// |
---|
| 299 | /// \note This operator only have to define some strict ordering of |
---|
| 300 | /// the items; this order has nothing to do with the iteration |
---|
| 301 | /// ordering of the items. |
---|
| 302 | /// |
---|
| 303 | /// \bug This is a technical requirement. Do we really need this? |
---|
| 304 | bool operator<(UEdge) const { return false; } |
---|
| 305 | }; |
---|
| 306 | |
---|
| 307 | /// This iterator goes through each undirected edge. |
---|
| 308 | |
---|
| 309 | /// This iterator goes through each undirected edge of a graph. |
---|
| 310 | /// Its usage is quite simple, for example you can count the number |
---|
| 311 | /// of undirected edges in a graph \c g of type \c Graph as follows: |
---|
| 312 | /// \code |
---|
| 313 | /// int count=0; |
---|
| 314 | /// for(Graph::UEdgeIt e(g); e!=INVALID; ++e) ++count; |
---|
| 315 | /// \endcode |
---|
| 316 | class UEdgeIt : public UEdge { |
---|
| 317 | public: |
---|
| 318 | /// Default constructor |
---|
| 319 | |
---|
| 320 | /// @warning The default constructor sets the iterator |
---|
| 321 | /// to an undefined value. |
---|
| 322 | UEdgeIt() { } |
---|
| 323 | /// Copy constructor. |
---|
| 324 | |
---|
| 325 | /// Copy constructor. |
---|
| 326 | /// |
---|
| 327 | UEdgeIt(const UEdgeIt& e) : UEdge(e) { } |
---|
| 328 | /// Initialize the iterator to be invalid. |
---|
| 329 | |
---|
| 330 | /// Initialize the iterator to be invalid. |
---|
| 331 | /// |
---|
| 332 | UEdgeIt(Invalid) { } |
---|
| 333 | /// This constructor sets the iterator to the first undirected edge. |
---|
| 334 | |
---|
| 335 | /// This constructor sets the iterator to the first undirected edge. |
---|
| 336 | UEdgeIt(const BpUGraph&) { } |
---|
| 337 | /// UEdge -> UEdgeIt conversion |
---|
| 338 | |
---|
| 339 | /// Sets the iterator to the value of the trivial iterator. |
---|
| 340 | /// This feature necessitates that each time we |
---|
| 341 | /// iterate the undirected edge-set, the iteration order is the |
---|
| 342 | /// same. |
---|
| 343 | UEdgeIt(const BpUGraph&, const UEdge&) { } |
---|
| 344 | /// Next undirected edge |
---|
| 345 | |
---|
| 346 | /// Assign the iterator to the next undirected edge. |
---|
| 347 | UEdgeIt& operator++() { return *this; } |
---|
| 348 | }; |
---|
| 349 | |
---|
| 350 | /// \brief This iterator goes trough the incident undirected |
---|
| 351 | /// edges of a node. |
---|
| 352 | /// |
---|
| 353 | /// This iterator goes trough the incident undirected edges |
---|
| 354 | /// of a certain node |
---|
| 355 | /// of a graph. |
---|
| 356 | /// Its usage is quite simple, for example you can compute the |
---|
| 357 | /// degree (i.e. count the number |
---|
| 358 | /// of incident edges of a node \c n |
---|
| 359 | /// in graph \c g of type \c Graph as follows. |
---|
| 360 | /// \code |
---|
| 361 | /// int count=0; |
---|
| 362 | /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
---|
| 363 | /// \endcode |
---|
| 364 | class IncEdgeIt : public UEdge { |
---|
| 365 | public: |
---|
| 366 | /// Default constructor |
---|
| 367 | |
---|
| 368 | /// @warning The default constructor sets the iterator |
---|
| 369 | /// to an undefined value. |
---|
| 370 | IncEdgeIt() { } |
---|
| 371 | /// Copy constructor. |
---|
| 372 | |
---|
| 373 | /// Copy constructor. |
---|
| 374 | /// |
---|
| 375 | IncEdgeIt(const IncEdgeIt& e) : UEdge(e) { } |
---|
| 376 | /// Initialize the iterator to be invalid. |
---|
| 377 | |
---|
| 378 | /// Initialize the iterator to be invalid. |
---|
| 379 | /// |
---|
| 380 | IncEdgeIt(Invalid) { } |
---|
| 381 | /// This constructor sets the iterator to first incident edge. |
---|
| 382 | |
---|
| 383 | /// This constructor set the iterator to the first incident edge of |
---|
| 384 | /// the node. |
---|
| 385 | IncEdgeIt(const BpUGraph&, const Node&) { } |
---|
| 386 | /// UEdge -> IncEdgeIt conversion |
---|
| 387 | |
---|
| 388 | /// Sets the iterator to the value of the trivial iterator \c e. |
---|
| 389 | /// This feature necessitates that each time we |
---|
| 390 | /// iterate the edge-set, the iteration order is the same. |
---|
| 391 | IncEdgeIt(const BpUGraph&, const UEdge&) { } |
---|
| 392 | /// Next incident edge |
---|
| 393 | |
---|
| 394 | /// Assign the iterator to the next incident edge |
---|
| 395 | /// of the corresponding node. |
---|
| 396 | IncEdgeIt& operator++() { return *this; } |
---|
| 397 | }; |
---|
| 398 | |
---|
| 399 | /// The directed edge type. |
---|
| 400 | |
---|
| 401 | /// The directed edge type. It can be converted to the |
---|
| 402 | /// undirected edge. |
---|
| 403 | class Edge : public UEdge { |
---|
| 404 | public: |
---|
| 405 | /// Default constructor |
---|
| 406 | |
---|
| 407 | /// @warning The default constructor sets the iterator |
---|
| 408 | /// to an undefined value. |
---|
| 409 | Edge() { } |
---|
| 410 | /// Copy constructor. |
---|
| 411 | |
---|
| 412 | /// Copy constructor. |
---|
| 413 | /// |
---|
| 414 | Edge(const Edge& e) : UEdge(e) { } |
---|
| 415 | /// Initialize the iterator to be invalid. |
---|
| 416 | |
---|
| 417 | /// Initialize the iterator to be invalid. |
---|
| 418 | /// |
---|
| 419 | Edge(Invalid) { } |
---|
| 420 | /// Equality operator |
---|
| 421 | |
---|
| 422 | /// Two iterators are equal if and only if they point to the |
---|
| 423 | /// same object or both are invalid. |
---|
| 424 | bool operator==(Edge) const { return true; } |
---|
| 425 | /// Inequality operator |
---|
| 426 | |
---|
| 427 | /// \sa operator==(Edge n) |
---|
| 428 | /// |
---|
| 429 | bool operator!=(Edge) const { return true; } |
---|
| 430 | |
---|
| 431 | /// Artificial ordering operator. |
---|
| 432 | |
---|
| 433 | /// To allow the use of graph descriptors as key type in std::map or |
---|
| 434 | /// similar associative container we require this. |
---|
| 435 | /// |
---|
| 436 | /// \note This operator only have to define some strict ordering of |
---|
| 437 | /// the items; this order has nothing to do with the iteration |
---|
| 438 | /// ordering of the items. |
---|
| 439 | /// |
---|
| 440 | /// \bug This is a technical requirement. Do we really need this? |
---|
| 441 | bool operator<(Edge) const { return false; } |
---|
| 442 | |
---|
| 443 | }; |
---|
| 444 | /// This iterator goes through each directed edge. |
---|
| 445 | |
---|
| 446 | /// This iterator goes through each edge of a graph. |
---|
| 447 | /// Its usage is quite simple, for example you can count the number |
---|
| 448 | /// of edges in a graph \c g of type \c Graph as follows: |
---|
| 449 | /// \code |
---|
| 450 | /// int count=0; |
---|
| 451 | /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count; |
---|
| 452 | /// \endcode |
---|
| 453 | class EdgeIt : public Edge { |
---|
| 454 | public: |
---|
| 455 | /// Default constructor |
---|
| 456 | |
---|
| 457 | /// @warning The default constructor sets the iterator |
---|
| 458 | /// to an undefined value. |
---|
| 459 | EdgeIt() { } |
---|
| 460 | /// Copy constructor. |
---|
| 461 | |
---|
| 462 | /// Copy constructor. |
---|
| 463 | /// |
---|
| 464 | EdgeIt(const EdgeIt& e) : Edge(e) { } |
---|
| 465 | /// Initialize the iterator to be invalid. |
---|
| 466 | |
---|
| 467 | /// Initialize the iterator to be invalid. |
---|
| 468 | /// |
---|
| 469 | EdgeIt(Invalid) { } |
---|
| 470 | /// This constructor sets the iterator to the first edge. |
---|
| 471 | |
---|
| 472 | /// This constructor sets the iterator to the first edge of \c g. |
---|
| 473 | ///@param g the graph |
---|
| 474 | EdgeIt(const BpUGraph &g) { ignore_unused_variable_warning(g); } |
---|
| 475 | /// Edge -> EdgeIt conversion |
---|
| 476 | |
---|
| 477 | /// Sets the iterator to the value of the trivial iterator \c e. |
---|
| 478 | /// This feature necessitates that each time we |
---|
| 479 | /// iterate the edge-set, the iteration order is the same. |
---|
| 480 | EdgeIt(const BpUGraph&, const Edge&) { } |
---|
| 481 | ///Next edge |
---|
| 482 | |
---|
| 483 | /// Assign the iterator to the next edge. |
---|
| 484 | EdgeIt& operator++() { return *this; } |
---|
| 485 | }; |
---|
| 486 | |
---|
| 487 | /// This iterator goes trough the outgoing directed edges of a node. |
---|
| 488 | |
---|
| 489 | /// This iterator goes trough the \e outgoing edges of a certain node |
---|
| 490 | /// of a graph. |
---|
| 491 | /// Its usage is quite simple, for example you can count the number |
---|
| 492 | /// of outgoing edges of a node \c n |
---|
| 493 | /// in graph \c g of type \c Graph as follows. |
---|
| 494 | /// \code |
---|
| 495 | /// int count=0; |
---|
| 496 | /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
---|
| 497 | /// \endcode |
---|
| 498 | |
---|
| 499 | class OutEdgeIt : public Edge { |
---|
| 500 | public: |
---|
| 501 | /// Default constructor |
---|
| 502 | |
---|
| 503 | /// @warning The default constructor sets the iterator |
---|
| 504 | /// to an undefined value. |
---|
| 505 | OutEdgeIt() { } |
---|
| 506 | /// Copy constructor. |
---|
| 507 | |
---|
| 508 | /// Copy constructor. |
---|
| 509 | /// |
---|
| 510 | OutEdgeIt(const OutEdgeIt& e) : Edge(e) { } |
---|
| 511 | /// Initialize the iterator to be invalid. |
---|
| 512 | |
---|
| 513 | /// Initialize the iterator to be invalid. |
---|
| 514 | /// |
---|
| 515 | OutEdgeIt(Invalid) { } |
---|
| 516 | /// This constructor sets the iterator to the first outgoing edge. |
---|
| 517 | |
---|
| 518 | /// This constructor sets the iterator to the first outgoing edge of |
---|
| 519 | /// the node. |
---|
| 520 | ///@param n the node |
---|
| 521 | ///@param g the graph |
---|
| 522 | OutEdgeIt(const BpUGraph& n, const Node& g) { |
---|
| 523 | ignore_unused_variable_warning(n); |
---|
| 524 | ignore_unused_variable_warning(g); |
---|
| 525 | } |
---|
| 526 | /// Edge -> OutEdgeIt conversion |
---|
| 527 | |
---|
| 528 | /// Sets the iterator to the value of the trivial iterator. |
---|
| 529 | /// This feature necessitates that each time we |
---|
| 530 | /// iterate the edge-set, the iteration order is the same. |
---|
| 531 | OutEdgeIt(const BpUGraph&, const Edge&) { } |
---|
| 532 | ///Next outgoing edge |
---|
| 533 | |
---|
| 534 | /// Assign the iterator to the next |
---|
| 535 | /// outgoing edge of the corresponding node. |
---|
| 536 | OutEdgeIt& operator++() { return *this; } |
---|
| 537 | }; |
---|
| 538 | |
---|
| 539 | /// This iterator goes trough the incoming directed edges of a node. |
---|
| 540 | |
---|
| 541 | /// This iterator goes trough the \e incoming edges of a certain node |
---|
| 542 | /// of a graph. |
---|
| 543 | /// Its usage is quite simple, for example you can count the number |
---|
| 544 | /// of outgoing edges of a node \c n |
---|
| 545 | /// in graph \c g of type \c Graph as follows. |
---|
| 546 | /// \code |
---|
| 547 | /// int count=0; |
---|
| 548 | /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count; |
---|
| 549 | /// \endcode |
---|
| 550 | |
---|
| 551 | class InEdgeIt : public Edge { |
---|
| 552 | public: |
---|
| 553 | /// Default constructor |
---|
| 554 | |
---|
| 555 | /// @warning The default constructor sets the iterator |
---|
| 556 | /// to an undefined value. |
---|
| 557 | InEdgeIt() { } |
---|
| 558 | /// Copy constructor. |
---|
| 559 | |
---|
| 560 | /// Copy constructor. |
---|
| 561 | /// |
---|
| 562 | InEdgeIt(const InEdgeIt& e) : Edge(e) { } |
---|
| 563 | /// Initialize the iterator to be invalid. |
---|
| 564 | |
---|
| 565 | /// Initialize the iterator to be invalid. |
---|
| 566 | /// |
---|
| 567 | InEdgeIt(Invalid) { } |
---|
| 568 | /// This constructor sets the iterator to first incoming edge. |
---|
| 569 | |
---|
| 570 | /// This constructor set the iterator to the first incoming edge of |
---|
| 571 | /// the node. |
---|
| 572 | ///@param n the node |
---|
| 573 | ///@param g the graph |
---|
| 574 | InEdgeIt(const BpUGraph& g, const Node& n) { |
---|
| 575 | ignore_unused_variable_warning(n); |
---|
| 576 | ignore_unused_variable_warning(g); |
---|
| 577 | } |
---|
| 578 | /// Edge -> InEdgeIt conversion |
---|
| 579 | |
---|
| 580 | /// Sets the iterator to the value of the trivial iterator \c e. |
---|
| 581 | /// This feature necessitates that each time we |
---|
| 582 | /// iterate the edge-set, the iteration order is the same. |
---|
| 583 | InEdgeIt(const BpUGraph&, const Edge&) { } |
---|
| 584 | /// Next incoming edge |
---|
| 585 | |
---|
| 586 | /// Assign the iterator to the next inedge of the corresponding node. |
---|
| 587 | /// |
---|
| 588 | InEdgeIt& operator++() { return *this; } |
---|
| 589 | }; |
---|
| 590 | |
---|
| 591 | /// \brief Read write map of the nodes to type \c T. |
---|
| 592 | /// |
---|
| 593 | /// ReadWrite map of the nodes to type \c T. |
---|
| 594 | /// \sa Reference |
---|
| 595 | /// \warning Making maps that can handle bool type (NodeMap<bool>) |
---|
| 596 | /// needs some extra attention! |
---|
| 597 | /// \todo Wrong documentation |
---|
| 598 | template<class T> |
---|
| 599 | class NodeMap : public ReadWriteMap< Node, T > |
---|
| 600 | { |
---|
| 601 | public: |
---|
| 602 | |
---|
| 603 | ///\e |
---|
| 604 | NodeMap(const BpUGraph&) { } |
---|
| 605 | ///\e |
---|
| 606 | NodeMap(const BpUGraph&, T) { } |
---|
| 607 | |
---|
| 608 | ///Copy constructor |
---|
| 609 | NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } |
---|
| 610 | ///Assignment operator |
---|
| 611 | NodeMap& operator=(const NodeMap&) { return *this; } |
---|
| 612 | // \todo fix this concept |
---|
| 613 | }; |
---|
| 614 | |
---|
| 615 | /// \brief Read write map of the ANodes to type \c T. |
---|
| 616 | /// |
---|
| 617 | /// ReadWrite map of the ANodes to type \c T. |
---|
| 618 | /// \sa Reference |
---|
| 619 | /// \warning Making maps that can handle bool type (NodeMap<bool>) |
---|
| 620 | /// needs some extra attention! |
---|
| 621 | /// \todo Wrong documentation |
---|
| 622 | template<class T> |
---|
| 623 | class ANodeMap : public ReadWriteMap< Node, T > |
---|
| 624 | { |
---|
| 625 | public: |
---|
| 626 | |
---|
| 627 | ///\e |
---|
| 628 | ANodeMap(const BpUGraph&) { } |
---|
| 629 | ///\e |
---|
| 630 | ANodeMap(const BpUGraph&, T) { } |
---|
| 631 | |
---|
| 632 | ///Copy constructor |
---|
| 633 | ANodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } |
---|
| 634 | ///Assignment operator |
---|
| 635 | ANodeMap& operator=(const NodeMap&) { return *this; } |
---|
| 636 | // \todo fix this concept |
---|
| 637 | }; |
---|
| 638 | |
---|
| 639 | /// \brief Read write map of the BNodes to type \c T. |
---|
| 640 | /// |
---|
| 641 | /// ReadWrite map of the BNodes to type \c T. |
---|
| 642 | /// \sa Reference |
---|
| 643 | /// \warning Making maps that can handle bool type (NodeMap<bool>) |
---|
| 644 | /// needs some extra attention! |
---|
| 645 | /// \todo Wrong documentation |
---|
| 646 | template<class T> |
---|
| 647 | class BNodeMap : public ReadWriteMap< Node, T > |
---|
| 648 | { |
---|
| 649 | public: |
---|
| 650 | |
---|
| 651 | ///\e |
---|
| 652 | BNodeMap(const BpUGraph&) { } |
---|
| 653 | ///\e |
---|
| 654 | BNodeMap(const BpUGraph&, T) { } |
---|
| 655 | |
---|
| 656 | ///Copy constructor |
---|
| 657 | BNodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } |
---|
| 658 | ///Assignment operator |
---|
| 659 | BNodeMap& operator=(const NodeMap&) { return *this; } |
---|
| 660 | // \todo fix this concept |
---|
| 661 | }; |
---|
| 662 | |
---|
| 663 | /// \brief Read write map of the directed edges to type \c T. |
---|
| 664 | /// |
---|
| 665 | /// Reference map of the directed edges to type \c T. |
---|
| 666 | /// \sa Reference |
---|
| 667 | /// \warning Making maps that can handle bool type (EdgeMap<bool>) |
---|
| 668 | /// needs some extra attention! |
---|
| 669 | /// \todo Wrong documentation |
---|
| 670 | template<class T> |
---|
| 671 | class EdgeMap : public ReadWriteMap<Edge,T> |
---|
| 672 | { |
---|
| 673 | public: |
---|
| 674 | |
---|
| 675 | ///\e |
---|
| 676 | EdgeMap(const BpUGraph&) { } |
---|
| 677 | ///\e |
---|
| 678 | EdgeMap(const BpUGraph&, T) { } |
---|
| 679 | ///Copy constructor |
---|
| 680 | EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { } |
---|
| 681 | ///Assignment operator |
---|
| 682 | EdgeMap& operator=(const EdgeMap&) { return *this; } |
---|
| 683 | // \todo fix this concept |
---|
| 684 | }; |
---|
| 685 | |
---|
| 686 | /// Read write map of the undirected edges to type \c T. |
---|
| 687 | |
---|
| 688 | /// Reference map of the edges to type \c T. |
---|
| 689 | /// \sa Reference |
---|
| 690 | /// \warning Making maps that can handle bool type (UEdgeMap<bool>) |
---|
| 691 | /// needs some extra attention! |
---|
| 692 | /// \todo Wrong documentation |
---|
| 693 | template<class T> |
---|
| 694 | class UEdgeMap : public ReadWriteMap<UEdge,T> |
---|
| 695 | { |
---|
| 696 | public: |
---|
| 697 | |
---|
| 698 | ///\e |
---|
| 699 | UEdgeMap(const BpUGraph&) { } |
---|
| 700 | ///\e |
---|
| 701 | UEdgeMap(const BpUGraph&, T) { } |
---|
| 702 | ///Copy constructor |
---|
| 703 | UEdgeMap(const UEdgeMap& em) : ReadWriteMap<UEdge,T>(em) {} |
---|
| 704 | ///Assignment operator |
---|
| 705 | UEdgeMap &operator=(const UEdgeMap&) { return *this; } |
---|
| 706 | // \todo fix this concept |
---|
| 707 | }; |
---|
| 708 | |
---|
| 709 | /// \brief Direct the given undirected edge. |
---|
| 710 | /// |
---|
| 711 | /// Direct the given undirected edge. The returned edge source |
---|
| 712 | /// will be the given edge. |
---|
| 713 | Edge direct(const UEdge&, const Node&) const { |
---|
| 714 | return INVALID; |
---|
| 715 | } |
---|
| 716 | |
---|
| 717 | /// \brief Direct the given undirected edge. |
---|
| 718 | /// |
---|
| 719 | /// Direct the given undirected edge. The returned edge source |
---|
| 720 | /// will be the source of the undirected edge if the given bool |
---|
| 721 | /// is true. |
---|
| 722 | Edge direct(const UEdge&, bool) const { |
---|
| 723 | return INVALID; |
---|
| 724 | } |
---|
| 725 | |
---|
| 726 | /// \brief Returns true when the given node is an ANode. |
---|
| 727 | /// |
---|
| 728 | /// Returns true when the given node is an ANode. |
---|
| 729 | bool aNode(Node) const { return true;} |
---|
| 730 | |
---|
| 731 | /// \brief Returns true when the given node is an BNode. |
---|
| 732 | /// |
---|
| 733 | /// Returns true when the given node is an BNode. |
---|
| 734 | bool bNode(Node) const { return true;} |
---|
| 735 | |
---|
| 736 | /// \brief Returns the edge's end node which is in the ANode set. |
---|
| 737 | /// |
---|
| 738 | /// Returns the edge's end node which is in the ANode set. |
---|
| 739 | Node aNode(UEdge) const { return INVALID;} |
---|
| 740 | |
---|
| 741 | /// \brief Returns the edge's end node which is in the BNode set. |
---|
| 742 | /// |
---|
| 743 | /// Returns the edge's end node which is in the BNode set. |
---|
| 744 | Node bNode(UEdge) const { return INVALID;} |
---|
| 745 | |
---|
| 746 | /// \brief Returns true if the edge has default orientation. |
---|
| 747 | /// |
---|
| 748 | /// Returns whether the given directed edge is same orientation as |
---|
| 749 | /// the corresponding undirected edge. |
---|
| 750 | bool direction(Edge) const { return true; } |
---|
| 751 | |
---|
| 752 | /// \brief Returns the opposite directed edge. |
---|
| 753 | /// |
---|
| 754 | /// Returns the opposite directed edge. |
---|
| 755 | Edge oppositeEdge(Edge) const { return INVALID; } |
---|
| 756 | |
---|
| 757 | /// \brief Opposite node on an edge |
---|
| 758 | /// |
---|
| 759 | /// \return the opposite of the given Node on the given Edge |
---|
| 760 | Node oppositeNode(Node, UEdge) const { return INVALID; } |
---|
| 761 | |
---|
| 762 | /// \brief First node of the undirected edge. |
---|
| 763 | /// |
---|
| 764 | /// \return the first node of the given UEdge. |
---|
| 765 | /// |
---|
| 766 | /// Naturally uectected edges don't have direction and thus |
---|
| 767 | /// don't have source and target node. But we use these two methods |
---|
| 768 | /// to query the two endnodes of the edge. The direction of the edge |
---|
| 769 | /// which arises this way is called the inherent direction of the |
---|
| 770 | /// undirected edge, and is used to define the "default" direction |
---|
| 771 | /// of the directed versions of the edges. |
---|
| 772 | /// \sa direction |
---|
| 773 | Node source(UEdge) const { return INVALID; } |
---|
| 774 | |
---|
| 775 | /// \brief Second node of the undirected edge. |
---|
| 776 | Node target(UEdge) const { return INVALID; } |
---|
| 777 | |
---|
| 778 | /// \brief Source node of the directed edge. |
---|
| 779 | Node source(Edge) const { return INVALID; } |
---|
| 780 | |
---|
| 781 | /// \brief Target node of the directed edge. |
---|
| 782 | Node target(Edge) const { return INVALID; } |
---|
| 783 | |
---|
| 784 | /// \brief Base node of the iterator |
---|
| 785 | /// |
---|
| 786 | /// Returns the base node (the source in this case) of the iterator |
---|
| 787 | Node baseNode(OutEdgeIt e) const { |
---|
| 788 | return source(e); |
---|
| 789 | } |
---|
| 790 | |
---|
| 791 | /// \brief Running node of the iterator |
---|
| 792 | /// |
---|
| 793 | /// Returns the running node (the target in this case) of the |
---|
| 794 | /// iterator |
---|
| 795 | Node runningNode(OutEdgeIt e) const { |
---|
| 796 | return target(e); |
---|
| 797 | } |
---|
| 798 | |
---|
| 799 | /// \brief Base node of the iterator |
---|
| 800 | /// |
---|
| 801 | /// Returns the base node (the target in this case) of the iterator |
---|
| 802 | Node baseNode(InEdgeIt e) const { |
---|
| 803 | return target(e); |
---|
| 804 | } |
---|
| 805 | /// \brief Running node of the iterator |
---|
| 806 | /// |
---|
| 807 | /// Returns the running node (the source in this case) of the |
---|
| 808 | /// iterator |
---|
| 809 | Node runningNode(InEdgeIt e) const { |
---|
| 810 | return source(e); |
---|
| 811 | } |
---|
| 812 | |
---|
| 813 | /// \brief Base node of the iterator |
---|
| 814 | /// |
---|
| 815 | /// Returns the base node of the iterator |
---|
| 816 | Node baseNode(IncEdgeIt) const { |
---|
| 817 | return INVALID; |
---|
| 818 | } |
---|
| 819 | |
---|
| 820 | /// \brief Running node of the iterator |
---|
| 821 | /// |
---|
| 822 | /// Returns the running node of the iterator |
---|
| 823 | Node runningNode(IncEdgeIt) const { |
---|
| 824 | return INVALID; |
---|
| 825 | } |
---|
| 826 | |
---|
| 827 | template <typename Graph> |
---|
| 828 | struct Constraints { |
---|
| 829 | void constraints() { |
---|
| 830 | } |
---|
| 831 | }; |
---|
| 832 | |
---|
| 833 | }; |
---|
| 834 | |
---|
| 835 | /// \brief An empty non-static undirected graph class. |
---|
| 836 | /// |
---|
| 837 | /// This class provides everything that \ref BpUGraph does. |
---|
| 838 | /// Additionally it enables building graphs from scratch. |
---|
| 839 | class ExtendableBpUGraph : public BpUGraph { |
---|
| 840 | public: |
---|
| 841 | |
---|
| 842 | /// \brief Add a new ANode to the graph. |
---|
| 843 | /// |
---|
| 844 | /// Add a new ANode to the graph. |
---|
| 845 | /// \return the new node. |
---|
| 846 | Node addANode(); |
---|
| 847 | |
---|
| 848 | /// \brief Add a new ANode to the graph. |
---|
| 849 | /// |
---|
| 850 | /// Add a new ANode to the graph. |
---|
| 851 | /// \return the new node. |
---|
| 852 | Node addBNode(); |
---|
| 853 | |
---|
| 854 | /// \brief Add a new undirected edge to the graph. |
---|
| 855 | /// |
---|
| 856 | /// Add a new undirected edge to the graph. One of the nodes |
---|
| 857 | /// should be ANode and the other should be BNode. |
---|
| 858 | /// \pre The nodes are not in the same nodeset. |
---|
| 859 | /// \return the new edge. |
---|
| 860 | UEdge addEdge(const Node& from, const Node& to); |
---|
| 861 | |
---|
| 862 | /// \brief Resets the graph. |
---|
| 863 | /// |
---|
| 864 | /// This function deletes all undirected edges and nodes of the graph. |
---|
| 865 | /// It also frees the memory allocated to store them. |
---|
| 866 | void clear() { } |
---|
| 867 | |
---|
| 868 | template <typename Graph> |
---|
| 869 | struct Constraints { |
---|
| 870 | void constraints() {} |
---|
| 871 | }; |
---|
| 872 | |
---|
| 873 | }; |
---|
| 874 | |
---|
| 875 | /// \brief An empty erasable undirected graph class. |
---|
| 876 | /// |
---|
| 877 | /// This class is an extension of \ref ExtendableBpUGraph. It makes it |
---|
| 878 | /// possible to erase undirected edges or nodes. |
---|
| 879 | class ErasableBpUGraph : public ExtendableBpUGraph { |
---|
| 880 | public: |
---|
| 881 | |
---|
| 882 | /// \brief Deletes a node. |
---|
| 883 | /// |
---|
| 884 | /// Deletes a node. |
---|
| 885 | /// |
---|
| 886 | void erase(Node) { } |
---|
| 887 | /// \brief Deletes an undirected edge. |
---|
| 888 | /// |
---|
| 889 | /// Deletes an undirected edge. |
---|
| 890 | /// |
---|
| 891 | void erase(UEdge) { } |
---|
| 892 | |
---|
| 893 | template <typename Graph> |
---|
| 894 | struct Constraints { |
---|
| 895 | void constraints() {} |
---|
| 896 | }; |
---|
| 897 | |
---|
| 898 | }; |
---|
| 899 | |
---|
| 900 | /// @} |
---|
| 901 | |
---|
| 902 | } |
---|
| 903 | |
---|
| 904 | } |
---|
| 905 | |
---|
| 906 | #endif |
---|