gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Small doc improvements (#257)
0 3 0
default
3 files changed with 14 insertions and 13 deletions:
↑ Collapse diff ↑
Ignore white space 6 line context
... ...
@@ -290,98 +290,103 @@
290 290
@defgroup shortest_path Shortest Path Algorithms
291 291
@ingroup algs
292 292
\brief Algorithms for finding shortest paths.
293 293

	
294 294
This group contains the algorithms for finding shortest paths in digraphs.
295 295

	
296 296
 - \ref Dijkstra algorithm for finding shortest paths from a source node
297 297
   when all arc lengths are non-negative.
298 298
 - \ref BellmanFord "Bellman-Ford" algorithm for finding shortest paths
299 299
   from a source node when arc lenghts can be either positive or negative,
300 300
   but the digraph should not contain directed cycles with negative total
301 301
   length.
302 302
 - \ref FloydWarshall "Floyd-Warshall" and \ref Johnson "Johnson" algorithms
303 303
   for solving the \e all-pairs \e shortest \e paths \e problem when arc
304 304
   lenghts can be either positive or negative, but the digraph should
305 305
   not contain directed cycles with negative total length.
306 306
 - \ref Suurballe A successive shortest path algorithm for finding
307 307
   arc-disjoint paths between two nodes having minimum total length.
308 308
*/
309 309

	
310 310
/**
311 311
@defgroup max_flow Maximum Flow Algorithms
312 312
@ingroup algs
313 313
\brief Algorithms for finding maximum flows.
314 314

	
315 315
This group contains the algorithms for finding maximum flows and
316 316
feasible circulations.
317 317

	
318 318
The \e maximum \e flow \e problem is to find a flow of maximum value between
319 319
a single source and a single target. Formally, there is a \f$G=(V,A)\f$
320 320
digraph, a \f$cap: A\rightarrow\mathbf{R}^+_0\f$ capacity function and
321 321
\f$s, t \in V\f$ source and target nodes.
322 322
A maximum flow is an \f$f: A\rightarrow\mathbf{R}^+_0\f$ solution of the
323 323
following optimization problem.
324 324

	
325 325
\f[ \max\sum_{sv\in A} f(sv) - \sum_{vs\in A} f(vs) \f]
326 326
\f[ \sum_{uv\in A} f(uv) = \sum_{vu\in A} f(vu)
327 327
    \quad \forall u\in V\setminus\{s,t\} \f]
328 328
\f[ 0 \leq f(uv) \leq cap(uv) \quad \forall uv\in A \f]
329 329

	
330 330
LEMON contains several algorithms for solving maximum flow problems:
331 331
- \ref EdmondsKarp Edmonds-Karp algorithm.
332 332
- \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm.
333 333
- \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees.
334 334
- \ref GoldbergTarjan Preflow push-relabel algorithm with dynamic trees.
335 335

	
336 336
In most cases the \ref Preflow "Preflow" algorithm provides the
337 337
fastest method for computing a maximum flow. All implementations
338
provides functions to also query the minimum cut, which is the dual
339
problem of the maximum flow.
338
also provide functions to query the minimum cut, which is the dual
339
problem of maximum flow.
340

	
341
\ref Circulation is a preflow push-relabel algorithm implemented directly 
342
for finding feasible circulations, which is a somewhat different problem,
343
but it is strongly related to maximum flow.
344
For more information, see \ref Circulation.
340 345
*/
341 346

	
342 347
/**
343 348
@defgroup min_cost_flow Minimum Cost Flow Algorithms
344 349
@ingroup algs
345 350

	
346 351
\brief Algorithms for finding minimum cost flows and circulations.
347 352

	
348 353
This group contains the algorithms for finding minimum cost flows and
349 354
circulations.
350 355

	
351 356
The \e minimum \e cost \e flow \e problem is to find a feasible flow of
352 357
minimum total cost from a set of supply nodes to a set of demand nodes
353 358
in a network with capacity constraints (lower and upper bounds)
354 359
and arc costs.
355 360
Formally, let \f$G=(V,A)\f$ be a digraph, \f$lower: A\rightarrow\mathbf{Z}\f$,
356 361
\f$upper: A\rightarrow\mathbf{Z}\cup\{+\infty\}\f$ denote the lower and
357 362
upper bounds for the flow values on the arcs, for which
358 363
\f$lower(uv) \leq upper(uv)\f$ must hold for all \f$uv\in A\f$,
359 364
\f$cost: A\rightarrow\mathbf{Z}\f$ denotes the cost per unit flow
360 365
on the arcs and \f$sup: V\rightarrow\mathbf{Z}\f$ denotes the
361 366
signed supply values of the nodes.
362 367
If \f$sup(u)>0\f$, then \f$u\f$ is a supply node with \f$sup(u)\f$
363 368
supply, if \f$sup(u)<0\f$, then \f$u\f$ is a demand node with
364 369
\f$-sup(u)\f$ demand.
365 370
A minimum cost flow is an \f$f: A\rightarrow\mathbf{Z}\f$ solution
366 371
of the following optimization problem.
367 372

	
368 373
\f[ \min\sum_{uv\in A} f(uv) \cdot cost(uv) \f]
369 374
\f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \geq
370 375
    sup(u) \quad \forall u\in V \f]
371 376
\f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A \f]
372 377

	
373 378
The sum of the supply values, i.e. \f$\sum_{u\in V} sup(u)\f$ must be
374 379
zero or negative in order to have a feasible solution (since the sum
375 380
of the expressions on the left-hand side of the inequalities is zero).
376 381
It means that the total demand must be greater or equal to the total
377 382
supply and all the supplies have to be carried out from the supply nodes,
378 383
but there could be demands that are not satisfied.
379 384
If \f$\sum_{u\in V} sup(u)\f$ is zero, then all the supply/demand
380 385
constraints have to be satisfied with equality, i.e. all demands
381 386
have to be satisfied and all supplies have to be used.
382 387

	
383 388
If you need the opposite inequalities in the supply/demand constraints
384 389
(i.e. the total demand is less than the total supply and all the demands
385 390
have to be satisfied while there could be supplies that are not used),
386 391
then you could easily transform the problem to the above form by reversing
387 392
the direction of the arcs and taking the negative of the supply values
... ...
@@ -496,100 +501,100 @@
496 501

	
497 502
\image html planar.png
498 503
\image latex planar.eps "Plane graph" width=\textwidth
499 504
*/
500 505

	
501 506
/**
502 507
@defgroup matching Matching Algorithms
503 508
@ingroup algs
504 509
\brief Algorithms for finding matchings in graphs and bipartite graphs.
505 510

	
506 511
This group contains the algorithms for calculating
507 512
matchings in graphs and bipartite graphs. The general matching problem is
508 513
finding a subset of the edges for which each node has at most one incident
509 514
edge.
510 515

	
511 516
There are several different algorithms for calculate matchings in
512 517
graphs.  The matching problems in bipartite graphs are generally
513 518
easier than in general graphs. The goal of the matching optimization
514 519
can be finding maximum cardinality, maximum weight or minimum cost
515 520
matching. The search can be constrained to find perfect or
516 521
maximum cardinality matching.
517 522

	
518 523
The matching algorithms implemented in LEMON:
519 524
- \ref MaxBipartiteMatching Hopcroft-Karp augmenting path algorithm
520 525
  for calculating maximum cardinality matching in bipartite graphs.
521 526
- \ref PrBipartiteMatching Push-relabel algorithm
522 527
  for calculating maximum cardinality matching in bipartite graphs.
523 528
- \ref MaxWeightedBipartiteMatching
524 529
  Successive shortest path algorithm for calculating maximum weighted
525 530
  matching and maximum weighted bipartite matching in bipartite graphs.
526 531
- \ref MinCostMaxBipartiteMatching
527 532
  Successive shortest path algorithm for calculating minimum cost maximum
528 533
  matching in bipartite graphs.
529 534
- \ref MaxMatching Edmond's blossom shrinking algorithm for calculating
530 535
  maximum cardinality matching in general graphs.
531 536
- \ref MaxWeightedMatching Edmond's blossom shrinking algorithm for calculating
532 537
  maximum weighted matching in general graphs.
533 538
- \ref MaxWeightedPerfectMatching
534 539
  Edmond's blossom shrinking algorithm for calculating maximum weighted
535 540
  perfect matching in general graphs.
536 541

	
537 542
\image html bipartite_matching.png
538 543
\image latex bipartite_matching.eps "Bipartite Matching" width=\textwidth
539 544
*/
540 545

	
541 546
/**
542 547
@defgroup spantree Minimum Spanning Tree Algorithms
543 548
@ingroup algs
544
\brief Algorithms for finding a minimum cost spanning tree in a graph.
549
\brief Algorithms for finding minimum cost spanning trees and arborescences.
545 550

	
546
This group contains the algorithms for finding a minimum cost spanning
547
tree in a graph.
551
This group contains the algorithms for finding minimum cost spanning
552
trees and arborescences.
548 553
*/
549 554

	
550 555
/**
551 556
@defgroup auxalg Auxiliary Algorithms
552 557
@ingroup algs
553 558
\brief Auxiliary algorithms implemented in LEMON.
554 559

	
555 560
This group contains some algorithms implemented in LEMON
556 561
in order to make it easier to implement complex algorithms.
557 562
*/
558 563

	
559 564
/**
560 565
@defgroup approx Approximation Algorithms
561 566
@ingroup algs
562 567
\brief Approximation algorithms.
563 568

	
564 569
This group contains the approximation and heuristic algorithms
565 570
implemented in LEMON.
566 571
*/
567 572

	
568 573
/**
569 574
@defgroup gen_opt_group General Optimization Tools
570 575
\brief This group contains some general optimization frameworks
571 576
implemented in LEMON.
572 577

	
573 578
This group contains some general optimization frameworks
574 579
implemented in LEMON.
575 580
*/
576 581

	
577 582
/**
578 583
@defgroup lp_group Lp and Mip Solvers
579 584
@ingroup gen_opt_group
580 585
\brief Lp and Mip solver interfaces for LEMON.
581 586

	
582 587
This group contains Lp and Mip solver interfaces for LEMON. The
583 588
various LP solvers could be used in the same manner with this
584 589
interface.
585 590
*/
586 591

	
587 592
/**
588 593
@defgroup lp_utils Tools for Lp and Mip Solvers
589 594
@ingroup lp_group
590 595
\brief Helper tools to the Lp and Mip solvers.
591 596

	
592 597
This group adds some helper tools to general optimization framework
593 598
implemented in LEMON.
594 599
*/
595 600

	
Ignore white space 96 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
/**
20 20
\mainpage LEMON Documentation
21 21

	
22 22
\section intro Introduction
23 23

	
24 24
\subsection whatis What is LEMON
25 25

	
26 26
LEMON stands for
27 27
<b>L</b>ibrary of <b>E</b>fficient <b>M</b>odels
28 28
and <b>O</b>ptimization in <b>N</b>etworks.
29 29
It is a C++ template
30 30
library aimed at combinatorial optimization tasks which
31 31
often involve in working
32 32
with graphs.
33 33

	
34 34
<b>
35 35
LEMON is an <a class="el" href="http://opensource.org/">open&nbsp;source</a>
36 36
project.
37 37
You are free to use it in your commercial or
38 38
non-commercial applications under very permissive
39 39
\ref license "license terms".
40 40
</b>
41 41

	
42 42
\subsection howtoread How to read the documentation
43 43

	
44
If you want to get a quick start and see the most important features then
45
take a look at our \ref quicktour
46
"Quick Tour to LEMON" which will guide you along.
47

	
48
If you already feel like using our library, see the
44
If you would like to get to know the library, see
49 45
<a class="el" href="http://lemon.cs.elte.hu/pub/tutorial/">LEMON Tutorial</a>.
50 46

	
51
If you know what you are looking for then try to find it under the
47
If you know what you are looking for, then try to find it under the
52 48
<a class="el" href="modules.html">Modules</a> section.
53 49

	
54 50
If you are a user of the old (0.x) series of LEMON, please check out the
55 51
\ref migration "Migration Guide" for the backward incompatibilities.
56 52
*/
Ignore white space 6 line context
... ...
@@ -454,116 +454,116 @@
454 454
            if ((*_matching)[v] == INVALID && v != n) {
455 455
              (*_matching)[n] = a;
456 456
              (*_status)[n] = MATCHED;
457 457
              (*_matching)[v] = _graph.oppositeArc(a);
458 458
              (*_status)[v] = MATCHED;
459 459
              break;
460 460
            }
461 461
          }
