gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Small doc improvements
0 8 0
default
8 files changed with 42 insertions and 28 deletions:
↑ Collapse diff ↑
Ignore white space 6 line context
... ...
@@ -354,73 +354,73 @@
354 354
 - \ref CancelAndTighten The Cancel and Tighten algorithm.
355 355
 - \ref CycleCanceling Cycle-Canceling algorithms.
356 356

	
357 357
In general NetworkSimplex is the most efficient implementation,
358 358
but in special cases other algorithms could be faster.
359 359
For example, if the total supply and/or capacities are rather small,
360 360
CapacityScaling is usually the fastest algorithm (without effective scaling).
361 361
*/
362 362

	
363 363
/**
364 364
@defgroup min_cut Minimum Cut Algorithms
365 365
@ingroup algs
366 366

	
367 367
\brief Algorithms for finding minimum cut in graphs.
368 368

	
369 369
This group contains the algorithms for finding minimum cut in graphs.
370 370

	
371 371
The \e minimum \e cut \e problem is to find a non-empty and non-complete
372 372
\f$X\f$ subset of the nodes with minimum overall capacity on
373 373
outgoing arcs. Formally, there is a \f$G=(V,A)\f$ digraph, a
374 374
\f$cap: A\rightarrow\mathbf{R}^+_0\f$ capacity function. The minimum
375 375
cut is the \f$X\f$ solution of the next optimization problem:
376 376

	
377 377
\f[ \min_{X \subset V, X\not\in \{\emptyset, V\}}
378
    \sum_{uv\in A, u\in X, v\not\in X}cap(uv) \f]
378
    \sum_{uv\in A: u\in X, v\not\in X}cap(uv) \f]
379 379

	
380 380
LEMON contains several algorithms related to minimum cut problems:
381 381

	
382 382
- \ref HaoOrlin "Hao-Orlin algorithm" for calculating minimum cut
383 383
  in directed graphs.
384 384
- \ref NagamochiIbaraki "Nagamochi-Ibaraki algorithm" for
385 385
  calculating minimum cut in undirected graphs.
386 386
- \ref GomoryHu "Gomory-Hu tree computation" for calculating
387 387
  all-pairs minimum cut in undirected graphs.
388 388

	
389 389
If you want to find minimum cut just between two distinict nodes,
390 390
see the \ref max_flow "maximum flow problem".
391 391
*/
392 392

	
393 393
/**
394 394
@defgroup graph_properties Connectivity and Other Graph Properties
395 395
@ingroup algs
396 396
\brief Algorithms for discovering the graph properties
397 397

	
398 398
This group contains the algorithms for discovering the graph properties
399 399
like connectivity, bipartiteness, euler property, simplicity etc.
400 400

	
401
\image html edge_biconnected_components.png
402
\image latex edge_biconnected_components.eps "bi-edge-connected components" width=\textwidth
401
\image html connected_components.png
402
\image latex connected_components.eps "Connected components" width=\textwidth
403 403
*/
404 404

	
405 405
/**
406 406
@defgroup planar Planarity Embedding and Drawing
407 407
@ingroup algs
408 408
\brief Algorithms for planarity checking, embedding and drawing
409 409

	
410 410
This group contains the algorithms for planarity checking,
411 411
embedding and drawing.
412 412

	
413 413
\image html planar.png
414 414
\image latex planar.eps "Plane graph" width=\textwidth
415 415
*/
416 416

	
417 417
/**
418 418
@defgroup matching Matching Algorithms
419 419
@ingroup algs
420 420
\brief Algorithms for finding matchings in graphs and bipartite graphs.
421 421

	
422 422
This group contains the algorithms for calculating
423 423
matchings in graphs and bipartite graphs. The general matching problem is
424 424
finding a subset of the edges for which each node has at most one incident
425 425
edge.
426 426

	
Ignore white space 6 line context
... ...
@@ -392,50 +392,50 @@
392 392
    ///Sets the map that stores the distances of the nodes.
393 393

	
394 394
    ///Sets the map that stores the distances of the nodes calculated by
395 395
    ///the algorithm.
396 396
    ///If you don't use this function before calling \ref run(Node) "run()"
397 397
    ///or \ref init(), an instance will be allocated automatically.
398 398
    ///The destructor deallocates this automatically allocated map,
399 399
    ///of course.
400 400
    ///\return <tt> (*this) </tt>
401 401
    Bfs &distMap(DistMap &m)
402 402
    {
403 403
      if(local_dist) {
404 404
        delete _dist;
405 405
        local_dist=false;
406 406
      }
407 407
      _dist = &m;
408 408
      return *this;
409 409
    }
410 410

	
411 411
  public:
412 412

	
413 413
    ///\name Execution Control
414 414
    ///The simplest way to execute the BFS algorithm is to use one of the
415 415
    ///member functions called \ref run(Node) "run()".\n
416
    ///If you need more control on the execution, first you have to call
417
    ///\ref init(), then you can add several source nodes with
416
    ///If you need better control on the execution, you have to call
417
    ///\ref init() first, then you can add several source nodes with
418 418
    ///\ref addSource(). Finally the actual path computation can be
419 419
    ///performed with one of the \ref start() functions.
420 420

	
421 421
    ///@{
422 422

	
423 423
    ///\brief Initializes the internal data structures.
424 424
    ///
425 425
    ///Initializes the internal data structures.
426 426
    void init()
427 427
    {
428 428
      create_maps();
429 429
      _queue.resize(countNodes(*G));
430 430
      _queue_head=_queue_tail=0;
431 431
      _curr_dist=1;
432 432
      for ( NodeIt u(*G) ; u!=INVALID ; ++u ) {
433 433
        _pred->set(u,INVALID);
434 434
        _reached->set(u,false);
435 435
        _processed->set(u,false);
436 436
      }
437 437
    }
438 438

	
439 439
    ///Adds a new source node.
440 440

	
441 441
    ///Adds a new source node to the set of nodes to be processed.
... ...
@@ -1404,50 +1404,50 @@
1404 1404
    }
1405 1405

	
1406 1406
    /// \brief Sets the map that indicates which nodes are reached.
1407 1407
    ///
1408 1408
    /// Sets the map that indicates which nodes are reached.
1409 1409
    /// If you don't use this function before calling \ref run(Node) "run()"
1410 1410
    /// or \ref init(), an instance will be allocated automatically.
1411 1411
    /// The destructor deallocates this automatically allocated map,
1412 1412
    /// of course.
1413 1413
    /// \return <tt> (*this) </tt>
1414 1414
    BfsVisit &reachedMap(ReachedMap &m) {
1415 1415
      if(local_reached) {
1416 1416
        delete _reached;
1417 1417
        local_reached = false;
1418 1418
      }
1419 1419
      _reached = &m;
1420 1420
      return *this;
1421 1421
    }
1422 1422

	
1423 1423
  public:
1424 1424

	
1425 1425
    /// \name Execution Control
1426 1426
    /// The simplest way to execute the BFS algorithm is to use one of the
1427 1427
    /// member functions called \ref run(Node) "run()".\n
1428
    /// If you need more control on the execution, first you have to call
1429
    /// \ref init(), then you can add several source nodes with
1428
    /// If you need better control on the execution, you have to call
1429
    /// \ref init() first, then you can add several source nodes with
1430 1430
    /// \ref addSource(). Finally the actual path computation can be
1431 1431
    /// performed with one of the \ref start() functions.
1432 1432

	
1433 1433
    /// @{
1434 1434

	
1435 1435
    /// \brief Initializes the internal data structures.
1436 1436
    ///
1437 1437
    /// Initializes the internal data structures.
1438 1438
    void init() {
1439 1439
      create_maps();
1440 1440
      _list.resize(countNodes(*_digraph));
1441 1441
      _list_front = _list_back = -1;
1442 1442
      for (NodeIt u(*_digraph) ; u != INVALID ; ++u) {
1443 1443
        _reached->set(u, false);
1444 1444
      }
1445 1445
    }
1446 1446

	
1447 1447
    /// \brief Adds a new source node.
1448 1448
    ///
1449 1449
    /// Adds a new source node to the set of nodes to be processed.
1450 1450
    void addSource(Node s) {
1451 1451
      if(!(*_reached)[s]) {
1452 1452
          _reached->set(s,true);
1453 1453
          _visitor->start(s);
Ignore white space 6 line context
... ...
@@ -51,66 +51,73 @@
51 51
    typedef LM LowerMap;
52 52

	
53 53
    /// \brief The type of the upper bound (capacity) map.
54 54
    ///
55 55
    /// The type of the map that stores the upper bounds (capacities)
56 56
    /// on the arcs.
57 57
    /// It must conform to the \ref concepts::ReadMap "ReadMap" concept.
58 58
    typedef UM UpperMap;
59 59

	
60 60
    /// \brief The type of supply map.
61 61
    ///
62 62
    /// The type of the map that stores the signed supply values of the 
63 63
    /// nodes. 
64 64
    /// It must conform to the \ref concepts::ReadMap "ReadMap" concept.
65 65
    typedef SM SupplyMap;
66 66

	
67 67
    /// \brief The type of the flow and supply values.
68 68
    typedef typename SupplyMap::Value Value;
69 69

	
70 70
    /// \brief The type of the map that stores the flow values.
71 71
    ///
72 72
    /// The type of the map that stores the flow values.
73 73
    /// It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap"
74 74
    /// concept.
75
#ifdef DOXYGEN
76
    typedef GR::ArcMap<Value> FlowMap;
77
#else
75 78
    typedef typename Digraph::template ArcMap<Value> FlowMap;
79
#endif
76 80

	
77 81
    /// \brief Instantiates a FlowMap.
78 82
    ///
79 83
    /// This function instantiates a \ref FlowMap.
80 84
    /// \param digraph The digraph for which we would like to define
81 85
    /// the flow map.
82 86
    static FlowMap* createFlowMap(const Digraph& digraph) {
83 87
      return new FlowMap(digraph);
84 88
    }
85 89

	
86 90
    /// \brief The elevator type used by the algorithm.
87 91
    ///
88 92
    /// The elevator type used by the algorithm.
89 93
    ///
90
    /// \sa Elevator
91
    /// \sa LinkedElevator
94
    /// \sa Elevator, LinkedElevator
95
#ifdef DOXYGEN
96
    typedef lemon::Elevator<GR, GR::Node> Elevator;
97
#else
92 98
    typedef lemon::Elevator<Digraph, typename Digraph::Node> Elevator;
99
#endif
93 100

	
94 101
    /// \brief Instantiates an Elevator.
95 102
    ///
96 103
    /// This function instantiates an \ref Elevator.
97 104
    /// \param digraph The digraph for which we would like to define
98 105
    /// the elevator.
99 106
    /// \param max_level The maximum level of the elevator.
100 107
    static Elevator* createElevator(const Digraph& digraph, int max_level) {
101 108
      return new Elevator(digraph, max_level);
102 109
    }
103 110

	
104 111
    /// \brief The tolerance used by the algorithm
105 112
    ///
106 113
    /// The tolerance used by the algorithm to handle inexact computation.
107 114
    typedef lemon::Tolerance<Value> Tolerance;
108 115

	
109 116
  };
110 117

	
111 118
  /**
112 119
     \brief Push-relabel algorithm for the network circulation problem.
113 120

	
114 121
     \ingroup max_flow
115 122
     This class implements a push-relabel algorithm for the \e network
116 123
     \e circulation problem.
... ...
@@ -446,50 +453,50 @@
446 453
    ///
447 454
    /// \pre Either \ref run() or \ref init() must be called before
448 455
    /// using this function.
449 456
    const Elevator& elevator() const {
450 457
      return *_level;
451 458
    }
452 459

	
453 460
    /// \brief Sets the tolerance used by algorithm.
454 461
    ///
455 462
    /// Sets the tolerance used by algorithm.
456 463
    Circulation& tolerance(const Tolerance& tolerance) const {
457 464
      _tol = tolerance;
458 465
      return *this;
459 466
    }
460 467

	
461 468
    /// \brief Returns a const reference to the tolerance.
462 469
    ///
463 470
    /// Returns a const reference to the tolerance.
464 471
    const Tolerance& tolerance() const {
465 472
      return tolerance;
466 473
    }
467 474

	
468 475
    /// \name Execution Control
469 476
    /// The simplest way to execute the algorithm is to call \ref run().\n
470
    /// If you need more control on the initial solution or the execution,
471
    /// first you have to call one of the \ref init() functions, then
477
    /// If you need better control on the initial solution or the execution,
478
    /// you have to call one of the \ref init() functions first, then
472 479
    /// the \ref start() function.
473 480

	
474 481
    ///@{
475 482

	
476 483
    /// Initializes the internal data structures.
477 484

	
478 485
    /// Initializes the internal data structures and sets all flow values
479 486
    /// to the lower bound.
480 487
    void init()
481 488
    {
482 489
      LEMON_DEBUG(checkBoundMaps(),
483 490
        "Upper bounds must be greater or equal to the lower bounds");
484 491

	
485 492
      createStructures();
486 493

	
487 494
      for(NodeIt n(_g);n!=INVALID;++n) {
488 495
        (*_excess)[n] = (*_supply)[n];
489 496
      }
490 497

	
491 498
      for (ArcIt e(_g);e!=INVALID;++e) {
492 499
        _flow->set(e, (*_lo)[e]);
493 500
        (*_excess)[_g.target(e)] += (*_flow)[e];
494 501
        (*_excess)[_g.source(e)] -= (*_flow)[e];
495 502
      }
Ignore white space 6 line context
... ...
@@ -390,50 +390,50 @@
390 390
    ///Sets the map that stores the distances of the nodes.
391 391

	
392 392
    ///Sets the map that stores the distances of the nodes calculated by
393 393
    ///the algorithm.
394 394
    ///If you don't use this function before calling \ref run(Node) "run()"
395 395
    ///or \ref init(), an instance will be allocated automatically.
396 396
    ///The destructor deallocates this automatically allocated map,
397 397
    ///of course.
398 398
    ///\return <tt> (*this) </tt>
399 399
    Dfs &distMap(DistMap &m)
400 400
    {
401 401
      if(local_dist) {
402 402
        delete _dist;
403 403
        local_dist=false;
404 404
      }
405 405
      _dist = &m;
406 406
      return *this;
407 407
    }
408 408

	
409 409
  public:
410 410

	
411 411
    ///\name Execution Control
412 412
    ///The simplest way to execute the DFS algorithm is to use one of the
413 413
    ///member functions called \ref run(Node) "run()".\n
414
    ///If you need more control on the execution, first you have to call
415
    ///\ref init(), then you can add a source node with \ref addSource()
414
    ///If you need better control on the execution, you have to call
415
    ///\ref init() first, then you can add a source node with \ref addSource()
416 416
    ///and perform the actual computation with \ref start().
417 417
    ///This procedure can be repeated if there are nodes that have not
418 418
    ///been reached.
419 419

	
420 420
    ///@{
421 421

	
422 422
    ///\brief Initializes the internal data structures.
423 423
    ///
424 424
    ///Initializes the internal data structures.
425 425
    void init()
426 426
    {
427 427
      create_maps();
428 428
      _stack.resize(countNodes(*G));
429 429
      _stack_head=-1;
430 430
      for ( NodeIt u(*G) ; u!=INVALID ; ++u ) {
431 431
        _pred->set(u,INVALID);
432 432
        _reached->set(u,false);
433 433
        _processed->set(u,false);
434 434
      }
435 435
    }
436 436

	
437 437
    ///Adds a new source node.
438 438

	
439 439
    ///Adds a new source node to the set of nodes to be processed.
... ...
@@ -1348,50 +1348,50 @@
1348 1348
    }
1349 1349

	
1350 1350
    /// \brief Sets the map that indicates which nodes are reached.
1351 1351
    ///
1352 1352
    /// Sets the map that indicates which nodes are reached.
1353 1353
    /// If you don't use this function before calling \ref run(Node) "run()"
1354 1354
    /// or \ref init(), an instance will be allocated automatically.
1355 1355
    /// The destructor deallocates this automatically allocated map,
1356 1356
    /// of course.
1357 1357
    /// \return <tt> (*this) </tt>
1358 1358
    DfsVisit &reachedMap(ReachedMap &m) {
1359 1359
      if(local_reached) {
1360 1360
        delete _reached;
1361 1361
        local_reached=false;
1362 1362
      }
1363 1363
      _reached = &m;
1364 1364
      return *this;
1365 1365
    }
1366 1366

	
1367 1367
  public:
1368 1368

	
1369 1369
    /// \name Execution Control
1370 1370
    /// The simplest way to execute the DFS algorithm is to use one of the
1371 1371
    /// member functions called \ref run(Node) "run()".\n
1372
    /// If you need more control on the execution, first you have to call
1373
    /// \ref init(), then you can add a source node with \ref addSource()
1372
    /// If you need better control on the execution, you have to call
1373
    /// \ref init() first, then you can add a source node with \ref addSource()
1374 1374
    /// and perform the actual computation with \ref start().
1375 1375
    /// This procedure can be repeated if there are nodes that have not
1376 1376
    /// been reached.
1377 1377

	
1378 1378
    /// @{
1379 1379

	
1380 1380
    /// \brief Initializes the internal data structures.
1381 1381
    ///
1382 1382
    /// Initializes the internal data structures.
1383 1383
    void init() {
1384 1384
      create_maps();
1385 1385
      _stack.resize(countNodes(*_digraph));
1386 1386
      _stack_head = -1;
1387 1387
      for (NodeIt u(*_digraph) ; u != INVALID ; ++u) {
1388 1388
        _reached->set(u, false);
1389 1389
      }
1390 1390
    }
1391 1391

	
1392 1392
    /// \brief Adds a new source node.
1393 1393
    ///
1394 1394
    /// Adds a new source node to the set of nodes to be processed.
1395 1395
    ///
1396 1396
    /// \pre The stack must be empty. Otherwise the algorithm gives
1397 1397
    /// wrong results. (One of the outgoing arcs of all the source nodes
Ignore white space 6 line context
... ...
@@ -563,50 +563,50 @@
563 563
        local_heap_cross_ref=false;
564 564
      }
565 565
      _heap_cross_ref = &cr;
566 566
      if(local_heap) {
567 567
        delete _heap;
568 568
        local_heap=false;
569 569
      }
570 570
      _heap = &hp;
571 571
      return *this;
572 572
    }
573 573

	
574 574
  private:
575 575

	
576 576
    void finalizeNodeData(Node v,Value dst)
577 577
    {
578 578
      _processed->set(v,true);
579 579
      _dist->set(v, dst);
580 580
    }
581 581

	
582 582
  public:
583 583

	
584 584
    ///\name Execution Control
585 585
    ///The simplest way to execute the %Dijkstra algorithm is to use
586 586
    ///one of the member functions called \ref run(Node) "run()".\n
587
    ///If you need more control on the execution, first you have to call
588
    ///\ref init(), then you can add several source nodes with
587
    ///If you need better control on the execution, you have to call
588
    ///\ref init() first, then you can add several source nodes with
589 589
    ///\ref addSource(). Finally the actual path computation can be
590 590
    ///performed with one of the \ref start() functions.
591 591

	
592 592
    ///@{
593 593

	
594 594
    ///\brief Initializes the internal data structures.
595 595
    ///
596 596
    ///Initializes the internal data structures.
597 597
    void init()
598 598
    {
599 599
      create_maps();
600 600
      _heap->clear();
601 601
      for ( NodeIt u(*G) ; u!=INVALID ; ++u ) {
602 602
        _pred->set(u,INVALID);
603 603
        _processed->set(u,false);
604 604
        _heap_cross_ref->set(u,Heap::PRE_HEAP);
605 605
      }
606 606
    }
607 607

	
608 608
    ///Adds a new source node.
609 609

	
610 610
    ///Adds a new source node to the priority heap.
611 611
    ///The optional second parameter is the initial distance of the node.
612 612
    ///
Ignore white space 6 line context
... ...
@@ -338,52 +338,52 @@
338 338
	  nn = (*_pred)[nn];
339 339
	}
340 340
	while (!st.empty()) {
341 341
	  cutMap.set(st.back(), cutMap[nn]);
342 342
	  st.pop_back();
343 343
	}
344 344
      }
345 345
      
346 346
      return value;
347 347
    }
348 348

	
349 349
    ///@}
350 350

	
351 351
    friend class MinCutNodeIt;
352 352

	
353 353
    /// Iterate on the nodes of a minimum cut
354 354
    
355 355
    /// This iterator class lists the nodes of a minimum cut found by
356 356
    /// GomoryHu. Before using it, you must allocate a GomoryHu class
357 357
    /// and call its \ref GomoryHu::run() "run()" method.
358 358
    ///
359 359
    /// This example counts the nodes in the minimum cut separating \c s from
360 360
    /// \c t.
361 361
    /// \code
362
    /// GomoruHu<Graph> gom(g, capacities);
362
    /// GomoryHu<Graph> gom(g, capacities);
363 363
    /// gom.run();
364 364
    /// int cnt=0;
365
    /// for(GomoruHu<Graph>::MinCutNodeIt n(gom,s,t); n!=INVALID; ++n) ++cnt;
365
    /// for(GomoryHu<Graph>::MinCutNodeIt n(gom,s,t); n!=INVALID; ++n) ++cnt;
366 366
    /// \endcode
367 367
    class MinCutNodeIt
368 368
    {
369 369
      bool _side;
370 370
      typename Graph::NodeIt _node_it;
371 371
      typename Graph::template NodeMap<bool> _cut;
372 372
    public:
373 373
      /// Constructor
374 374

	
375 375
      /// Constructor.
376 376
      ///
377 377
      MinCutNodeIt(GomoryHu const &gomory,
378 378
                   ///< The GomoryHu class. You must call its
379 379
                   ///  run() method
380 380
                   ///  before initializing this iterator.
381 381
                   const Node& s, ///< The base node.
382 382
                   const Node& t,
383 383
                   ///< The node you want to separate from node \c s.
384 384
                   bool side=true
385 385
                   ///< If it is \c true (default) then the iterator lists
386 386
                   ///  the nodes of the component containing \c s,
387 387
                   ///  otherwise it lists the other component.
388 388
                   /// \note As the minimum cut is not always unique,
389 389
                   /// \code
... ...
@@ -435,52 +435,52 @@
435 435
      /// Postfix incrementation.
436 436
      ///
437 437
      /// \warning This incrementation
438 438
      /// returns a \c Node, not a \c MinCutNodeIt, as one may
439 439
      /// expect.
440 440
      typename Graph::Node operator++(int)
441 441
      {
442 442
        typename Graph::Node n=*this;
443 443
        ++(*this);
444 444
        return n;
445 445
      }
446 446
    };
447 447
    
448 448
    friend class MinCutEdgeIt;
449 449
    
450 450
    /// Iterate on the edges of a minimum cut
451 451
    
452 452
    /// This iterator class lists the edges of a minimum cut found by
453 453
    /// GomoryHu. Before using it, you must allocate a GomoryHu class
454 454
    /// and call its \ref GomoryHu::run() "run()" method.
455 455
    ///
456 456
    /// This example computes the value of the minimum cut separating \c s from
457 457
    /// \c t.
458 458
    /// \code
459
    /// GomoruHu<Graph> gom(g, capacities);
459
    /// GomoryHu<Graph> gom(g, capacities);
460 460
    /// gom.run();
461 461
    /// int value=0;
462
    /// for(GomoruHu<Graph>::MinCutEdgeIt e(gom,s,t); e!=INVALID; ++e)
462
    /// for(GomoryHu<Graph>::MinCutEdgeIt e(gom,s,t); e!=INVALID; ++e)
463 463
    ///   value+=capacities[e];
464 464
    /// \endcode
465 465
    /// The result will be the same as the value returned by
466 466
    /// \ref GomoryHu::minCutValue() "gom.minCutValue(s,t)".
467 467
    class MinCutEdgeIt
468 468
    {
469 469
      bool _side;
470 470
      const Graph &_graph;
471 471
      typename Graph::NodeIt _node_it;
472 472
      typename Graph::OutArcIt _arc_it;
473 473
      typename Graph::template NodeMap<bool> _cut;
474 474
      void step()
475 475
      {
476 476
        ++_arc_it;
477 477
        while(_node_it!=INVALID && _arc_it==INVALID)
478 478
          {
479 479
            for(++_node_it;_node_it!=INVALID&&!_cut[_node_it];++_node_it) {}
480 480
            if(_node_it!=INVALID)
481 481
              _arc_it=typename Graph::OutArcIt(_graph,_node_it);
482 482
          }
483 483
      }
484 484
      
485 485
    public:
486 486
      /// Constructor
Ignore white space 48 line context
... ...
@@ -467,50 +467,50 @@
467 467
      if (local_arborescence) {
468 468
        delete _arborescence;
469 469
      }
470 470
      local_arborescence = false;
471 471
      _arborescence = &m;
472 472
      return *this;
473 473
    }
474 474

	
475 475
    /// \brief Sets the predecessor map.
476 476
    ///
477 477
    /// Sets the predecessor map.
478 478
    /// \return <tt>(*this)</tt>
479 479
    MinCostArborescence& predMap(PredMap& m) {
480 480
      if (local_pred) {
481 481
        delete _pred;
482 482
      }
483 483
      local_pred = false;
484 484
      _pred = &m;
485 485
      return *this;
486 486
    }
487 487

	
488 488
    /// \name Execution Control
489 489
    /// The simplest way to execute the algorithm is to use
490 490
    /// one of the member functions called \c run(...). \n
491
    /// If you need more control on the execution,
492
    /// first you must call \ref init(), then you can add several
491
    /// If you need better control on the execution,
492
    /// you have to call \ref init() first, then you can add several
493 493
    /// source nodes with \ref addSource().
494 494
    /// Finally \ref start() will perform the arborescence
495 495
    /// computation.
496 496

	
497 497
    ///@{
498 498

	
499 499
    /// \brief Initializes the internal data structures.
500 500
    ///
501 501
    /// Initializes the internal data structures.
502 502
    ///
503 503
    void init() {
504 504
      createStructures();
505 505
      _heap->clear();
506 506
      for (NodeIt it(*_digraph); it != INVALID; ++it) {
507 507
        (*_cost_arcs)[it].arc = INVALID;
508 508
        (*_node_order)[it] = -3;
509 509
        (*_heap_cross_ref)[it] = Heap::PRE_HEAP;
510 510
        _pred->set(it, INVALID);
511 511
      }
512 512
      for (ArcIt it(*_digraph); it != INVALID; ++it) {
513 513
        _arborescence->set(it, false);
514 514
        (*_arc_order)[it] = -1;
515 515
      }
516 516
      _dual_node_list.clear();
Ignore white space 6 line context
... ...
@@ -31,66 +31,73 @@
31 31
  /// \brief Default traits class of Preflow class.
32 32
  ///
33 33
  /// Default traits class of Preflow class.
34 34
  /// \tparam GR Digraph type.
35 35
  /// \tparam CAP Capacity map type.
36 36
  template <typename GR, typename CAP>
37 37
  struct PreflowDefaultTraits {
38 38

	
39 39
    /// \brief The type of the digraph the algorithm runs on.
40 40
    typedef GR Digraph;
41 41

	
42 42
    /// \brief The type of the map that stores the arc capacities.
43 43
    ///
44 44
    /// The type of the map that stores the arc capacities.
45 45
    /// It must meet the \ref concepts::ReadMap "ReadMap" concept.
46 46
    typedef CAP CapacityMap;
47 47

	
48 48
    /// \brief The type of the flow values.
49 49
    typedef typename CapacityMap::Value Value;
50 50

	
51 51
    /// \brief The type of the map that stores the flow values.
52 52
    ///
53 53
    /// The type of the map that stores the flow values.
54 54
    /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
55
#ifdef DOXYGEN
56
    typedef GR::ArcMap<Value> FlowMap;
57
#else
55 58
    typedef typename Digraph::template ArcMap<Value> FlowMap;
59
#endif
56 60

	
57 61
    /// \brief Instantiates a FlowMap.
58 62
    ///
59 63
    /// This function instantiates a \ref FlowMap.
60 64
    /// \param digraph The digraph for which we would like to define
61 65
    /// the flow map.
62 66
    static FlowMap* createFlowMap(const Digraph& digraph) {
63 67
      return new FlowMap(digraph);
64 68
    }
65 69

	
66 70
    /// \brief The elevator type used by Preflow algorithm.
67 71
    ///
68 72
    /// The elevator type used by Preflow algorithm.
69 73
    ///
70
    /// \sa Elevator
71
    /// \sa LinkedElevator
72
    typedef LinkedElevator<Digraph, typename Digraph::Node> Elevator;
74
    /// \sa Elevator, LinkedElevator
75
#ifdef DOXYGEN
76
    typedef lemon::Elevator<GR, GR::Node> Elevator;
77
#else
78
    typedef lemon::Elevator<Digraph, typename Digraph::Node> Elevator;
79
#endif
73 80

	
74 81
    /// \brief Instantiates an Elevator.
75 82
    ///
76 83
    /// This function instantiates an \ref Elevator.
77 84
    /// \param digraph The digraph for which we would like to define
78 85
    /// the elevator.
79 86
    /// \param max_level The maximum level of the elevator.
80 87
    static Elevator* createElevator(const Digraph& digraph, int max_level) {
81 88
      return new Elevator(digraph, max_level);
82 89
    }
83 90

	
84 91
    /// \brief The tolerance used by the algorithm
85 92
    ///
86 93
    /// The tolerance used by the algorithm to handle inexact computation.
87 94
    typedef lemon::Tolerance<Value> Tolerance;
88 95

	
89 96
  };
90 97

	
91 98

	
92 99
  /// \ingroup max_flow
93 100
  ///
94 101
  /// \brief %Preflow algorithm class.
95 102
  ///
96 103
  /// This class provides an implementation of Goldberg-Tarjan's \e preflow
... ...
@@ -368,50 +375,50 @@
368 375
    /// \pre Either \ref run() or \ref init() must be called before
369 376
    /// using this function.
370 377
    const Elevator& elevator() const {
371 378
      return *_level;
372 379
    }
373 380

	
374 381
    /// \brief Sets the tolerance used by algorithm.
375 382
    ///
376 383
    /// Sets the tolerance used by algorithm.
377 384
    Preflow& tolerance(const Tolerance& tolerance) const {
378 385
      _tolerance = tolerance;
379 386
      return *this;
380 387
    }
381 388

	
382 389
    /// \brief Returns a const reference to the tolerance.
383 390
    ///
384 391
    /// Returns a const reference to the tolerance.
385 392
    const Tolerance& tolerance() const {
386 393
      return tolerance;
387 394
    }
388 395

	
389 396
    /// \name Execution Control
390 397
    /// The simplest way to execute the preflow algorithm is to use
391 398
    /// \ref run() or \ref runMinCut().\n
392
    /// If you need more control on the initial solution or the execution,
393
    /// first you have to call one of the \ref init() functions, then
399
    /// If you need better control on the initial solution or the execution,
400
    /// you have to call one of the \ref init() functions first, then
394 401
    /// \ref startFirstPhase() and if you need it \ref startSecondPhase().
395 402

	
396 403
    ///@{
397 404

	
398 405
    /// \brief Initializes the internal data structures.
399 406
    ///
400 407
    /// Initializes the internal data structures and sets the initial
401 408
    /// flow to zero on each arc.
402 409
    void init() {
403 410
      createStructures();
404 411

	
405 412
      _phase = true;
406 413
      for (NodeIt n(_graph); n != INVALID; ++n) {
407 414
        (*_excess)[n] = 0;
408 415
      }
409 416

	
410 417
      for (ArcIt e(_graph); e != INVALID; ++e) {
411 418
        _flow->set(e, 0);
412 419
      }
413 420

	
414 421
      typename Digraph::template NodeMap<bool> reached(_graph, false);
415 422

	
416 423
      _level->initStart();
417 424
      _level->initAddItem(_target);
0 comments (0 inline)