462 462
        }
463 463
      }
464 464
    }
465 465

	
466 466

	
467 467
    /// \brief Initialize the matching from a map.
468 468
    ///
469 469
    /// This function initializes the matching from a \c bool valued edge
470 470
    /// map. This map should have the property that there are no two incident
471 471
    /// edges with \c true value, i.e. it really contains a matching.
472 472
    /// \return \c true if the map contains a matching.
473 473
    template <typename MatchingMap>
474 474
    bool matchingInit(const MatchingMap& matching) {
475 475
      createStructures();
476 476

	
477 477
      for (NodeIt n(_graph); n != INVALID; ++n) {
478 478
        (*_matching)[n] = INVALID;
479 479
        (*_status)[n] = UNMATCHED;
480 480
      }
481 481
      for(EdgeIt e(_graph); e!=INVALID; ++e) {
482 482
        if (matching[e]) {
483 483

	
484 484
          Node u = _graph.u(e);
485 485
          if ((*_matching)[u] != INVALID) return false;
486 486
          (*_matching)[u] = _graph.direct(e, true);
487 487
          (*_status)[u] = MATCHED;
488 488

	
489 489
          Node v = _graph.v(e);
490 490
          if ((*_matching)[v] != INVALID) return false;
491 491
          (*_matching)[v] = _graph.direct(e, false);
492 492
          (*_status)[v] = MATCHED;
493 493
        }
494 494
      }
495 495
      return true;
496 496
    }
497 497

	
498 498
    /// \brief Start Edmonds' algorithm
499 499
    ///
500 500
    /// This function runs the original Edmonds' algorithm.
501 501
    ///
502
    /// \pre \ref Init(), \ref greedyInit() or \ref matchingInit() must be
502
    /// \pre \ref init(), \ref greedyInit() or \ref matchingInit() must be
503 503
    /// called before using this function.
504 504
    void startSparse() {
505 505
      for(NodeIt n(_graph); n != INVALID; ++n) {
506 506
        if ((*_status)[n] == UNMATCHED) {
507 507
          (*_blossom_rep)[_blossom_set->insert(n)] = n;
508 508
          _tree_set->insert(n);
509 509
          (*_status)[n] = EVEN;
510 510
          processSparse(n);
511 511
        }
512 512
      }
513 513
    }
514 514

	
515 515
    /// \brief Start Edmonds' algorithm with a heuristic improvement 
516 516
    /// for dense graphs
517 517
    ///
518 518
    /// This function runs Edmonds' algorithm with a heuristic of postponing
519 519
    /// shrinks, therefore resulting in a faster algorithm for dense graphs.
520 520
    ///
521
    /// \pre \ref Init(), \ref greedyInit() or \ref matchingInit() must be
521
    /// \pre \ref init(), \ref greedyInit() or \ref matchingInit() must be
522 522
    /// called before using this function.
523 523
    void startDense() {
524 524
      for(NodeIt n(_graph); n != INVALID; ++n) {
525 525
        if ((*_status)[n] == UNMATCHED) {
526 526
          (*_blossom_rep)[_blossom_set->insert(n)] = n;
527 527
          _tree_set->insert(n);
528 528
          (*_status)[n] = EVEN;
529 529
          processDense(n);
530 530
        }
531 531
      }
532 532
    }
533 533

	
534 534

	
535 535
    /// \brief Run Edmonds' algorithm
536 536
    ///
537 537
    /// This function runs Edmonds' algorithm. An additional heuristic of 
538 538
    /// postponing shrinks is used for relatively dense graphs 
539 539
    /// (for which <tt>m>=2*n</tt> holds).
540 540
    void run() {
541 541
      if (countEdges(_graph) < 2 * countNodes(_graph)) {
542 542
        greedyInit();
543 543
        startSparse();
544 544
      } else {
545 545
        init();
546 546
        startDense();
547 547
      }
548 548
    }
549 549

	
550 550
    /// @}
551 551

	
552 552
    /// \name Primal Solution
553 553
    /// Functions to get the primal solution, i.e. the maximum matching.
554 554

	
555 555
    /// @{
556 556

	
557 557
    /// \brief Return the size (cardinality) of the matching.
558 558
    ///
559 559
    /// This function returns the size (cardinality) of the current matching. 
560 560
    /// After run() it returns the size of the maximum matching in the graph.
561 561
    int matchingSize() const {
562 562
      int size = 0;
563 563
      for (NodeIt n(_graph); n != INVALID; ++n) {
564 564
        if ((*_matching)[n] != INVALID) {
565 565
          ++size;
566 566
        }
567 567
      }
568 568
      return size / 2;
569 569
    }
0 comments (0 inline)