COIN-OR::LEMON - Graph Library

Ignore:
Files:
8 added
46 edited

Legend:

Unmodified
Added
Removed
  • CMakeLists.txt

    r727 r791  
    3535CHECK_TYPE_SIZE("long long" LONG_LONG)
    3636SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
     37
     38INCLUDE(FindPythonInterp)
    3739
    3840ENABLE_TESTING()
  • Makefile.am

    r676 r799  
    1818        cmake/FindGLPK.cmake \
    1919        cmake/FindCOIN.cmake \
     20        cmake/LEMONConfig.cmake.in \
    2021        cmake/version.cmake.in \
    2122        cmake/version.cmake \
  • configure.ac

    r727 r791  
    4242
    4343AC_CHECK_PROG([doxygen_found],[doxygen],[yes],[no])
     44AC_CHECK_PROG([python_found],[python],[yes],[no])
    4445AC_CHECK_PROG([gs_found],[gs],[yes],[no])
    4546
  • doc/CMakeLists.txt

    r726 r791  
    1010)
    1111
    12 IF(DOXYGEN_EXECUTABLE AND GHOSTSCRIPT_EXECUTABLE)
     12IF(DOXYGEN_EXECUTABLE AND PYTHONINTERP_FOUND AND GHOSTSCRIPT_EXECUTABLE)
    1313  FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/)
    1414  SET(GHOSTSCRIPT_OPTIONS -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha)
     
    2929    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/strongly_connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/strongly_connected_components.eps
    3030    COMMAND ${CMAKE_COMMAND} -E remove_directory html
     31    COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/bib2dox.py ${CMAKE_CURRENT_SOURCE_DIR}/references.bib >references.dox
    3132    COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
    3233    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  • doc/Doxyfile.in

    r379 r803  
    1 # Doxyfile 1.5.7.1
     1# Doxyfile 1.5.9
    22
    33#---------------------------------------------------------------------------
     
    2222QT_AUTOBRIEF           = NO
    2323MULTILINE_CPP_IS_BRIEF = NO
    24 DETAILS_AT_TOP         = YES
    2524INHERIT_DOCS           = NO
    2625SEPARATE_MEMBER_PAGES  = NO
     
    9291                         "@abs_top_srcdir@/demo" \
    9392                         "@abs_top_srcdir@/tools" \
    94                          "@abs_top_srcdir@/test/test_tools.h"
     93                         "@abs_top_srcdir@/test/test_tools.h" \
     94                         "@abs_top_builddir@/doc/references.dox"
    9595INPUT_ENCODING         = UTF-8
    9696FILE_PATTERNS          = *.h \
     
    224224SKIP_FUNCTION_MACROS   = YES
    225225#---------------------------------------------------------------------------
    226 # Configuration::additions related to external references   
     226# Options related to the search engine   
    227227#---------------------------------------------------------------------------
    228228TAGFILES               = "@abs_top_srcdir@/doc/libstdc++.tag = http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/  "
  • doc/Makefile.am

    r720 r791  
    6767        fi
    6868
    69 html-local: $(DOC_PNG_IMAGES)
     69references.dox: doc/references.bib
     70        if test ${python_found} = yes; then \
     71          cd doc; \
     72          python @abs_top_srcdir@/scripts/bib2dox.py @abs_top_builddir@/$< >$@; \
     73          cd ..; \
     74        else \
     75          echo; \
     76          echo "Python not found."; \
     77          echo; \
     78          exit 1; \
     79        fi
     80
     81html-local: $(DOC_PNG_IMAGES) references.dox
    7082        if test ${doxygen_found} = yes; then \
    7183          cd doc; \
  • doc/groups.dox

    r762 r818  
    317317
    318318This group contains the common graph search algorithms, namely
    319 \e breadth-first \e search (BFS) and \e depth-first \e search (DFS).
     319\e breadth-first \e search (BFS) and \e depth-first \e search (DFS)
     320\ref clrs01algorithms.
    320321*/
    321322
     
    325326\brief Algorithms for finding shortest paths.
    326327
    327 This group contains the algorithms for finding shortest paths in digraphs.
     328This group contains the algorithms for finding shortest paths in digraphs
     329\ref clrs01algorithms.
    328330
    329331 - \ref Dijkstra algorithm for finding shortest paths from a source node
     
    347349
    348350This group contains the algorithms for finding minimum cost spanning
    349 trees and arborescences.
     351trees and arborescences \ref clrs01algorithms.
    350352*/
    351353
     
    356358
    357359This group contains the algorithms for finding maximum flows and
    358 feasible circulations.
     360feasible circulations \ref clrs01algorithms, \ref amo93networkflows.
    359361
    360362The \e maximum \e flow \e problem is to find a flow of maximum value between
     
    371373
    372374LEMON contains several algorithms for solving maximum flow problems:
    373 - \ref EdmondsKarp Edmonds-Karp algorithm.
    374 - \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm.
    375 - \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees.
    376 - \ref GoldbergTarjan Preflow push-relabel algorithm with dynamic trees.
    377 
    378 In most cases the \ref Preflow "Preflow" algorithm provides the
     375- \ref EdmondsKarp Edmonds-Karp algorithm
     376  \ref edmondskarp72theoretical.
     377- \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm
     378  \ref goldberg88newapproach.
     379- \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees
     380  \ref dinic70algorithm, \ref sleator83dynamic.
     381- \ref GoldbergTarjan !Preflow push-relabel algorithm with dynamic trees
     382  \ref goldberg88newapproach, \ref sleator83dynamic.
     383
     384In most cases the \ref Preflow algorithm provides the
    379385fastest method for computing a maximum flow. All implementations
    380386also provide functions to query the minimum cut, which is the dual
     
    394400
    395401This group contains the algorithms for finding minimum cost flows and
    396 circulations. For more information about this problem and its dual
    397 solution see \ref min_cost_flow "Minimum Cost Flow Problem".
     402circulations \ref amo93networkflows. For more information about this
     403problem and its dual solution, see \ref min_cost_flow
     404"Minimum Cost Flow Problem".
    398405
    399406LEMON contains several algorithms for this problem.
    400407 - \ref NetworkSimplex Primal Network Simplex algorithm with various
    401    pivot strategies.
     408   pivot strategies \ref dantzig63linearprog, \ref kellyoneill91netsimplex.
    402409 - \ref CostScaling Push-Relabel and Augment-Relabel algorithms based on
    403    cost scaling.
     410   cost scaling \ref goldberg90approximation, \ref goldberg97efficient,
     411   \ref bunnagel98efficient.
    404412 - \ref CapacityScaling Successive Shortest %Path algorithm with optional
    405    capacity scaling.
    406  - \ref CancelAndTighten The Cancel and Tighten algorithm.
    407  - \ref CycleCanceling Cycle-Canceling algorithms.
     413   capacity scaling \ref edmondskarp72theoretical.
     414 - \ref CancelAndTighten The Cancel and Tighten algorithm
     415   \ref goldberg89cyclecanceling.
     416 - \ref CycleCanceling Cycle-Canceling algorithms
     417   \ref klein67primal, \ref goldberg89cyclecanceling.
    408418
    409419In general NetworkSimplex is the most efficient implementation,
     
    441451If you want to find minimum cut just between two distinict nodes,
    442452see the \ref max_flow "maximum flow problem".
     453*/
     454
     455/**
     456@defgroup min_mean_cycle Minimum Mean Cycle Algorithms
     457@ingroup algs
     458\brief Algorithms for finding minimum mean cycles.
     459
     460This group contains the algorithms for finding minimum mean cycles
     461\ref clrs01algorithms, \ref amo93networkflows.
     462
     463The \e minimum \e mean \e cycle \e problem is to find a directed cycle
     464of minimum mean length (cost) in a digraph.
     465The mean length of a cycle is the average length of its arcs, i.e. the
     466ratio between the total length of the cycle and the number of arcs on it.
     467
     468This problem has an important connection to \e conservative \e length
     469\e functions, too. A length function on the arcs of a digraph is called
     470conservative if and only if there is no directed cycle of negative total
     471length. For an arbitrary length function, the negative of the minimum
     472cycle mean is the smallest \f$\epsilon\f$ value so that increasing the
     473arc lengths uniformly by \f$\epsilon\f$ results in a conservative length
     474function.
     475
     476LEMON contains three algorithms for solving the minimum mean cycle problem:
     477- \ref Karp "Karp"'s original algorithm \ref amo93networkflows,
     478  \ref dasdan98minmeancycle.
     479- \ref HartmannOrlin "Hartmann-Orlin"'s algorithm, which is an improved
     480  version of Karp's algorithm \ref dasdan98minmeancycle.
     481- \ref Howard "Howard"'s policy iteration algorithm
     482  \ref dasdan98minmeancycle.
     483
     484In practice, the Howard algorithm proved to be by far the most efficient
     485one, though the best known theoretical bound on its running time is
     486exponential.
     487Both Karp and HartmannOrlin algorithms run in time O(ne) and use space
     488O(n<sup>2</sup>+e), but the latter one is typically faster due to the
     489applied early termination scheme.
    443490*/
    444491
     
    535582
    536583/**
    537 @defgroup lp_group Lp and Mip Solvers
     584@defgroup lp_group LP and MIP Solvers
    538585@ingroup gen_opt_group
    539 \brief Lp and Mip solver interfaces for LEMON.
    540 
    541 This group contains Lp and Mip solver interfaces for LEMON. The
    542 various LP solvers could be used in the same manner with this
    543 interface.
     586\brief LP and MIP solver interfaces for LEMON.
     587
     588This group contains LP and MIP solver interfaces for LEMON.
     589Various LP solvers could be used in the same manner with this
     590high-level interface.
     591
     592The currently supported solvers are \ref glpk, \ref clp, \ref cbc,
     593\ref cplex, \ref soplex.
    544594*/
    545595
     
    680730\brief Skeleton and concept checking classes for graph structures
    681731
    682 This group contains the skeletons and concept checking classes of LEMON's
    683 graph structures and helper classes used to implement these.
     732This group contains the skeletons and concept checking classes of
     733graph structures.
    684734*/
    685735
  • doc/mainpage.dox

    r705 r802  
    2222\section intro Introduction
    2323
    24 \subsection whatis What is LEMON
    25 
    26 LEMON stands for <b>L</b>ibrary for <b>E</b>fficient <b>M</b>odeling
    27 and <b>O</b>ptimization in <b>N</b>etworks.
    28 It is a C++ template
    29 library aimed at combinatorial optimization tasks which
    30 often involve in working
    31 with graphs.
     24<b>LEMON</b> stands for <i><b>L</b>ibrary for <b>E</b>fficient <b>M</b>odeling
     25and <b>O</b>ptimization in <b>N</b>etworks</i>.
     26It is a C++ template library providing efficient implementation of common
     27data structures and algorithms with focus on combinatorial optimization
     28problems in graphs and networks.
    3229
    3330<b>
     
    3936</b>
    4037
    41 \subsection howtoread How to read the documentation
     38The project is maintained by the
     39<a href="http://www.cs.elte.hu/egres/">Egerv&aacute;ry Research Group on
     40Combinatorial Optimization</a> \ref egres
     41at the Operations Research Department of the
     42<a href="http://www.elte.hu/">E&ouml;tv&ouml;s Lor&aacute;nd University,
     43Budapest</a>, Hungary.
     44LEMON is also a member of the <a href="http://www.coin-or.org/">COIN-OR</a>
     45initiative \ref coinor.
     46
     47\section howtoread How to Read the Documentation
    4248
    4349If you would like to get to know the library, see
  • doc/min_cost_flow.dox

    r710 r802  
    2727minimum total cost from a set of supply nodes to a set of demand nodes
    2828in a network with capacity constraints (lower and upper bounds)
    29 and arc costs.
     29and arc costs \ref amo93networkflows.
    3030
    3131Formally, let \f$G=(V,A)\f$ be a digraph, \f$lower: A\rightarrow\mathbf{R}\f$,
  • lemon/Makefile.am

    r755 r827  
    8787        lemon/graph_to_eps.h \
    8888        lemon/grid_graph.h \
     89        lemon/hartmann_orlin.h \
     90        lemon/howard.h \
    8991        lemon/hypercube_graph.h \
     92        lemon/karp.h \
    9093        lemon/kary_heap.h \
    9194        lemon/kruskal.h \
     
    111114        lemon/smart_graph.h \
    112115        lemon/soplex.h \
     116        lemon/static_graph.h \
    113117        lemon/suurballe.h \
    114118        lemon/time_measure.h \
  • lemon/bits/graph_extender.h

    r732 r825  
    5757    }
    5858
    59     Node fromId(int id, Node) const {
     59    static Node fromId(int id, Node) {
    6060      return Parent::nodeFromId(id);
    6161    }
    6262
    63     Arc fromId(int id, Arc) const {
     63    static Arc fromId(int id, Arc) {
    6464      return Parent::arcFromId(id);
    6565    }
     
    356356    }
    357357
    358     Node fromId(int id, Node) const {
     358    static Node fromId(int id, Node) {
    359359      return Parent::nodeFromId(id);
    360360    }
    361361
    362     Arc fromId(int id, Arc) const {
     362    static Arc fromId(int id, Arc) {
    363363      return Parent::arcFromId(id);
    364364    }
    365365
    366     Edge fromId(int id, Edge) const {
     366    static Edge fromId(int id, Edge) {
    367367      return Parent::edgeFromId(id);
    368368    }
  • lemon/cbc.cc

    r623 r793  
    9595  }
    9696
     97  int CbcMip::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) {
     98    std::vector<int> indexes;
     99    std::vector<Value> values;
     100
     101    for(ExprIterator it = b; it != e; ++it) {
     102      indexes.push_back(it->first);
     103      values.push_back(it->second);
     104    }
     105
     106    _prob->addRow(values.size(), &indexes.front(), &values.front(), l, u);
     107    return _prob->numberRows() - 1;
     108  }
    97109
    98110  void CbcMip::_eraseCol(int i) {
  • lemon/cbc.h

    r623 r793  
    6363    virtual int _addCol();
    6464    virtual int _addRow();
     65    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
    6566
    6667    virtual void _eraseCol(int i);
  • lemon/clp.cc

    r623 r793  
    7979  }
    8080
     81  int ClpLp::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) {
     82    std::vector<int> indexes;
     83    std::vector<Value> values;
     84
     85    for(ExprIterator it = b; it != e; ++it) {
     86      indexes.push_back(it->first);
     87      values.push_back(it->second);
     88    }
     89
     90    _prob->addRow(values.size(), &indexes.front(), &values.front(), l, u);
     91    return _prob->numberRows() - 1;
     92  }
     93
    8194
    8295  void ClpLp::_eraseCol(int c) {
  • lemon/clp.h

    r623 r793  
    7676    virtual int _addCol();
    7777    virtual int _addRow();
     78    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
    7879
    7980    virtual void _eraseCol(int i);
  • lemon/concepts/digraph.h

    r627 r781  
    3636    /// \brief Class describing the concept of directed graphs.
    3737    ///
    38     /// This class describes the \ref concept "concept" of the
    39     /// immutable directed digraphs.
     38    /// This class describes the common interface of all directed
     39    /// graphs (digraphs).
    4040    ///
    41     /// Note that actual digraph implementation like @ref ListDigraph or
    42     /// @ref SmartDigraph may have several additional functionality.
     41    /// Like all concept classes, it only provides an interface
     42    /// without any sensible implementation. So any general algorithm for
     43    /// directed graphs should compile with this class, but it will not
     44    /// run properly, of course.
     45    /// An actual digraph implementation like \ref ListDigraph or
     46    /// \ref SmartDigraph may have additional functionality.
    4347    ///
    44     /// \sa concept
     48    /// \sa Graph
    4549    class Digraph {
    4650    private:
    47       ///Digraphs are \e not copy constructible. Use DigraphCopy() instead.
    48 
    49       ///Digraphs are \e not copy constructible. Use DigraphCopy() instead.
    50       ///
    51       Digraph(const Digraph &) {};
    52       ///\brief Assignment of \ref Digraph "Digraph"s to another ones are
    53       ///\e not allowed. Use DigraphCopy() instead.
    54 
    55       ///Assignment of \ref Digraph "Digraph"s to another ones are
    56       ///\e not allowed.  Use DigraphCopy() instead.
    57 
     51      /// Diraphs are \e not copy constructible. Use DigraphCopy instead.
     52      Digraph(const Digraph &) {}
     53      /// \brief Assignment of a digraph to another one is \e not allowed.
     54      /// Use DigraphCopy instead.
    5855      void operator=(const Digraph &) {}
     56
    5957    public:
    60       ///\e
    61 
    62       /// Defalult constructor.
    63 
    64       /// Defalult constructor.
    65       ///
     58      /// Default constructor.
    6659      Digraph() { }
    67       /// Class for identifying a node of the digraph
     60
     61      /// The node type of the digraph
    6862
    6963      /// This class identifies a node of the digraph. It also serves
    7064      /// as a base class of the node iterators,
    71       /// thus they will convert to this type.
     65      /// thus they convert to this type.
    7266      class Node {
    7367      public:
    7468        /// Default constructor
    7569
    76         /// @warning The default constructor sets the iterator
    77         /// to an undefined value.
     70        /// Default constructor.
     71        /// \warning It sets the object to an undefined value.
    7872        Node() { }
    7973        /// Copy constructor.
     
    8377        Node(const Node&) { }
    8478
    85         /// Invalid constructor \& conversion.
    86 
    87         /// This constructor initializes the iterator to be invalid.
     79        /// %Invalid constructor \& conversion.
     80
     81        /// Initializes the object to be invalid.
    8882        /// \sa Invalid for more details.
    8983        Node(Invalid) { }
    9084        /// Equality operator
    9185
     86        /// Equality operator.
     87        ///
    9288        /// Two iterators are equal if and only if they point to the
    93         /// same object or both are invalid.
     89        /// same object or both are \c INVALID.
    9490        bool operator==(Node) const { return true; }
    9591
    9692        /// Inequality operator
    9793
    98         /// \sa operator==(Node n)
    99         ///
     94        /// Inequality operator.
    10095        bool operator!=(Node) const { return true; }
    10196
    10297        /// Artificial ordering operator.
    10398
    104         /// To allow the use of digraph 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.
     99        /// Artificial ordering operator.
     100        ///
     101        /// \note This operator only has to define some strict ordering of
     102        /// the nodes; this order has nothing to do with the iteration
     103        /// ordering of the nodes.
    110104        bool operator<(Node) const { return false; }
    111 
    112       };
    113 
    114       /// This iterator goes through each node.
    115 
    116       /// This iterator goes through each node.
     105      };
     106
     107      /// Iterator class for the nodes.
     108
     109      /// This iterator goes through each node of the digraph.
    117110      /// Its usage is quite simple, for example you can count the number
    118       /// of nodes in digraph \c g of type \c Digraph like this:
     111      /// of nodes in a digraph \c g of type \c %Digraph like this:
    119112      ///\code
    120113      /// int count=0;
     
    125118        /// Default constructor
    126119
    127         /// @warning The default constructor sets the iterator
    128         /// to an undefined value.
     120        /// Default constructor.
     121        /// \warning It sets the iterator to an undefined value.
    129122        NodeIt() { }
    130123        /// Copy constructor.
     
    133126        ///
    134127        NodeIt(const NodeIt& n) : Node(n) { }
    135         /// Invalid constructor \& conversion.
    136 
    137         /// Initialize the iterator to be invalid.
     128        /// %Invalid constructor \& conversion.
     129
     130        /// Initializes the iterator to be invalid.
    138131        /// \sa Invalid for more details.
    139132        NodeIt(Invalid) { }
    140133        /// Sets the iterator to the first node.
    141134
    142         /// Sets the iterator to the first node of \c g.
    143         ///
    144         NodeIt(const Digraph&) { }
    145         /// Node -> NodeIt conversion.
    146 
    147         /// Sets the iterator to the node of \c the digraph pointed by
    148         /// the trivial iterator.
    149         /// This feature necessitates that each time we
    150         /// iterate the arc-set, the iteration order is the same.
     135        /// Sets the iterator to the first node of the given digraph.
     136        ///
     137        explicit NodeIt(const Digraph&) { }
     138        /// Sets the iterator to the given node.
     139
     140        /// Sets the iterator to the given node of the given digraph.
     141        ///
    151142        NodeIt(const Digraph&, const Node&) { }
    152143        /// Next node.
     
    158149
    159150
    160       /// Class for identifying an arc of the digraph
     151      /// The arc type of the digraph
    161152
    162153      /// This class identifies an arc of the digraph. It also serves
     
    167158        /// Default constructor
    168159
    169         /// @warning The default constructor sets the iterator
    170         /// to an undefined value.
     160        /// Default constructor.
     161        /// \warning It sets the object to an undefined value.
    171162        Arc() { }
    172163        /// Copy constructor.
     
    175166        ///
    176167        Arc(const Arc&) { }
    177         /// Initialize the iterator to be invalid.
    178 
    179         /// Initialize the iterator to be invalid.
    180         ///
     168        /// %Invalid constructor \& conversion.
     169
     170        /// Initializes the object to be invalid.
     171        /// \sa Invalid for more details.
    181172        Arc(Invalid) { }
    182173        /// Equality operator
    183174
     175        /// Equality operator.
     176        ///
    184177        /// Two iterators are equal if and only if they point to the
    185         /// same object or both are invalid.
     178        /// same object or both are \c INVALID.
    186179        bool operator==(Arc) const { return true; }
    187180        /// Inequality operator
    188181
    189         /// \sa operator==(Arc n)
    190         ///
     182        /// Inequality operator.
    191183        bool operator!=(Arc) const { return true; }
    192184
    193185        /// Artificial ordering operator.
    194186
    195         /// To allow the use of digraph descriptors as key type in std::map or
    196         /// similar associative container we require this.
    197         ///
    198         /// \note This operator only have to define some strict ordering of
    199         /// the items; this order has nothing to do with the iteration
    200         /// ordering of the items.
     187        /// Artificial ordering operator.
     188        ///
     189        /// \note This operator only has to define some strict ordering of
     190        /// the arcs; this order has nothing to do with the iteration
     191        /// ordering of the arcs.
    201192        bool operator<(Arc) const { return false; }
    202193      };
    203194
    204       /// This iterator goes trough the outgoing arcs of a node.
     195      /// Iterator class for the outgoing arcs of a node.
    205196
    206197      /// This iterator goes trough the \e outgoing arcs of a certain node
     
    208199      /// Its usage is quite simple, for example you can count the number
    209200      /// of outgoing arcs of a node \c n
    210       /// in digraph \c g of type \c Digraph as follows.
     201      /// in a digraph \c g of type \c %Digraph as follows.
    211202      ///\code
    212203      /// int count=0;
    213       /// for (Digraph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
     204      /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
    214205      ///\endcode
    215 
    216206      class OutArcIt : public Arc {
    217207      public:
    218208        /// Default constructor
    219209
    220         /// @warning The default constructor sets the iterator
    221         /// to an undefined value.
     210        /// Default constructor.
     211        /// \warning It sets the iterator to an undefined value.
    222212        OutArcIt() { }
    223213        /// Copy constructor.
     
    226216        ///
    227217        OutArcIt(const OutArcIt& e) : Arc(e) { }
    228         /// Initialize the iterator to be invalid.
    229 
    230         /// Initialize the iterator to be invalid.
    231         ///
     218        /// %Invalid constructor \& conversion.
     219
     220        /// Initializes the iterator to be invalid.
     221        /// \sa Invalid for more details.
    232222        OutArcIt(Invalid) { }
    233         /// This constructor sets the iterator to the first outgoing arc.
    234 
    235         /// This constructor sets the iterator to the first outgoing arc of
    236         /// the node.
     223        /// Sets the iterator to the first outgoing arc.
     224
     225        /// Sets the iterator to the first outgoing arc of the given node.
     226        ///
    237227        OutArcIt(const Digraph&, const Node&) { }
    238         /// Arc -> OutArcIt conversion
    239 
    240         /// Sets the iterator to the value of the trivial iterator.
    241         /// This feature necessitates that each time we
    242         /// iterate the arc-set, the iteration order is the same.
     228        /// Sets the iterator to the given arc.
     229
     230        /// Sets the iterator to the given arc of the given digraph.
     231        ///
    243232        OutArcIt(const Digraph&, const Arc&) { }
    244         ///Next outgoing arc
     233        /// Next outgoing arc
    245234
    246235        /// Assign the iterator to the next
     
    249238      };
    250239
    251       /// This iterator goes trough the incoming arcs of a node.
     240      /// Iterator class for the incoming arcs of a node.
    252241
    253242      /// This iterator goes trough the \e incoming arcs of a certain node
    254243      /// of a digraph.
    255244      /// Its usage is quite simple, for example you can count the number
    256       /// of outgoing arcs of a node \c n
    257       /// in digraph \c g of type \c Digraph as follows.
     245      /// of incoming arcs of a node \c n
     246      /// in a digraph \c g of type \c %Digraph as follows.
    258247      ///\code
    259248      /// int count=0;
    260       /// for(Digraph::InArcIt e(g, n); e!=INVALID; ++e) ++count;
     249      /// for(Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
    261250      ///\endcode
    262 
    263251      class InArcIt : public Arc {
    264252      public:
    265253        /// Default constructor
    266254
    267         /// @warning The default constructor sets the iterator
    268         /// to an undefined value.
     255        /// Default constructor.
     256        /// \warning It sets the iterator to an undefined value.
    269257        InArcIt() { }
    270258        /// Copy constructor.
     
    273261        ///
    274262        InArcIt(const InArcIt& e) : Arc(e) { }
    275         /// Initialize the iterator to be invalid.
    276 
    277         /// Initialize the iterator to be invalid.
    278         ///
     263        /// %Invalid constructor \& conversion.
     264
     265        /// Initializes the iterator to be invalid.
     266        /// \sa Invalid for more details.
    279267        InArcIt(Invalid) { }
    280         /// This constructor sets the iterator to first incoming arc.
    281 
    282         /// This constructor set the iterator to the first incoming arc of
    283         /// the node.
     268        /// Sets the iterator to the first incoming arc.
     269
     270        /// Sets the iterator to the first incoming arc of the given node.
     271        ///
    284272        InArcIt(const Digraph&, const Node&) { }
    285         /// Arc -> InArcIt conversion
    286 
    287         /// Sets the iterator to the value of the trivial iterator \c e.
    288         /// This feature necessitates that each time we
    289         /// iterate the arc-set, the iteration order is the same.
     273        /// Sets the iterator to the given arc.
     274
     275        /// Sets the iterator to the given arc of the given digraph.
     276        ///
    290277        InArcIt(const Digraph&, const Arc&) { }
    291278        /// Next incoming arc
    292279
    293         /// Assign the iterator to the next inarc of the corresponding node.
    294         ///
     280        /// Assign the iterator to the next
     281        /// incoming arc of the corresponding node.
    295282        InArcIt& operator++() { return *this; }
    296283      };
    297       /// This iterator goes through each arc.
    298 
    299       /// This iterator goes through each arc of a digraph.
     284
     285      /// Iterator class for the arcs.
     286
     287      /// This iterator goes through each arc of the digraph.
    300288      /// Its usage is quite simple, for example you can count the number
    301       /// of arcs in a digraph \c g of type \c Digraph as follows:
     289      /// of arcs in a digraph \c g of type \c %Digraph as follows:
    302290      ///\code
    303291      /// int count=0;
    304       /// for(Digraph::ArcIt e(g); e!=INVALID; ++e) ++count;
     292      /// for(Digraph::ArcIt a(g); a!=INVALID; ++a) ++count;
    305293      ///\endcode
    306294      class ArcIt : public Arc {
     
    308296        /// Default constructor
    309297
    310         /// @warning The default constructor sets the iterator
    311         /// to an undefined value.
     298        /// Default constructor.
     299        /// \warning It sets the iterator to an undefined value.
    312300        ArcIt() { }
    313301        /// Copy constructor.
     
    316304        ///
    317305        ArcIt(const ArcIt& e) : Arc(e) { }
    318         /// Initialize the iterator to be invalid.
    319 
    320         /// Initialize the iterator to be invalid.
    321         ///
     306        /// %Invalid constructor \& conversion.
     307
     308        /// Initializes the iterator to be invalid.
     309        /// \sa Invalid for more details.
    322310        ArcIt(Invalid) { }
    323         /// This constructor sets the iterator to the first arc.
    324 
    325         /// This constructor sets the iterator to the first arc of \c g.
    326         ///@param g the digraph
    327         ArcIt(const Digraph& g) { ignore_unused_variable_warning(g); }
    328         /// Arc -> ArcIt conversion
    329 
    330         /// Sets the iterator to the value of the trivial iterator \c e.
    331         /// This feature necessitates that each time we
    332         /// iterate the arc-set, the iteration order is the same.
     311        /// Sets the iterator to the first arc.
     312
     313        /// Sets the iterator to the first arc of the given digraph.
     314        ///
     315        explicit ArcIt(const Digraph& g) { ignore_unused_variable_warning(g); }
     316        /// Sets the iterator to the given arc.
     317
     318        /// Sets the iterator to the given arc of the given digraph.
     319        ///
    333320        ArcIt(const Digraph&, const Arc&) { }
    334         ///Next arc
     321        /// Next arc
    335322
    336323        /// Assign the iterator to the next arc.
     324        ///
    337325        ArcIt& operator++() { return *this; }
    338326      };
    339       ///Gives back the target node of an arc.
    340 
    341       ///Gives back the target node of an arc.
    342       ///
     327
     328      /// \brief The source node of the arc.
     329      ///
     330      /// Returns the source node of the given arc.
     331      Node source(Arc) const { return INVALID; }
     332
     333      /// \brief The target node of the arc.
     334      ///
     335      /// Returns the target node of the given arc.
    343336      Node target(Arc) const { return INVALID; }
    344       ///Gives back the source node of an arc.
    345 
    346       ///Gives back the source node of an arc.
    347       ///
    348       Node source(Arc) const { return INVALID; }
    349 
    350       /// \brief Returns the ID of the node.
     337
     338      /// \brief The ID of the node.
     339      ///
     340      /// Returns the ID of the given node.
    351341      int id(Node) const { return -1; }
    352342
    353       /// \brief Returns the ID of the arc.
     343      /// \brief The ID of the arc.
     344      ///
     345      /// Returns the ID of the given arc.
    354346      int id(Arc) const { return -1; }
    355347
    356       /// \brief Returns the node with the given ID.
    357       ///
    358       /// \pre The argument should be a valid node ID in the graph.
     348      /// \brief The node with the given ID.
     349      ///
     350      /// Returns the node with the given ID.
     351      /// \pre The argument should be a valid node ID in the digraph.
    359352      Node nodeFromId(int) const { return INVALID; }
    360353
    361       /// \brief Returns the arc with the given ID.
    362       ///
    363       /// \pre The argument should be a valid arc ID in the graph.
     354      /// \brief The arc with the given ID.
     355      ///
     356      /// Returns the arc with the given ID.
     357      /// \pre The argument should be a valid arc ID in the digraph.
    364358      Arc arcFromId(int) const { return INVALID; }
    365359
    366       /// \brief Returns an upper bound on the node IDs.
     360      /// \brief An upper bound on the node IDs.
     361      ///
     362      /// Returns an upper bound on the node IDs.
    367363      int maxNodeId() const { return -1; }
    368364
    369       /// \brief Returns an upper bound on the arc IDs.
     365      /// \brief An upper bound on the arc IDs.
     366      ///
     367      /// Returns an upper bound on the arc IDs.
    370368      int maxArcId() const { return -1; }
    371369
     
    393391      int maxId(Arc) const { return -1; }
    394392
     393      /// \brief The opposite node on the arc.
     394      ///
     395      /// Returns the opposite node on the given arc.
     396      Node oppositeNode(Node, Arc) const { return INVALID; }
     397
    395398      /// \brief The base node of the iterator.
    396399      ///
    397       /// Gives back the base node of the iterator.
    398       /// It is always the target of the pointed arc.
    399       Node baseNode(const InArcIt&) const { return INVALID; }
     400      /// Returns the base node of the given outgoing arc iterator
     401      /// (i.e. the source node of the corresponding arc).
     402      Node baseNode(OutArcIt) const { return INVALID; }
    400403
    401404      /// \brief The running node of the iterator.
    402405      ///
    403       /// Gives back the running node of the iterator.
    404       /// It is always the source of the pointed arc.
    405       Node runningNode(const InArcIt&) const { return INVALID; }
     406      /// Returns the running node of the given outgoing arc iterator
     407      /// (i.e. the target node of the corresponding arc).
     408      Node runningNode(OutArcIt) const { return INVALID; }
    406409
    407410      /// \brief The base node of the iterator.
    408411      ///
    409       /// Gives back the base node of the iterator.
    410       /// It is always the source of the pointed arc.
    411       Node baseNode(const OutArcIt&) const { return INVALID; }
     412      /// Returns the base node of the given incomming arc iterator
     413      /// (i.e. the target node of the corresponding arc).
     414      Node baseNode(InArcIt) const { return INVALID; }
    412415
    413416      /// \brief The running node of the iterator.
    414417      ///
    415       /// Gives back the running node of the iterator.
    416       /// It is always the target of the pointed arc.
    417       Node runningNode(const OutArcIt&) const { return INVALID; }
    418 
    419       /// \brief The opposite node on the given arc.
    420       ///
    421       /// Gives back the opposite node on the given arc.
    422       Node oppositeNode(const Node&, const Arc&) const { return INVALID; }
    423 
    424       /// \brief Reference map of the nodes to type \c T.
    425       ///
    426       /// Reference map of the nodes to type \c T.
     418      /// Returns the running node of the given incomming arc iterator
     419      /// (i.e. the source node of the corresponding arc).
     420      Node runningNode(InArcIt) const { return INVALID; }
     421
     422      /// \brief Standard graph map type for the nodes.
     423      ///
     424      /// Standard graph map type for the nodes.
     425      /// It conforms to the ReferenceMap concept.
    427426      template<class T>
    428427      class NodeMap : public ReferenceMap<Node, T, T&, const T&> {
    429428      public:
    430429
    431         ///\e
    432         NodeMap(const Digraph&) { }
    433         ///\e
     430        /// Constructor
     431        explicit NodeMap(const Digraph&) { }
     432        /// Constructor with given initial value
    434433        NodeMap(const Digraph&, T) { }
    435434
     
    446445      };
    447446
    448       /// \brief Reference map of the arcs to type \c T.
    449       ///
    450       /// Reference map of the arcs to type \c T.
     447      /// \brief Standard graph map type for the arcs.
     448      ///
     449      /// Standard graph map type for the arcs.
     450      /// It conforms to the ReferenceMap concept.
    451451      template<class T>
    452452      class ArcMap : public ReferenceMap<Arc, T, T&, const T&> {
    453453      public:
    454454
    455         ///\e
    456         ArcMap(const Digraph&) { }
    457         ///\e
     455        /// Constructor
     456        explicit ArcMap(const Digraph&) { }
     457        /// Constructor with given initial value
    458458        ArcMap(const Digraph&, T) { }
     459
    459460      private:
    460461        ///Copy constructor
  • lemon/concepts/graph.h

    r704 r781  
    1919///\ingroup graph_concepts
    2020///\file
    21 ///\brief The concept of Undirected Graphs.
     21///\brief The concept of undirected graphs.
    2222
    2323#ifndef LEMON_CONCEPTS_GRAPH_H
     
    2525
    2626#include <lemon/concepts/graph_components.h>
     27#include <lemon/concepts/maps.h>
     28#include <lemon/concept_check.h>
    2729#include <lemon/core.h>
    2830
     
    3234    /// \ingroup graph_concepts
    3335    ///
    34     /// \brief Class describing the concept of Undirected Graphs.
     36    /// \brief Class describing the concept of undirected graphs.
    3537    ///
    36     /// This class describes the common interface of all Undirected
    37     /// Graphs.
     38    /// This class describes the common interface of all undirected
     39    /// graphs.
    3840    ///
    39     /// As all concept describing classes it provides only interface
    40     /// without any sensible implementation. So any algorithm for
    41     /// undirected graph should compile with this class, but it will not
     41    /// Like all concept classes, it only provides an interface
     42    /// without any sensible implementation. So any general algorithm for
     43    /// undirected graphs should compile with this class, but it will not
    4244    /// run properly, of course.
     45    /// An actual graph implementation like \ref ListGraph or
     46    /// \ref SmartGraph may have additional functionality.   
    4347    ///
    44     /// The LEMON undirected graphs also fulfill the concept of
    45     /// directed graphs (\ref lemon::concepts::Digraph "Digraph
    46     /// Concept"). Each edges can be seen as two opposite
    47     /// directed arc and consequently the undirected graph can be
    48     /// seen as the direceted graph of these directed arcs. The
    49     /// Graph has the Edge inner class for the edges and
    50     /// the Arc type for the directed arcs. The Arc type is
    51     /// convertible to Edge or inherited from it so from a directed
    52     /// arc we can get the represented edge.
     48    /// The undirected graphs also fulfill the concept of \ref Digraph
     49    /// "directed graphs", since each edge can also be regarded as two
     50    /// oppositely directed arcs.
     51    /// Undirected graphs provide an Edge type for the undirected edges and
     52    /// an Arc type for the directed arcs. The Arc type is convertible to
     53    /// Edge or inherited from it, i.e. the corresponding edge can be
     54    /// obtained from an arc.
     55    /// EdgeIt and EdgeMap classes can be used for the edges, while ArcIt
     56    /// and ArcMap classes can be used for the arcs (just like in digraphs).
     57    /// Both InArcIt and OutArcIt iterates on the same edges but with
     58    /// opposite direction. IncEdgeIt also iterates on the same edges
     59    /// as OutArcIt and InArcIt, but it is not convertible to Arc,
     60    /// only to Edge.
    5361    ///
    54     /// In the sense of the LEMON each edge has a default
    55     /// direction (it should be in every computer implementation,
    56     /// because the order of edge's nodes defines an
    57     /// orientation). With the default orientation we can define that
    58     /// the directed arc is forward or backward directed. With the \c
    59     /// direction() and \c direct() function we can get the direction
    60     /// of the directed arc and we can direct an edge.
     62    /// In LEMON, each undirected edge has an inherent orientation.
     63    /// Thus it can defined if an arc is forward or backward oriented in
     64    /// an undirected graph with respect to this default oriantation of
     65    /// the represented edge.
     66    /// With the direction() and direct() functions the direction
     67    /// of an arc can be obtained and set, respectively.
    6168    ///
    62     /// The EdgeIt is an iterator for the edges. We can use
    63     /// the EdgeMap to map values for the edges. The InArcIt and
    64     /// OutArcIt iterates on the same edges but with opposite
    65     /// direction. The IncEdgeIt iterates also on the same edges
    66     /// as the OutArcIt and InArcIt but it is not convertible to Arc just
    67     /// to Edge.
     69    /// Only nodes and edges can be added to or removed from an undirected
     70    /// graph and the corresponding arcs are added or removed automatically.
     71    ///
     72    /// \sa Digraph
    6873    class Graph {
     74    private:
     75      /// Graphs are \e not copy constructible. Use DigraphCopy instead.
     76      Graph(const Graph&) {}
     77      /// \brief Assignment of a graph to another one is \e not allowed.
     78      /// Use DigraphCopy instead.
     79      void operator=(const Graph&) {}
     80
    6981    public:
    70       /// \brief The undirected graph should be tagged by the
    71       /// UndirectedTag.
    72       ///
    73       /// The undirected graph should be tagged by the UndirectedTag. This
    74       /// tag helps the enable_if technics to make compile time
     82      /// Default constructor.
     83      Graph() {}
     84
     85      /// \brief Undirected graphs should be tagged with \c UndirectedTag.
     86      ///
     87      /// Undirected graphs should be tagged with \c UndirectedTag.
     88      ///
     89      /// This tag helps the \c enable_if technics to make compile time
    7590      /// specializations for undirected graphs.
    7691      typedef True UndirectedTag;
    7792
    78       /// \brief The base type of node iterators,
    79       /// or in other words, the trivial node iterator.
    80       ///
    81       /// This is the base type of each node iterator,
    82       /// thus each kind of node iterator converts to this.
    83       /// More precisely each kind of node iterator should be inherited
    84       /// from the trivial node iterator.
     93      /// The node type of the graph
     94
     95      /// This class identifies a node of the graph. It also serves
     96      /// as a base class of the node iterators,
     97      /// thus they convert to this type.
    8598      class Node {
    8699      public:
    87100        /// Default constructor
    88101
    89         /// @warning The default constructor sets the iterator
    90         /// to an undefined value.
     102        /// Default constructor.
     103        /// \warning It sets the object to an undefined value.
    91104        Node() { }
    92105        /// Copy constructor.
     
    96109        Node(const Node&) { }
    97110
    98         /// Invalid constructor \& conversion.
    99 
    100         /// This constructor initializes the iterator to be invalid.
     111        /// %Invalid constructor \& conversion.
     112
     113        /// Initializes the object to be invalid.
    101114        /// \sa Invalid for more details.
    102115        Node(Invalid) { }
    103116        /// Equality operator
    104117
     118        /// Equality operator.
     119        ///
    105120        /// Two iterators are equal if and only if they point to the
    106         /// same object or both are invalid.
     121        /// same object or both are \c INVALID.
    107122        bool operator==(Node) const { return true; }
    108123
    109124        /// Inequality operator
    110125
    111         /// \sa operator==(Node n)
    112         ///
     126        /// Inequality operator.
    113127        bool operator!=(Node) const { return true; }
    114128
    115129        /// Artificial ordering operator.
    116130
    117         /// To allow the use of graph descriptors as key type in std::map or
    118         /// similar associative container we require this.
    119         ///
    120         /// \note This operator only have to define some strict ordering of
     131        /// Artificial ordering operator.
     132        ///
     133        /// \note This operator only has to define some strict ordering of
    121134        /// the items; this order has nothing to do with the iteration
    122135        /// ordering of the items.
     
    125138      };
    126139
    127       /// This iterator goes through each node.
    128 
    129       /// This iterator goes through each node.
     140      /// Iterator class for the nodes.
     141
     142      /// This iterator goes through each node of the graph.
    130143      /// Its usage is quite simple, for example you can count the number
    131       /// of nodes in graph \c g of type \c Graph like this:
     144      /// of nodes in a graph \c g of type \c %Graph like this:
    132145      ///\code
    133146      /// int count=0;
     
    138151        /// Default constructor
    139152
    140         /// @warning The default constructor sets the iterator
    141         /// to an undefined value.
     153        /// Default constructor.
     154        /// \warning It sets the iterator to an undefined value.
    142155        NodeIt() { }
    143156        /// Copy constructor.
     
    146159        ///
    147160        NodeIt(const NodeIt& n) : Node(n) { }
    148         /// Invalid constructor \& conversion.
    149 
    150         /// Initialize the iterator to be invalid.
     161        /// %Invalid constructor \& conversion.
     162
     163        /// Initializes the iterator to be invalid.
    151164        /// \sa Invalid for more details.
    152165        NodeIt(Invalid) { }
    153166        /// Sets the iterator to the first node.
    154167
    155         /// Sets the iterator to the first node of \c g.
    156         ///
    157         NodeIt(const Graph&) { }
    158         /// Node -> NodeIt conversion.
    159 
    160         /// Sets the iterator to the node of \c the graph pointed by
    161         /// the trivial iterator.
    162         /// This feature necessitates that each time we
    163         /// iterate the arc-set, the iteration order is the same.
     168        /// Sets the iterator to the first node of the given digraph.
     169        ///
     170        explicit NodeIt(const Graph&) { }
     171        /// Sets the iterator to the given node.
     172
     173        /// Sets the iterator to the given node of the given digraph.
     174        ///
    164175        NodeIt(const Graph&, const Node&) { }
    165176        /// Next node.
     
    171182
    172183
    173       /// The base type of the edge iterators.
    174 
    175       /// The base type of the edge iterators.
    176       ///
     184      /// The edge type of the graph
     185
     186      /// This class identifies an edge of the graph. It also serves
     187      /// as a base class of the edge iterators,
     188      /// thus they will convert to this type.
    177189      class Edge {
    178190      public:
    179191        /// Default constructor
    180192
    181         /// @warning The default constructor sets the iterator
    182         /// to an undefined value.
     193        /// Default constructor.
     194        /// \warning It sets the object to an undefined value.
    183195        Edge() { }
    184196        /// Copy constructor.
     
    187199        ///
    188200        Edge(const Edge&) { }
    189         /// Initialize the iterator to be invalid.
    190 
    191         /// Initialize the iterator to be invalid.
    192         ///
     201        /// %Invalid constructor \& conversion.
     202
     203        /// Initializes the object to be invalid.
     204        /// \sa Invalid for more details.
    193205        Edge(Invalid) { }
    194206        /// Equality operator
    195207
     208        /// Equality operator.
     209        ///
    196210        /// Two iterators are equal if and only if they point to the
    197         /// same object or both are invalid.
     211        /// same object or both are \c INVALID.
    198212        bool operator==(Edge) const { return true; }
    199213        /// Inequality operator
    200214
    201         /// \sa operator==(Edge n)
    202         ///
     215        /// Inequality operator.
    203216        bool operator!=(Edge) const { return true; }
    204217
    205218        /// Artificial ordering operator.
    206219
    207         /// To allow the use of graph descriptors as key type in std::map or
    208         /// similar associative container we require this.
    209         ///
    210         /// \note This operator only have to define some strict ordering of
    211         /// the items; this order has nothing to do with the iteration
    212         /// ordering of the items.
     220        /// Artificial ordering operator.
     221        ///
     222        /// \note This operator only has to define some strict ordering of
     223        /// the edges; this order has nothing to do with the iteration
     224        /// ordering of the edges.
    213225        bool operator<(Edge) const { return false; }
    214226      };
    215227
    216       /// This iterator goes through each edge.
    217 
    218       /// This iterator goes through each edge of a graph.
     228      /// Iterator class for the edges.
     229
     230      /// This iterator goes through each edge of the graph.
    219231      /// Its usage is quite simple, for example you can count the number
    220       /// of edges in a graph \c g of type \c Graph as follows:
     232      /// of edges in a graph \c g of type \c %Graph as follows:
    221233      ///\code
    222234      /// int count=0;
     
    227239        /// Default constructor
    228240
    229         /// @warning The default constructor sets the iterator
    230         /// to an undefined value.
     241        /// Default constructor.
     242        /// \warning It sets the iterator to an undefined value.
    231243        EdgeIt() { }
    232244        /// Copy constructor.
     
    235247        ///
    236248        EdgeIt(const EdgeIt& e) : Edge(e) { }
    237         /// Initialize the iterator to be invalid.
    238 
    239         /// Initialize the iterator to be invalid.
    240         ///
     249        /// %Invalid constructor \& conversion.
     250
     251        /// Initializes the iterator to be invalid.
     252        /// \sa Invalid for more details.
    241253        EdgeIt(Invalid) { }
    242         /// This constructor sets the iterator to the first edge.
    243 
    244         /// This constructor sets the iterator to the first edge.
    245         EdgeIt(const Graph&) { }
    246         /// Edge -> EdgeIt conversion
    247 
    248         /// Sets the iterator to the value of the trivial iterator.
    249         /// This feature necessitates that each time we
    250         /// iterate the edge-set, the iteration order is the
    251         /// same.
     254        /// Sets the iterator to the first edge.
     255
     256        /// Sets the iterator to the first edge of the given graph.
     257        ///
     258        explicit EdgeIt(const Graph&) { }
     259        /// Sets the iterator to the given edge.
     260
     261        /// Sets the iterator to the given edge of the given graph.
     262        ///
    252263        EdgeIt(const Graph&, const Edge&) { }
    253264        /// Next edge
    254265
    255266        /// Assign the iterator to the next edge.
     267        ///
    256268        EdgeIt& operator++() { return *this; }
    257269      };
    258270
    259       /// \brief This iterator goes trough the incident undirected
    260       /// arcs of a node.
    261       ///
    262       /// This iterator goes trough the incident edges
    263       /// of a certain node of a graph. You should assume that the
    264       /// loop arcs will be iterated twice.
    265       ///
     271      /// Iterator class for the incident edges of a node.
     272
     273      /// This iterator goes trough the incident undirected edges
     274      /// of a certain node of a graph.
    266275      /// Its usage is quite simple, for example you can compute the
    267       /// degree (i.e. count the number of incident arcs of a node \c n
    268       /// in graph \c g of type \c Graph as follows.
     276      /// degree (i.e. the number of incident edges) of a node \c n
     277      /// in a graph \c g of type \c %Graph as follows.
    269278      ///
    270279      ///\code
     
    272281      /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
    273282      ///\endcode
     283      ///
     284      /// \warning Loop edges will be iterated twice.
    274285      class IncEdgeIt : public Edge {
    275286      public:
    276287        /// Default constructor
    277288
    278         /// @warning The default constructor sets the iterator
    279         /// to an undefined value.
     289        /// Default constructor.
     290        /// \warning It sets the iterator to an undefined value.
    280291        IncEdgeIt() { }
    281292        /// Copy constructor.
     
    284295        ///
    285296        IncEdgeIt(const IncEdgeIt& e) : Edge(e) { }
    286         /// Initialize the iterator to be invalid.
    287 
    288         /// Initialize the iterator to be invalid.
    289         ///
     297        /// %Invalid constructor \& conversion.
     298
     299        /// Initializes the iterator to be invalid.
     300        /// \sa Invalid for more details.
    290301        IncEdgeIt(Invalid) { }
    291         /// This constructor sets the iterator to first incident arc.
    292 
    293         /// This constructor set the iterator to the first incident arc of
    294         /// the node.
     302        /// Sets the iterator to the first incident edge.
     303
     304        /// Sets the iterator to the first incident edge of the given node.
     305        ///
    295306        IncEdgeIt(const Graph&, const Node&) { }
    296         /// Edge -> IncEdgeIt conversion
    297 
    298         /// Sets the iterator to the value of the trivial iterator \c e.
    299         /// This feature necessitates that each time we
    300         /// iterate the arc-set, the iteration order is the same.
     307        /// Sets the iterator to the given edge.
     308
     309        /// Sets the iterator to the given edge of the given graph.
     310        ///
    301311        IncEdgeIt(const Graph&, const Edge&) { }
    302         /// Next incident arc
    303 
    304         /// Assign the iterator to the next incident arc
     312        /// Next incident edge
     313
     314        /// Assign the iterator to the next incident edge
    305315        /// of the corresponding node.
    306316        IncEdgeIt& operator++() { return *this; }
    307317      };
    308318
    309       /// The directed arc type.
    310 
    311       /// The directed arc type. It can be converted to the
    312       /// edge or it should be inherited from the undirected
    313       /// edge.
     319      /// The arc type of the graph
     320
     321      /// This class identifies a directed arc of the graph. It also serves
     322      /// as a base class of the arc iterators,
     323      /// thus they will convert to this type.
    314324      class Arc {
    315325      public:
    316326        /// Default constructor
    317327
    318         /// @warning The default constructor sets the iterator
    319         /// to an undefined value.
     328        /// Default constructor.
     329        /// \warning It sets the object to an undefined value.
    320330        Arc() { }
    321331        /// Copy constructor.
     
    324334        ///
    325335        Arc(const Arc&) { }
    326         /// Initialize the iterator to be invalid.
    327 
    328         /// Initialize the iterator to be invalid.
    329         ///
     336        /// %Invalid constructor \& conversion.
     337
     338        /// Initializes the object to be invalid.
     339        /// \sa Invalid for more details.
    330340        Arc(Invalid) { }
    331341        /// Equality operator
    332342
     343        /// Equality operator.
     344        ///
    333345        /// Two iterators are equal if and only if they point to the
    334         /// same object or both are invalid.
     346        /// same object or both are \c INVALID.
    335347        bool operator==(Arc) const { return true; }
    336348        /// Inequality operator
    337349
    338         /// \sa operator==(Arc n)
    339         ///
     350        /// Inequality operator.
    340351        bool operator!=(Arc) const { return true; }
    341352
    342353        /// Artificial ordering operator.
    343354
    344         /// To allow the use of graph descriptors as key type in std::map or
    345         /// similar associative container we require this.
    346         ///
    347         /// \note This operator only have to define some strict ordering of
    348         /// the items; this order has nothing to do with the iteration
    349         /// ordering of the items.
     355        /// Artificial ordering operator.
     356        ///
     357        /// \note This operator only has to define some strict ordering of
     358        /// the arcs; this order has nothing to do with the iteration
     359        /// ordering of the arcs.
    350360        bool operator<(Arc) const { return false; }
    351361
    352         /// Converison to Edge
     362        /// Converison to \c Edge
     363       
     364        /// Converison to \c Edge.
     365        ///
    353366        operator Edge() const { return Edge(); }
    354367      };
    355       /// This iterator goes through each directed arc.
    356 
    357       /// This iterator goes through each arc of a graph.
     368
     369      /// Iterator class for the arcs.
     370
     371      /// This iterator goes through each directed arc of the graph.
    358372      /// Its usage is quite simple, for example you can count the number
    359       /// of arcs in a graph \c g of type \c Graph as follows:
     373      /// of arcs in a graph \c g of type \c %Graph as follows:
    360374      ///\code
    361375      /// int count=0;
    362       /// for(Graph::ArcIt e(g); e!=INVALID; ++e) ++count;
     376      /// for(Graph::ArcIt a(g); a!=INVALID; ++a) ++count;
    363377      ///\endcode
    364378      class ArcIt : public Arc {
     
    366380        /// Default constructor
    367381
    368         /// @warning The default constructor sets the iterator
    369         /// to an undefined value.
     382        /// Default constructor.
     383        /// \warning It sets the iterator to an undefined value.
    370384        ArcIt() { }
    371385        /// Copy constructor.
     
    374388        ///
    375389        ArcIt(const ArcIt& e) : Arc(e) { }
    376         /// Initialize the iterator to be invalid.
    377 
    378         /// Initialize the iterator to be invalid.
    379         ///
     390        /// %Invalid constructor \& conversion.
     391
     392        /// Initializes the iterator to be invalid.
     393        /// \sa Invalid for more details.
    380394        ArcIt(Invalid) { }
    381         /// This constructor sets the iterator to the first arc.
    382 
    383         /// This constructor sets the iterator to the first arc of \c g.
    384         ///@param g the graph
    385         ArcIt(const Graph &g) { ignore_unused_variable_warning(g); }
    386         /// Arc -> ArcIt 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 arc-set, the iteration order is the same.
     395        /// Sets the iterator to the first arc.
     396
     397        /// Sets the iterator to the first arc of the given graph.
     398        ///
     399        explicit ArcIt(const Graph &g) { ignore_unused_variable_warning(g); }
     400        /// Sets the iterator to the given arc.
     401
     402        /// Sets the iterator to the given arc of the given graph.
     403        ///
    391404        ArcIt(const Graph&, const Arc&) { }
    392         ///Next arc
     405        /// Next arc
    393406
    394407        /// Assign the iterator to the next arc.
     408        ///
    395409        ArcIt& operator++() { return *this; }
    396410      };
    397411
    398       /// This iterator goes trough the outgoing directed arcs of a node.
    399 
    400       /// This iterator goes trough the \e outgoing arcs of a certain node
    401       /// of a graph.
     412      /// Iterator class for the outgoing arcs of a node.
     413
     414      /// This iterator goes trough the \e outgoing directed arcs of a
     415      /// certain node of a graph.
    402416      /// Its usage is quite simple, for example you can count the number
    403417      /// of outgoing arcs of a node \c n
    404       /// in graph \c g of type \c Graph as follows.
     418      /// in a graph \c g of type \c %Graph as follows.
    405419      ///\code
    406420      /// int count=0;
    407       /// for (Graph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
     421      /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
    408422      ///\endcode
    409 
    410423      class OutArcIt : public Arc {
    411424      public:
    412425        /// Default constructor
    413426
    414         /// @warning The default constructor sets the iterator
    415         /// to an undefined value.
     427        /// Default constructor.
     428        /// \warning It sets the iterator to an undefined value.
    416429        OutArcIt() { }
    417430        /// Copy constructor.
     
    420433        ///
    421434        OutArcIt(const OutArcIt& e) : Arc(e) { }
    422         /// Initialize the iterator to be invalid.
    423 
    424         /// Initialize the iterator to be invalid.
    425         ///
     435        /// %Invalid constructor \& conversion.
     436
     437        /// Initializes the iterator to be invalid.
     438        /// \sa Invalid for more details.
    426439        OutArcIt(Invalid) { }
    427         /// This constructor sets the iterator to the first outgoing arc.
    428 
    429         /// This constructor sets the iterator to the first outgoing arc of
    430         /// the node.
    431         ///@param n the node
    432         ///@param g the graph
     440        /// Sets the iterator to the first outgoing arc.
     441
     442        /// Sets the iterator to the first outgoing arc of the given node.
     443        ///
    433444        OutArcIt(const Graph& n, const Node& g) {
    434445          ignore_unused_variable_warning(n);
    435446          ignore_unused_variable_warning(g);
    436447        }
    437         /// Arc -> OutArcIt conversion
    438 
    439         /// Sets the iterator to the value of the trivial iterator.
    440         /// This feature necessitates that each time we
    441         /// iterate the arc-set, the iteration order is the same.
     448        /// Sets the iterator to the given arc.
     449
     450        /// Sets the iterator to the given arc of the given graph.
     451        ///
    442452        OutArcIt(const Graph&, const Arc&) { }
    443         ///Next outgoing arc
     453        /// Next outgoing arc
    444454
    445455        /// Assign the iterator to the next
     
    448458      };
    449459
    450       /// This iterator goes trough the incoming directed arcs of a node.
    451 
    452       /// This iterator goes trough the \e incoming arcs of a certain node
    453       /// of a graph.
     460      /// Iterator class for the incoming arcs of a node.
     461
     462      /// This iterator goes trough the \e incoming directed arcs of a
     463      /// certain node of a graph.
    454464      /// Its usage is quite simple, for example you can count the number
    455       /// of outgoing arcs of a node \c n
    456       /// in graph \c g of type \c Graph as follows.
     465      /// of incoming arcs of a node \c n
     466      /// in a graph \c g of type \c %Graph as follows.
    457467      ///\code
    458468      /// int count=0;
    459       /// for(Graph::InArcIt e(g, n); e!=INVALID; ++e) ++count;
     469      /// for (Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
    460470      ///\endcode
    461 
    462471      class InArcIt : public Arc {
    463472      public:
    464473        /// Default constructor
    465474
    466         /// @warning The default constructor sets the iterator
    467         /// to an undefined value.
     475        /// Default constructor.
     476        /// \warning It sets the iterator to an undefined value.
    468477        InArcIt() { }
    469478        /// Copy constructor.
     
    472481        ///
    473482        InArcIt(const InArcIt& e) : Arc(e) { }
    474         /// Initialize the iterator to be invalid.
    475 
    476         /// Initialize the iterator to be invalid.
    477         ///
     483        /// %Invalid constructor \& conversion.
     484
     485        /// Initializes the iterator to be invalid.
     486        /// \sa Invalid for more details.
    478487        InArcIt(Invalid) { }
    479         /// This constructor sets the iterator to first incoming arc.
    480 
    481         /// This constructor set the iterator to the first incoming arc of
    482         /// the node.
    483         ///@param n the node
    484         ///@param g the graph
     488        /// Sets the iterator to the first incoming arc.
     489
     490        /// Sets the iterator to the first incoming arc of the given node.
     491        ///
    485492        InArcIt(const Graph& g, const Node& n) {
    486493          ignore_unused_variable_warning(n);
    487494          ignore_unused_variable_warning(g);
    488495        }
    489         /// Arc -> InArcIt conversion
    490 
    491         /// Sets the iterator to the value of the trivial iterator \c e.
    492         /// This feature necessitates that each time we
    493         /// iterate the arc-set, the iteration order is the same.
     496        /// Sets the iterator to the given arc.
     497
     498        /// Sets the iterator to the given arc of the given graph.
     499        ///
    494500        InArcIt(const Graph&, const Arc&) { }
    495501        /// Next incoming arc
    496502
    497         /// Assign the iterator to the next inarc of the corresponding node.
    498         ///
     503        /// Assign the iterator to the next
     504        /// incoming arc of the corresponding node.
    499505        InArcIt& operator++() { return *this; }
    500506      };
    501507
    502       /// \brief Reference map of the nodes to type \c T.
    503       ///
    504       /// Reference map of the nodes to type \c T.
     508      /// \brief Standard graph map type for the nodes.
     509      ///
     510      /// Standard graph map type for the nodes.
     511      /// It conforms to the ReferenceMap concept.
    505512      template<class T>
    506513      class NodeMap : public ReferenceMap<Node, T, T&, const T&>
     
    508515      public:
    509516
    510         ///\e
    511         NodeMap(const Graph&) { }
    512         ///\e
     517        /// Constructor
     518        explicit NodeMap(const Graph&) { }
     519        /// Constructor with given initial value
    513520        NodeMap(const Graph&, T) { }
    514521
     
    525532      };
    526533
    527       /// \brief Reference map of the arcs to type \c T.
    528       ///
    529       /// Reference map of the arcs to type \c T.
     534      /// \brief Standard graph map type for the arcs.
     535      ///
     536      /// Standard graph map type for the arcs.
     537      /// It conforms to the ReferenceMap concept.
    530538      template<class T>
    531539      class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
     
    533541      public:
    534542
    535         ///\e
    536         ArcMap(const Graph&) { }
    537         ///\e
     543        /// Constructor
     544        explicit ArcMap(const Graph&) { }
     545        /// Constructor with given initial value
    538546        ArcMap(const Graph&, T) { }
     547
    539548      private:
    540549        ///Copy constructor
     
    549558      };
    550559
    551       /// Reference map of the edges to type \c T.
    552 
    553       /// Reference map of the edges to type \c T.
     560      /// \brief Standard graph map type for the edges.
     561      ///
     562      /// Standard graph map type for the edges.
     563      /// It conforms to the ReferenceMap concept.
    554564      template<class T>
    555565      class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
     
    557567      public:
    558568
    559         ///\e
    560         EdgeMap(const Graph&) { }
    561         ///\e
     569        /// Constructor
     570        explicit EdgeMap(const Graph&) { }
     571        /// Constructor with given initial value
    562572        EdgeMap(const Graph&, T) { }
     573
    563574      private:
    564575        ///Copy constructor
     
    573584      };
    574585
    575       /// \brief Direct the given edge.
    576       ///
    577       /// Direct the given edge. The returned arc source
    578       /// will be the given node.
    579       Arc direct(const Edge&, const Node&) const {
    580         return INVALID;
    581       }
    582 
    583       /// \brief Direct the given edge.
    584       ///
    585       /// Direct the given edge. The returned arc
    586       /// represents the given edge and the direction comes
    587       /// from the bool parameter. The source of the edge and
    588       /// the directed arc is the same when the given bool is true.
    589       Arc direct(const Edge&, bool) const {
    590         return INVALID;
    591       }
    592 
    593       /// \brief Returns true if the arc has default orientation.
    594       ///
    595       /// Returns whether the given directed arc is same orientation as
    596       /// the corresponding edge's default orientation.
    597       bool direction(Arc) const { return true; }
    598 
    599       /// \brief Returns the opposite directed arc.
    600       ///
    601       /// Returns the opposite directed arc.
    602       Arc oppositeArc(Arc) const { return INVALID; }
    603 
    604       /// \brief Opposite node on an arc
    605       ///
    606       /// \return The opposite of the given node on the given edge.
    607       Node oppositeNode(Node, Edge) const { return INVALID; }
    608 
    609       /// \brief First node of the edge.
    610       ///
    611       /// \return The first node of the given edge.
    612       ///
    613       /// Naturally edges don't have direction and thus
    614       /// don't have source and target node. However we use \c u() and \c v()
    615       /// methods to query the two nodes of the arc. The direction of the
    616       /// arc which arises this way is called the inherent direction of the
    617       /// edge, and is used to define the "default" direction
    618       /// of the directed versions of the arcs.
     586      /// \brief The first node of the edge.
     587      ///
     588      /// Returns the first node of the given edge.
     589      ///
     590      /// Edges don't have source and target nodes, however methods
     591      /// u() and v() are used to query the two end-nodes of an edge.
     592      /// The orientation of an edge that arises this way is called
     593      /// the inherent direction, it is used to define the default
     594      /// direction for the corresponding arcs.
    619595      /// \sa v()
    620596      /// \sa direction()
    621597      Node u(Edge) const { return INVALID; }
    622598
    623       /// \brief Second node of the edge.
    624       ///
    625       /// \return The second node of the given edge.
    626       ///
    627       /// Naturally edges don't have direction and thus
    628       /// don't have source and target node. However we use \c u() and \c v()
    629       /// methods to query the two nodes of the arc. The direction of the
    630       /// arc which arises this way is called the inherent direction of the
    631       /// edge, and is used to define the "default" direction
    632       /// of the directed versions of the arcs.
     599      /// \brief The second node of the edge.
     600      ///
     601      /// Returns the second node of the given edge.
     602      ///
     603      /// Edges don't have source and target nodes, however methods
     604      /// u() and v() are used to query the two end-nodes of an edge.
     605      /// The orientation of an edge that arises this way is called
     606      /// the inherent direction, it is used to define the default
     607      /// direction for the corresponding arcs.
    633608      /// \sa u()
    634609      /// \sa direction()
    635610      Node v(Edge) const { return INVALID; }
    636611
    637       /// \brief Source node of the directed arc.
     612      /// \brief The source node of the arc.
     613      ///
     614      /// Returns the source node of the given arc.
    638615      Node source(Arc) const { return INVALID; }
    639616
    640       /// \brief Target node of the directed arc.
     617      /// \brief The target node of the arc.
     618      ///
     619      /// Returns the target node of the given arc.
    641620      Node target(Arc) const { return INVALID; }
    642621
    643       /// \brief Returns the id of the node.
     622      /// \brief The ID of the node.
     623      ///
     624      /// Returns the ID of the given node.
    644625      int id(Node) const { return -1; }
    645626
    646       /// \brief Returns the id of the edge.
     627      /// \brief The ID of the edge.
     628      ///
     629      /// Returns the ID of the given edge.
    647630      int id(Edge) const { return -1; }
    648631
    649       /// \brief Returns the id of the arc.
     632      /// \brief The ID of the arc.
     633      ///
     634      /// Returns the ID of the given arc.
    650635      int id(Arc) const { return -1; }
    651636
    652       /// \brief Returns the node with the given id.
    653       ///
    654       /// \pre The argument should be a valid node id in the graph.
     637      /// \brief The node with the given ID.
     638      ///
     639      /// Returns the node with the given ID.
     640      /// \pre The argument should be a valid node ID in the graph.
    655641      Node nodeFromId(int) const { return INVALID; }
    656642
    657       /// \brief Returns the edge with the given id.
    658       ///
    659       /// \pre The argument should be a valid edge id in the graph.
     643      /// \brief The edge with the given ID.
     644      ///
     645      /// Returns the edge with the given ID.
     646      /// \pre The argument should be a valid edge ID in the graph.
    660647      Edge edgeFromId(int) const { return INVALID; }
    661648
    662       /// \brief Returns the arc with the given id.
    663       ///
    664       /// \pre The argument should be a valid arc id in the graph.
     649      /// \brief The arc with the given ID.
     650      ///
     651      /// Returns the arc with the given ID.
     652      /// \pre The argument should be a valid arc ID in the graph.
    665653      Arc arcFromId(int) const { return INVALID; }
    666654
    667       /// \brief Returns an upper bound on the node IDs.
     655      /// \brief An upper bound on the node IDs.
     656      ///
     657      /// Returns an upper bound on the node IDs.
    668658      int maxNodeId() const { return -1; }
    669659
    670       /// \brief Returns an upper bound on the edge IDs.
     660      /// \brief An upper bound on the edge IDs.
     661      ///
     662      /// Returns an upper bound on the edge IDs.
    671663      int maxEdgeId() const { return -1; }
    672664
    673       /// \brief Returns an upper bound on the arc IDs.
     665      /// \brief An upper bound on the arc IDs.
     666      ///
     667      /// Returns an upper bound on the arc IDs.
    674668      int maxArcId() const { return -1; }
     669
     670      /// \brief The direction of the arc.
     671      ///
     672      /// Returns \c true if the direction of the given arc is the same as
     673      /// the inherent orientation of the represented edge.
     674      bool direction(Arc) const { return true; }
     675
     676      /// \brief Direct the edge.
     677      ///
     678      /// Direct the given edge. The returned arc
     679      /// represents the given edge and its direction comes
     680      /// from the bool parameter. If it is \c true, then the direction
     681      /// of the arc is the same as the inherent orientation of the edge.
     682      Arc direct(Edge, bool) const {
     683        return INVALID;
     684      }
     685
     686      /// \brief Direct the edge.
     687      ///
     688      /// Direct the given edge. The returned arc represents the given
     689      /// edge and its source node is the given node.
     690      Arc direct(Edge, Node) const {
     691        return INVALID;
     692      }
     693
     694      /// \brief The oppositely directed arc.
     695      ///
     696      /// Returns the oppositely directed arc representing the same edge.
     697      Arc oppositeArc(Arc) const { return INVALID; }
     698
     699      /// \brief The opposite node on the edge.
     700      ///
     701      /// Returns the opposite node on the given edge.
     702      Node oppositeNode(Node, Edge) const { return INVALID; }
    675703
    676704      void first(Node&) const {}
     
    706734      int maxId(Arc) const { return -1; }
    707735
    708       /// \brief Base node of the iterator
    709       ///
    710       /// Returns the base node (the source in this case) of the iterator
    711       Node baseNode(OutArcIt e) const {
    712         return source(e);
    713       }
    714       /// \brief Running node of the iterator
    715       ///
    716       /// Returns the running node (the target in this case) of the
    717       /// iterator
    718       Node runningNode(OutArcIt e) const {
    719         return target(e);
    720       }
    721 
    722       /// \brief Base node of the iterator
    723       ///
    724       /// Returns the base node (the target in this case) of the iterator
    725       Node baseNode(InArcIt e) const {
    726         return target(e);
    727       }
    728       /// \brief Running node of the iterator
    729       ///
    730       /// Returns the running node (the source in this case) of the
    731       /// iterator
    732       Node runningNode(InArcIt e) const {
    733         return source(e);
    734       }
    735 
    736       /// \brief Base node of the iterator
    737       ///
    738       /// Returns the base node of the iterator
    739       Node baseNode(IncEdgeIt) const {
    740         return INVALID;
    741       }
    742 
    743       /// \brief Running node of the iterator
    744       ///
    745       /// Returns the running node of the iterator
    746       Node runningNode(IncEdgeIt) const {
    747         return INVALID;
    748       }
     736      /// \brief The base node of the iterator.
     737      ///
     738      /// Returns the base node of the given incident edge iterator.
     739      Node baseNode(IncEdgeIt) const { return INVALID; }
     740
     741      /// \brief The running node of the iterator.
     742      ///
     743      /// Returns the running node of the given incident edge iterator.
     744      Node runningNode(IncEdgeIt) const { return INVALID; }
     745
     746      /// \brief The base node of the iterator.
     747      ///
     748      /// Returns the base node of the given outgoing arc iterator
     749      /// (i.e. the source node of the corresponding arc).
     750      Node baseNode(OutArcIt) const { return INVALID; }
     751
     752      /// \brief The running node of the iterator.
     753      ///
     754      /// Returns the running node of the given outgoing arc iterator
     755      /// (i.e. the target node of the corresponding arc).
     756      Node runningNode(OutArcIt) const { return INVALID; }
     757
     758      /// \brief The base node of the iterator.
     759      ///
     760      /// Returns the base node of the given incomming arc iterator
     761      /// (i.e. the target node of the corresponding arc).
     762      Node baseNode(InArcIt) const { return INVALID; }
     763
     764      /// \brief The running node of the iterator.
     765      ///
     766      /// Returns the running node of the given incomming arc iterator
     767      /// (i.e. the source node of the corresponding arc).
     768      Node runningNode(InArcIt) const { return INVALID; }
    749769
    750770      template <typename _Graph>
  • lemon/concepts/graph_components.h

    r713 r781  
    9393      /// associative containers (e.g. \c std::map).
    9494      ///
    95       /// \note This operator only have to define some strict ordering of
     95      /// \note This operator only has to define some strict ordering of
    9696      /// the items; this order has nothing to do with the iteration
    9797      /// ordering of the items.
  • lemon/cplex.cc

    r623 r793  
    112112  }
    113113
     114  int CplexBase::_addRow(Value lb, ExprIterator b,
     115                         ExprIterator e, Value ub) {
     116    int i = CPXgetnumrows(cplexEnv(), _prob);
     117    if (lb == -INF) {
     118      const char s = 'L';
     119      CPXnewrows(cplexEnv(), _prob, 1, &ub, &s, 0, 0);
     120    } else if (ub == INF) {
     121      const char s = 'G';
     122      CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, 0, 0);
     123    } else if (lb == ub){
     124      const char s = 'E';
     125      CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, 0, 0);
     126    } else {
     127      const char s = 'R';
     128      double len = ub - lb;
     129      CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, &len, 0);
     130    }
     131
     132    std::vector<int> indices;
     133    std::vector<int> rowlist;
     134    std::vector<Value> values;
     135
     136    for(ExprIterator it=b; it!=e; ++it) {
     137      indices.push_back(it->first);
     138      values.push_back(it->second);
     139      rowlist.push_back(i);
     140    }
     141
     142    CPXchgcoeflist(cplexEnv(), _prob, values.size(),
     143                   &rowlist.front(), &indices.front(), &values.front());
     144
     145    return i;
     146  }
    114147
    115148  void CplexBase::_eraseCol(int i) {
  • lemon/cplex.h

    r623 r793  
    9494    virtual int _addCol();
    9595    virtual int _addRow();
     96    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
    9697
    9798    virtual void _eraseCol(int i);
  • lemon/edge_set.h

    r717 r825  
    868868    }
    869869
    870     void next(Arc& arc) const {
     870    static void next(Arc& arc) {
    871871      --arc.id;
    872872    }
     
    11741174    }
    11751175
    1176     void next(Arc& arc) const {
     1176    static void next(Arc& arc) {
    11771177      --arc.id;
    11781178    }
     
    11821182    }
    11831183
    1184     void next(Edge& arc) const {
     1184    static void next(Edge& arc) {
    11851185      --arc.id;
    11861186    }
  • lemon/full_graph.h

    r664 r827  
    2525///\ingroup graphs
    2626///\file
    27 ///\brief FullGraph and FullDigraph classes.
     27///\brief FullDigraph and FullGraph classes.
    2828
    2929namespace lemon {
     
    5252
    5353    Node operator()(int ix) const { return Node(ix); }
    54     int index(const Node& node) const { return node._id; }
     54    static int index(const Node& node) { return node._id; }
    5555
    5656    Arc arc(const Node& s, const Node& t) const {
     
    149149  /// \ingroup graphs
    150150  ///
    151   /// \brief A full digraph class.
    152   ///
    153   /// This is a simple and fast directed full graph implementation.
    154   /// From each node go arcs to each node (including the source node),
    155   /// therefore the number of the arcs in the digraph is the square of
    156   /// the node number. This digraph type is completely static, so you
    157   /// can neither add nor delete either arcs or nodes, and it needs
    158   /// constant space in memory.
    159   ///
    160   /// This class fully conforms to the \ref concepts::Digraph
    161   /// "Digraph concept".
    162   ///
    163   /// The \c FullDigraph and \c FullGraph classes are very similar,
     151  /// \brief A directed full graph class.
     152  ///
     153  /// FullDigraph is a simple and fast implmenetation of directed full
     154  /// (complete) graphs. It contains an arc from each node to each node
     155  /// (including a loop for each node), therefore the number of arcs
     156  /// is the square of the number of nodes.
     157  /// This class is completely static and it needs constant memory space.
     158  /// Thus you can neither add nor delete nodes or arcs, however
     159  /// the structure can be resized using resize().
     160  ///
     161  /// This type fully conforms to the \ref concepts::Digraph "Digraph concept".
     162  /// Most of its member functions and nested classes are documented
     163  /// only in the concept class.
     164  ///
     165  /// \note FullDigraph and FullGraph classes are very similar,
    164166  /// but there are two differences. While this class conforms only
    165   /// to the \ref concepts::Digraph "Digraph" concept, the \c FullGraph
    166   /// class conforms to the \ref concepts::Graph "Graph" concept,
    167   /// moreover \c FullGraph does not contain a loop arc for each
    168   /// node as \c FullDigraph does.
     167  /// to the \ref concepts::Digraph "Digraph" concept, FullGraph
     168  /// conforms to the \ref concepts::Graph "Graph" concept,
     169  /// moreover FullGraph does not contain a loop for each
     170  /// node as this class does.
    169171  ///
    170172  /// \sa FullGraph
     
    174176  public:
    175177
    176     /// \brief Constructor
     178    /// \brief Default constructor.
     179    ///
     180    /// Default constructor. The number of nodes and arcs will be zero.
    177181    FullDigraph() { construct(0); }
    178182
     
    185189    /// \brief Resizes the digraph
    186190    ///
    187     /// Resizes the digraph. The function will fully destroy and
    188     /// rebuild the digraph. This cause that the maps of the digraph will
     191    /// This function resizes the digraph. It fully destroys and
     192    /// rebuilds the structure, therefore the maps of the digraph will be
    189193    /// reallocated automatically and the previous values will be lost.
    190194    void resize(int n) {
     
    198202    /// \brief Returns the node with the given index.
    199203    ///
    200     /// Returns the node with the given index. Since it is a static
    201     /// digraph its nodes can be indexed with integers from the range
    202     /// <tt>[0..nodeNum()-1]</tt>.
     204    /// Returns the node with the given index. Since this structure is
     205    /// completely static, the nodes can be indexed with integers from
     206    /// the range <tt>[0..nodeNum()-1]</tt>.
    203207    /// \sa index()
    204208    Node operator()(int ix) const { return Parent::operator()(ix); }
     
    206210    /// \brief Returns the index of the given node.
    207211    ///
    208     /// Returns the index of the given node. Since it is a static
    209     /// digraph its nodes can be indexed with integers from the range
    210     /// <tt>[0..nodeNum()-1]</tt>.
    211     /// \sa operator()
    212     int index(const Node& node) const { return Parent::index(node); }
     212    /// Returns the index of the given node. Since this structure is
     213    /// completely static, the nodes can be indexed with integers from
     214    /// the range <tt>[0..nodeNum()-1]</tt>.
     215    /// \sa operator()()
     216    static int index(const Node& node) { return Parent::index(node); }
    213217
    214218    /// \brief Returns the arc connecting the given nodes.
    215219    ///
    216220    /// Returns the arc connecting the given nodes.
    217     Arc arc(const Node& u, const Node& v) const {
     221    Arc arc(Node u, Node v) const {
    218222      return Parent::arc(u, v);
    219223    }
     
    284288
    285289    Node operator()(int ix) const { return Node(ix); }
    286     int index(const Node& node) const { return node._id; }
     290    static int index(const Node& node) { return node._id; }
    287291
    288292    Edge edge(const Node& u, const Node& v) const {
     
    521525  /// \brief An undirected full graph class.
    522526  ///
    523   /// This is a simple and fast undirected full graph
    524   /// implementation. From each node go edge to each other node,
    525   /// therefore the number of edges in the graph is \f$n(n-1)/2\f$.
    526   /// This graph type is completely static, so you can neither
    527   /// add nor delete either edges or nodes, and it needs constant
    528   /// space in memory.
    529   ///
    530   /// This class fully conforms to the \ref concepts::Graph "Graph concept".
    531   ///
    532   /// The \c FullGraph and \c FullDigraph classes are very similar,
    533   /// but there are two differences. While the \c FullDigraph class
     527  /// FullGraph is a simple and fast implmenetation of undirected full
     528  /// (complete) graphs. It contains an edge between every distinct pair
     529  /// of nodes, therefore the number of edges is <tt>n(n-1)/2</tt>.
     530  /// This class is completely static and it needs constant memory space.
     531  /// Thus you can neither add nor delete nodes or edges, however
     532  /// the structure can be resized using resize().
     533  ///
     534  /// This type fully conforms to the \ref concepts::Graph "Graph concept".
     535  /// Most of its member functions and nested classes are documented
     536  /// only in the concept class.
     537  ///
     538  /// \note FullDigraph and FullGraph classes are very similar,
     539  /// but there are two differences. While FullDigraph
    534540  /// conforms only to the \ref concepts::Digraph "Digraph" concept,
    535541  /// this class conforms to the \ref concepts::Graph "Graph" concept,
    536   /// moreover \c FullGraph does not contain a loop arc for each
    537   /// node as \c FullDigraph does.
     542  /// moreover this class does not contain a loop for each
     543  /// node as FullDigraph does.
    538544  ///
    539545  /// \sa FullDigraph
     
    543549  public:
    544550
    545     /// \brief Constructor
     551    /// \brief Default constructor.
     552    ///
     553    /// Default constructor. The number of nodes and edges will be zero.
    546554    FullGraph() { construct(0); }
    547555
     
    554562    /// \brief Resizes the graph
    555563    ///
    556     /// Resizes the graph. The function will fully destroy and
    557     /// rebuild the graph. This cause that the maps of the graph will
     564    /// This function resizes the graph. It fully destroys and
     565    /// rebuilds the structure, therefore the maps of the graph will be
    558566    /// reallocated automatically and the previous values will be lost.
    559567    void resize(int n) {
     
    569577    /// \brief Returns the node with the given index.
    570578    ///
    571     /// Returns the node with the given index. Since it is a static
    572     /// graph its nodes can be indexed with integers from the range
    573     /// <tt>[0..nodeNum()-1]</tt>.
     579    /// Returns the node with the given index. Since this structure is
     580    /// completely static, the nodes can be indexed with integers from
     581    /// the range <tt>[0..nodeNum()-1]</tt>.
    574582    /// \sa index()
    575583    Node operator()(int ix) const { return Parent::operator()(ix); }
     
    577585    /// \brief Returns the index of the given node.
    578586    ///
    579     /// Returns the index of the given node. Since it is a static
    580     /// graph its nodes can be indexed with integers from the range
    581     /// <tt>[0..nodeNum()-1]</tt>.
    582     /// \sa operator()
    583     int index(const Node& node) const { return Parent::index(node); }
     587    /// Returns the index of the given node. Since this structure is
     588    /// completely static, the nodes can be indexed with integers from
     589    /// the range <tt>[0..nodeNum()-1]</tt>.
     590    /// \sa operator()()
     591    static int index(const Node& node) { return Parent::index(node); }
    584592
    585593    /// \brief Returns the arc connecting the given nodes.
    586594    ///
    587595    /// Returns the arc connecting the given nodes.
    588     Arc arc(const Node& s, const Node& t) const {
     596    Arc arc(Node s, Node t) const {
    589597      return Parent::arc(s, t);
    590598    }
    591599
    592     /// \brief Returns the edge connects the given nodes.
    593     ///
    594     /// Returns the edge connects the given nodes.
    595     Edge edge(const Node& u, const Node& v) const {
     600    /// \brief Returns the edge connecting the given nodes.
     601    ///
     602    /// Returns the edge connecting the given nodes.
     603    Edge edge(Node u, Node v) const {
    596604      return Parent::edge(u, v);
    597605    }
  • lemon/glpk.cc

    r623 r793  
    5757    int i = glp_add_rows(lp, 1);
    5858    glp_set_row_bnds(lp, i, GLP_FR, 0.0, 0.0);
     59    return i;
     60  }
     61
     62  int GlpkBase::_addRow(Value lo, ExprIterator b,
     63                        ExprIterator e, Value up) {
     64    int i = glp_add_rows(lp, 1);
     65
     66    if (lo == -INF) {
     67      if (up == INF) {
     68        glp_set_row_bnds(lp, i, GLP_FR, lo, up);
     69      } else {
     70        glp_set_row_bnds(lp, i, GLP_UP, lo, up);
     71      }   
     72    } else {
     73      if (up == INF) {
     74        glp_set_row_bnds(lp, i, GLP_LO, lo, up);
     75      } else if (lo != up) {       
     76        glp_set_row_bnds(lp, i, GLP_DB, lo, up);
     77      } else {
     78        glp_set_row_bnds(lp, i, GLP_FX, lo, up);
     79      }
     80    }
     81
     82    std::vector<int> indexes;
     83    std::vector<Value> values;
     84
     85    indexes.push_back(0);
     86    values.push_back(0);
     87
     88    for(ExprIterator it = b; it != e; ++it) {
     89      indexes.push_back(it->first);
     90      values.push_back(it->second);
     91    }
     92
     93    glp_set_mat_row(lp, i, values.size() - 1,
     94                    &indexes.front(), &values.front());
    5995    return i;
    6096  }
  • lemon/glpk.h

    r697 r793  
    5555    virtual int _addCol();
    5656    virtual int _addRow();
     57    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
    5758
    5859    virtual void _eraseCol(int i);
  • lemon/grid_graph.h

    r664 r782  
    471471  /// \brief Grid graph class
    472472  ///
    473   /// This class implements a special graph type. The nodes of the
    474   /// graph can be indexed by two integer \c (i,j) value where \c i is
    475   /// in the \c [0..width()-1] range and j is in the \c
    476   /// [0..height()-1] range. Two nodes are connected in the graph if
    477   /// the indexes differ exactly on one position and exactly one is
    478   /// the difference. The nodes of the graph can be indexed by position
    479   /// with the \c operator()() function. The positions of the nodes can be
    480   /// get with \c pos(), \c col() and \c row() members. The outgoing
     473  /// GridGraph implements a special graph type. The nodes of the
     474  /// graph can be indexed by two integer values \c (i,j) where \c i is
     475  /// in the range <tt>[0..width()-1]</tt> and j is in the range
     476  /// <tt>[0..height()-1]</tt>. Two nodes are connected in the graph if
     477  /// the indices differ exactly on one position and the difference is
     478  /// also exactly one. The nodes of the graph can be obtained by position
     479  /// using the \c operator()() function and the indices of the nodes can
     480  /// be obtained using \c pos(), \c col() and \c row() members. The outgoing
    481481  /// arcs can be retrieved with the \c right(), \c up(), \c left()
    482482  /// and \c down() functions, where the bottom-left corner is the
    483483  /// origin.
     484  ///
     485  /// This class is completely static and it needs constant memory space.
     486  /// Thus you can neither add nor delete nodes or edges, however
     487  /// the structure can be resized using resize().
    484488  ///
    485489  /// \image html grid_graph.png
     
    497501  ///\endcode
    498502  ///
    499   /// This graph type fully conforms to the \ref concepts::Graph
    500   /// "Graph concept".
     503  /// This type fully conforms to the \ref concepts::Graph "Graph concept".
     504  /// Most of its member functions and nested classes are documented
     505  /// only in the concept class.
    501506  class GridGraph : public ExtendedGridGraphBase {
    502507    typedef ExtendedGridGraphBase Parent;
     
    504509  public:
    505510
    506     /// \brief Map to get the indices of the nodes as dim2::Point<int>.
    507     ///
    508     /// Map to get the indices of the nodes as dim2::Point<int>.
     511    /// \brief Map to get the indices of the nodes as \ref dim2::Point
     512    /// "dim2::Point<int>".
     513    ///
     514    /// Map to get the indices of the nodes as \ref dim2::Point
     515    /// "dim2::Point<int>".
    509516    class IndexMap {
    510517    public:
     
    515522
    516523      /// \brief Constructor
    517       ///
    518       /// Constructor
    519524      IndexMap(const GridGraph& graph) : _graph(graph) {}
    520525
    521526      /// \brief The subscript operator
    522       ///
    523       /// The subscript operator.
    524527      Value operator[](Key key) const {
    525528        return _graph.pos(key);
     
    541544
    542545      /// \brief Constructor
    543       ///
    544       /// Constructor
    545546      ColMap(const GridGraph& graph) : _graph(graph) {}
    546547
    547548      /// \brief The subscript operator
    548       ///
    549       /// The subscript operator.
    550549      Value operator[](Key key) const {
    551550        return _graph.col(key);
     
    567566
    568567      /// \brief Constructor
    569       ///
    570       /// Constructor
    571568      RowMap(const GridGraph& graph) : _graph(graph) {}
    572569
    573570      /// \brief The subscript operator
    574       ///
    575       /// The subscript operator.
    576571      Value operator[](Key key) const {
    577572        return _graph.row(key);
     
    584579    /// \brief Constructor
    585580    ///
    586     /// Construct a grid graph with given size.
     581    /// Construct a grid graph with the given size.
    587582    GridGraph(int width, int height) { construct(width, height); }
    588583
    589     /// \brief Resize the graph
    590     ///
    591     /// Resize the graph. The function will fully destroy and rebuild
    592     /// the graph.  This cause that the maps of the graph will
    593     /// reallocated automatically and the previous values will be
    594     /// lost.
     584    /// \brief Resizes the graph
     585    ///
     586    /// This function resizes the graph. It fully destroys and
     587    /// rebuilds the structure, therefore the maps of the graph will be
     588    /// reallocated automatically and the previous values will be lost.
    595589    void resize(int width, int height) {
    596590      Parent::notifier(Arc()).clear();
     
    610604    }
    611605
    612     /// \brief Gives back the column index of the node.
     606    /// \brief The column index of the node.
    613607    ///
    614608    /// Gives back the column index of the node.
     
    617611    }
    618612
    619     /// \brief Gives back the row index of the node.
     613    /// \brief The row index of the node.
    620614    ///
    621615    /// Gives back the row index of the node.
     
    624618    }
    625619
    626     /// \brief Gives back the position of the node.
     620    /// \brief The position of the node.
    627621    ///
    628622    /// Gives back the position of the node, ie. the <tt>(col,row)</tt> pair.
     
    631625    }
    632626
    633     /// \brief Gives back the number of the columns.
     627    /// \brief The number of the columns.
    634628    ///
    635629    /// Gives back the number of the columns.
     
    638632    }
    639633
    640     /// \brief Gives back the number of the rows.
     634    /// \brief The number of the rows.
    641635    ///
    642636    /// Gives back the number of the rows.
     
    645639    }
    646640
    647     /// \brief Gives back the arc goes right from the node.
     641    /// \brief The arc goes right from the node.
    648642    ///
    649643    /// Gives back the arc goes right from the node. If there is not
     
    653647    }
    654648
    655     /// \brief Gives back the arc goes left from the node.
     649    /// \brief The arc goes left from the node.
    656650    ///
    657651    /// Gives back the arc goes left from the node. If there is not
     
    661655    }
    662656
    663     /// \brief Gives back the arc goes up from the node.
     657    /// \brief The arc goes up from the node.
    664658    ///
    665659    /// Gives back the arc goes up from the node. If there is not
     
    669663    }
    670664
    671     /// \brief Gives back the arc goes down from the node.
     665    /// \brief The arc goes down from the node.
    672666    ///
    673667    /// Gives back the arc goes down from the node. If there is not
  • lemon/hypercube_graph.h

    r664 r827  
    263263    }
    264264
    265     int index(Node node) const {
     265    static int index(Node node) {
    266266      return node._id;
    267267    }
     
    283283  /// \brief Hypercube graph class
    284284  ///
    285   /// This class implements a special graph type. The nodes of the graph
    286   /// are indiced with integers with at most \c dim binary digits.
     285  /// HypercubeGraph implements a special graph type. The nodes of the
     286  /// graph are indexed with integers having at most \c dim binary digits.
    287287  /// Two nodes are connected in the graph if and only if their indices
    288288  /// differ only on one position in the binary form.
     289  /// This class is completely static and it needs constant memory space.
     290  /// Thus you can neither add nor delete nodes or edges, however
     291  /// the structure can be resized using resize().
     292  ///
     293  /// This type fully conforms to the \ref concepts::Graph "Graph concept".
     294  /// Most of its member functions and nested classes are documented
     295  /// only in the concept class.
    289296  ///
    290297  /// \note The type of the indices is chosen to \c int for efficiency
    291298  /// reasons. Thus the maximum dimension of this implementation is 26
    292299  /// (assuming that the size of \c int is 32 bit).
    293   ///
    294   /// This graph type fully conforms to the \ref concepts::Graph
    295   /// "Graph concept".
    296300  class HypercubeGraph : public ExtendedHypercubeGraphBase {
    297301    typedef ExtendedHypercubeGraphBase Parent;
     
    303307    /// Constructs a hypercube graph with \c dim dimensions.
    304308    HypercubeGraph(int dim) { construct(dim); }
     309
     310    /// \brief Resizes the graph
     311    ///
     312    /// This function resizes the graph. It fully destroys and
     313    /// rebuilds the structure, therefore the maps of the graph will be
     314    /// reallocated automatically and the previous values will be lost.
     315    void resize(int dim) {
     316      Parent::notifier(Arc()).clear();
     317      Parent::notifier(Edge()).clear();
     318      Parent::notifier(Node()).clear();
     319      construct(dim);
     320      Parent::notifier(Node()).build();
     321      Parent::notifier(Edge()).build();
     322      Parent::notifier(Arc()).build();
     323    }
    305324
    306325    /// \brief The number of dimensions.
     
    321340    ///
    322341    /// Gives back the dimension id of the given edge.
    323     /// It is in the [0..dim-1] range.
     342    /// It is in the range <tt>[0..dim-1]</tt>.
    324343    int dimension(Edge edge) const {
    325344      return Parent::dimension(edge);
     
    329348    ///
    330349    /// Gives back the dimension id of the given arc.
    331     /// It is in the [0..dim-1] range.
     350    /// It is in the range <tt>[0..dim-1]</tt>.
    332351    int dimension(Arc arc) const {
    333352      return Parent::dimension(arc);
     
    338357    /// Gives back the index of the given node.
    339358    /// The lower bits of the integer describes the node.
    340     int index(Node node) const {
     359    static int index(Node node) {
    341360      return Parent::index(node);
    342361    }
  • lemon/list_graph.h

    r664 r788  
    2222///\ingroup graphs
    2323///\file
    24 ///\brief ListDigraph, ListGraph classes.
     24///\brief ListDigraph and ListGraph classes.
    2525
    2626#include <lemon/core.h>
     
    3232
    3333namespace lemon {
     34
     35  class ListDigraph;
    3436
    3537  class ListDigraphBase {
     
    6365    class Node {
    6466      friend class ListDigraphBase;
     67      friend class ListDigraph;
    6568    protected:
    6669
     
    7881    class Arc {
    7982      friend class ListDigraphBase;
     83      friend class ListDigraph;
    8084    protected:
    8185
     
    117121      int n;
    118122      for(n = first_node;
    119           n!=-1 && nodes[n].first_in == -1;
     123          n != -1 && nodes[n].first_out == -1;
    120124          n = nodes[n].next) {}
    121       arc.id = (n == -1) ? -1 : nodes[n].first_in;
     125      arc.id = (n == -1) ? -1 : nodes[n].first_out;
    122126    }
    123127
    124128    void next(Arc& arc) const {
    125       if (arcs[arc.id].next_in != -1) {
    126         arc.id = arcs[arc.id].next_in;
     129      if (arcs[arc.id].next_out != -1) {
     130        arc.id = arcs[arc.id].next_out;
    127131      } else {
    128132        int n;
    129         for(n = nodes[arcs[arc.id].target].next;
    130             n!=-1 && nodes[n].first_in == -1;
     133        for(n = nodes[arcs[arc.id].source].next;
     134            n != -1 && nodes[n].first_out == -1;
    131135            n = nodes[n].next) {}
    132         arc.id = (n == -1) ? -1 : nodes[n].first_in;
     136        arc.id = (n == -1) ? -1 : nodes[n].first_out;
    133137      }
    134138    }
     
    312316  ///A general directed graph structure.
    313317
    314   ///\ref ListDigraph is a simple and fast <em>directed graph</em>
    315   ///implementation based on static linked lists that are stored in
     318  ///\ref ListDigraph is a versatile and fast directed graph
     319  ///implementation based on linked lists that are stored in
    316320  ///\c std::vector structures.
    317321  ///
    318   ///It conforms to the \ref concepts::Digraph "Digraph concept" and it
    319   ///also provides several useful additional functionalities.
    320   ///Most of the member functions and nested classes are documented
     322  ///This type fully conforms to the \ref concepts::Digraph "Digraph concept"
     323  ///and it also provides several useful additional functionalities.
     324  ///Most of its member functions and nested classes are documented
    321325  ///only in the concept class.
    322326  ///
    323327  ///\sa concepts::Digraph
    324 
     328  ///\sa ListGraph
    325329  class ListDigraph : public ExtendedListDigraphBase {
    326330    typedef ExtendedListDigraphBase Parent;
    327331
    328332  private:
    329     ///ListDigraph is \e not copy constructible. Use copyDigraph() instead.
    330 
    331     ///ListDigraph is \e not copy constructible. Use copyDigraph() instead.
    332     ///
     333    /// Digraphs are \e not copy constructible. Use DigraphCopy instead.
    333334    ListDigraph(const ListDigraph &) :ExtendedListDigraphBase() {};
    334     ///\brief Assignment of ListDigraph to another one is \e not allowed.
    335     ///Use copyDigraph() instead.
    336 
    337     ///Assignment of ListDigraph to another one is \e not allowed.
    338     ///Use copyDigraph() instead.
     335    /// \brief Assignment of a digraph to another one is \e not allowed.
     336    /// Use DigraphCopy instead.
    339337    void operator=(const ListDigraph &) {}
    340338  public:
     
    348346    ///Add a new node to the digraph.
    349347
    350     ///Add a new node to the digraph.
     348    ///This function adds a new node to the digraph.
    351349    ///\return The new node.
    352350    Node addNode() { return Parent::addNode(); }
     
    354352    ///Add a new arc to the digraph.
    355353
    356     ///Add a new arc to the digraph with source node \c s
     354    ///This function adds a new arc to the digraph with source node \c s
    357355    ///and target node \c t.
    358356    ///\return The new arc.
    359     Arc addArc(const Node& s, const Node& t) {
     357    Arc addArc(Node s, Node t) {
    360358      return Parent::addArc(s, t);
    361359    }
     
    363361    ///\brief Erase a node from the digraph.
    364362    ///
    365     ///Erase a node from the digraph.
    366     ///
    367     void erase(const Node& n) { Parent::erase(n); }
     363    ///This function erases the given node from the digraph.
     364    void erase(Node n) { Parent::erase(n); }
    368365
    369366    ///\brief Erase an arc from the digraph.
    370367    ///
    371     ///Erase an arc from the digraph.
    372     ///
    373     void erase(const Arc& a) { Parent::erase(a); }
     368    ///This function erases the given arc from the digraph.
     369    void erase(Arc a) { Parent::erase(a); }
    374370
    375371    /// Node validity check
    376372
    377     /// This function gives back true if the given node is valid,
    378     /// ie. it is a real node of the graph.
    379     ///
    380     /// \warning A Node pointing to a removed item
    381     /// could become valid again later if new nodes are
    382     /// added to the graph.
     373    /// This function gives back \c true if the given node is valid,
     374    /// i.e. it is a real node of the digraph.
     375    ///
     376    /// \warning A removed node could become valid again if new nodes are
     377    /// added to the digraph.
    383378    bool valid(Node n) const { return Parent::valid(n); }
    384379
    385380    /// Arc validity check
    386381
    387     /// This function gives back true if the given arc is valid,
    388     /// ie. it is a real arc of the graph.
    389     ///
    390     /// \warning An Arc pointing to a removed item
    391     /// could become valid again later if new nodes are
    392     /// added to the graph.
     382    /// This function gives back \c true if the given arc is valid,
     383    /// i.e. it is a real arc of the digraph.
     384    ///
     385    /// \warning A removed arc could become valid again if new arcs are
     386    /// added to the digraph.
    393387    bool valid(Arc a) const { return Parent::valid(a); }
    394388
    395     /// Change the target of \c a to \c n
    396 
    397     /// Change the target of \c a to \c n
    398     ///
    399     ///\note The <tt>ArcIt</tt>s and <tt>OutArcIt</tt>s referencing
    400     ///the changed arc remain valid. However <tt>InArcIt</tt>s are
    401     ///invalidated.
     389    /// Change the target node of an arc
     390
     391    /// This function changes the target node of the given arc \c a to \c n.
     392    ///
     393    ///\note \c ArcIt and \c OutArcIt iterators referencing the changed
     394    ///arc remain valid, however \c InArcIt iterators are invalidated.
    402395    ///
    403396    ///\warning This functionality cannot be used together with the Snapshot
     
    406399      Parent::changeTarget(a,n);
    407400    }
    408     /// Change the source of \c a to \c n
    409 
    410     /// Change the source of \c a to \c n
    411     ///
    412     ///\note The <tt>InArcIt</tt>s referencing the changed arc remain
    413     ///valid. However the <tt>ArcIt</tt>s and <tt>OutArcIt</tt>s are
    414     ///invalidated.
     401    /// Change the source node of an arc
     402
     403    /// This function changes the source node of the given arc \c a to \c n.
     404    ///
     405    ///\note \c InArcIt iterators referencing the changed arc remain
     406    ///valid, however \c ArcIt and \c OutArcIt iterators are invalidated.
    415407    ///
    416408    ///\warning This functionality cannot be used together with the Snapshot
     
    420412    }
    421413
    422     /// Invert the direction of an arc.
    423 
    424     ///\note The <tt>ArcIt</tt>s referencing the changed arc remain
    425     ///valid. However <tt>OutArcIt</tt>s and <tt>InArcIt</tt>s are
    426     ///invalidated.
     414    /// Reverse the direction of an arc.
     415
     416    /// This function reverses the direction of the given arc.
     417    ///\note \c ArcIt, \c OutArcIt and \c InArcIt iterators referencing
     418    ///the changed arc are invalidated.
    427419    ///
    428420    ///\warning This functionality cannot be used together with the Snapshot
    429421    ///feature.
    430     void reverseArc(Arc e) {
    431       Node t=target(e);
    432       changeTarget(e,source(e));
    433       changeSource(e,t);
    434     }
    435 
    436     /// Reserve memory for nodes.
    437 
    438     /// Using this function it is possible to avoid the superfluous memory
    439     /// allocation: if you know that the digraph you want to build will
    440     /// be very large (e.g. it will contain millions of nodes and/or arcs)
    441     /// then it is worth reserving space for this amount before starting
    442     /// to build the digraph.
    443     /// \sa reserveArc
    444     void reserveNode(int n) { nodes.reserve(n); };
    445 
    446     /// Reserve memory for arcs.
    447 
    448     /// Using this function it is possible to avoid the superfluous memory
    449     /// allocation: if you know that the digraph you want to build will
    450     /// be very large (e.g. it will contain millions of nodes and/or arcs)
    451     /// then it is worth reserving space for this amount before starting
    452     /// to build the digraph.
    453     /// \sa reserveNode
    454     void reserveArc(int m) { arcs.reserve(m); };
     422    void reverseArc(Arc a) {
     423      Node t=target(a);
     424      changeTarget(a,source(a));
     425      changeSource(a,t);
     426    }
    455427
    456428    ///Contract two nodes.
    457429
    458     ///This function contracts two nodes.
    459     ///Node \p b will be removed but instead of deleting
    460     ///incident arcs, they will be joined to \p a.
    461     ///The last parameter \p r controls whether to remove loops. \c true
    462     ///means that loops will be removed.
    463     ///
    464     ///\note The <tt>ArcIt</tt>s referencing a moved arc remain
    465     ///valid. However <tt>InArcIt</tt>s and <tt>OutArcIt</tt>s
    466     ///may be invalidated.
     430    ///This function contracts the given two nodes.
     431    ///Node \c v is removed, but instead of deleting its
     432    ///incident arcs, they are joined to node \c u.
     433    ///If the last parameter \c r is \c true (this is the default value),
     434    ///then the newly created loops are removed.
     435    ///
     436    ///\note The moved arcs are joined to node \c u using changeSource()
     437    ///or changeTarget(), thus \c ArcIt and \c OutArcIt iterators are
     438    ///invalidated for the outgoing arcs of node \c v and \c InArcIt
     439    ///iterators are invalidated for the incomming arcs of \c v.
     440    ///Moreover all iterators referencing node \c v or the removed
     441    ///loops are also invalidated. Other iterators remain valid.
    467442    ///
    468443    ///\warning This functionality cannot be used together with the Snapshot
    469444    ///feature.
    470     void contract(Node a, Node b, bool r = true)
     445    void contract(Node u, Node v, bool r = true)
    471446    {
    472       for(OutArcIt e(*this,b);e!=INVALID;) {
     447      for(OutArcIt e(*this,v);e!=INVALID;) {
    473448        OutArcIt f=e;
    474449        ++f;
    475         if(r && target(e)==a) erase(e);
    476         else changeSource(e,a);
     450        if(r && target(e)==u) erase(e);
     451        else changeSource(e,u);
    477452        e=f;
    478453      }
    479       for(InArcIt e(*this,b);e!=INVALID;) {
     454      for(InArcIt e(*this,v);e!=INVALID;) {
    480455        InArcIt f=e;
    481456        ++f;
    482         if(r && source(e)==a) erase(e);
    483         else changeTarget(e,a);
     457        if(r && source(e)==u) erase(e);
     458        else changeTarget(e,u);
    484459        e=f;
    485460      }
    486       erase(b);
     461      erase(v);
    487462    }
    488463
    489464    ///Split a node.
    490465
    491     ///This function splits a node. First a new node is added to the digraph,
    492     ///then the source of each outgoing arc of \c n is moved to this new node.
    493     ///If \c connect is \c true (this is the default value), then a new arc
    494     ///from \c n to the newly created node is also added.
     466    ///This function splits the given node. First, a new node is added
     467    ///to the digraph, then the source of each outgoing arc of node \c n
     468    ///is moved to this new node.
     469    ///If the second parameter \c connect is \c true (this is the default
     470    ///value), then a new arc from node \c n to the newly created node
     471    ///is also added.
    495472    ///\return The newly created node.
    496473    ///
    497     ///\note The <tt>ArcIt</tt>s referencing a moved arc remain
    498     ///valid. However <tt>InArcIt</tt>s and <tt>OutArcIt</tt>s may
    499     ///be invalidated.
    500     ///
    501     ///\warning This functionality cannot be used in conjunction with the
     474    ///\note All iterators remain valid.
     475    ///
     476    ///\warning This functionality cannot be used together with the
    502477    ///Snapshot feature.
    503478    Node split(Node n, bool connect = true) {
    504479      Node b = addNode();
    505       for(OutArcIt e(*this,n);e!=INVALID;) {
    506         OutArcIt f=e;
    507         ++f;
    508         changeSource(e,b);
    509         e=f;
     480      nodes[b.id].first_out=nodes[n.id].first_out;
     481      nodes[n.id].first_out=-1;
     482      for(int i=nodes[b.id].first_out; i!=-1; i=arcs[i].next_out) {
     483        arcs[i].source=b.id;
    510484      }
    511485      if (connect) addArc(n,b);
     
    515489    ///Split an arc.
    516490
    517     ///This function splits an arc. First a new node \c b is added to
    518     ///the digraph, then the original arc is re-targeted to \c
    519     ///b. Finally an arc from \c b to the original target is added.
    520     ///
     491    ///This function splits the given arc. First, a new node \c v is
     492    ///added to the digraph, then the target node of the original arc
     493    ///is set to \c v. Finally, an arc from \c v to the original target
     494    ///is added.
    521495    ///\return The newly created node.
     496    ///
     497    ///\note \c InArcIt iterators referencing the original arc are
     498    ///invalidated. Other iterators remain valid.
    522499    ///
    523500    ///\warning This functionality cannot be used together with the
    524501    ///Snapshot feature.
    525     Node split(Arc e) {
    526       Node b = addNode();
    527       addArc(b,target(e));
    528       changeTarget(e,b);
    529       return b;
    530     }
     502    Node split(Arc a) {
     503      Node v = addNode();
     504      addArc(v,target(a));
     505      changeTarget(a,v);
     506      return v;
     507    }
     508
     509    ///Clear the digraph.
     510
     511    ///This function erases all nodes and arcs from the digraph.
     512    ///
     513    void clear() {
     514      Parent::clear();
     515    }
     516
     517    /// Reserve memory for nodes.
     518
     519    /// Using this function, it is possible to avoid superfluous memory
     520    /// allocation: if you know that the digraph you want to build will
     521    /// be large (e.g. it will contain millions of nodes and/or arcs),
     522    /// then it is worth reserving space for this amount before starting
     523    /// to build the digraph.
     524    /// \sa reserveArc()
     525    void reserveNode(int n) { nodes.reserve(n); };
     526
     527    /// Reserve memory for arcs.
     528
     529    /// Using this function, it is possible to avoid superfluous memory
     530    /// allocation: if you know that the digraph you want to build will
     531    /// be large (e.g. it will contain millions of nodes and/or arcs),
     532    /// then it is worth reserving space for this amount before starting
     533    /// to build the digraph.
     534    /// \sa reserveNode()
     535    void reserveArc(int m) { arcs.reserve(m); };
    531536
    532537    /// \brief Class to make a snapshot of the digraph and restore
     
    538543    /// restore() function.
    539544    ///
    540     /// \warning Arc and node deletions and other modifications (e.g.
    541     /// contracting, splitting, reversing arcs or nodes) cannot be
     545    /// \note After a state is restored, you cannot restore a later state,
     546    /// i.e. you cannot add the removed nodes and arcs again using
     547    /// another Snapshot instance.
     548    ///
     549    /// \warning Node and arc deletions and other modifications (e.g.
     550    /// reversing, contracting, splitting arcs or nodes) cannot be
    542551    /// restored. These events invalidate the snapshot.
     552    /// However the arcs and nodes that were added to the digraph after
     553    /// making the current snapshot can be removed without invalidating it.
    543554    class Snapshot {
    544555    protected:
     
    710721      ///
    711722      /// Default constructor.
    712       /// To actually make a snapshot you must call save().
     723      /// You have to call save() to actually make a snapshot.
    713724      Snapshot()
    714725        : digraph(0), node_observer_proxy(*this),
     
    717728      /// \brief Constructor that immediately makes a snapshot.
    718729      ///
    719       /// This constructor immediately makes a snapshot of the digraph.
    720       /// \param _digraph The digraph we make a snapshot of.
    721       Snapshot(ListDigraph &_digraph)
     730      /// This constructor immediately makes a snapshot of the given digraph.
     731      Snapshot(ListDigraph &gr)
    722732        : node_observer_proxy(*this),
    723733          arc_observer_proxy(*this) {
    724         attach(_digraph);
     734        attach(gr);
    725735      }
    726736
    727737      /// \brief Make a snapshot.
    728738      ///
    729       /// Make a snapshot of the digraph.
    730       ///
    731       /// This function can be called more than once. In case of a repeated
     739      /// This function makes a snapshot of the given digraph.
     740      /// It can be called more than once. In case of a repeated
    732741      /// call, the previous snapshot gets lost.
    733       /// \param _digraph The digraph we make the snapshot of.
    734       void save(ListDigraph &_digraph) {
     742      void save(ListDigraph &gr) {
    735743        if (attached()) {
    736744          detach();
    737745          clear();
    738746        }
    739         attach(_digraph);
     747        attach(gr);
    740748      }
    741749
    742750      /// \brief Undo the changes until the last snapshot.
    743       //
    744       /// Undo the changes until the last snapshot created by save().
     751      ///
     752      /// This function undos the changes until the last snapshot
     753      /// created by save() or Snapshot(ListDigraph&).
     754      ///
     755      /// \warning This method invalidates the snapshot, i.e. repeated
     756      /// restoring is not supported unless you call save() again.
    745757      void restore() {
    746758        detach();
     
    756768      }
    757769
    758       /// \brief Gives back true when the snapshot is valid.
     770      /// \brief Returns \c true if the snapshot is valid.
    759771      ///
    760       /// Gives back true when the snapshot is valid.
     772      /// This function returns \c true if the snapshot is valid.
    761773      bool valid() const {
    762774        return attached();
     
    795807
    796808    typedef ListGraphBase Graph;
    797 
    798     class Node;
    799     class Arc;
    800     class Edge;
    801809
    802810    class Node {
     
    848856      bool operator<(const Arc& arc) const {return id < arc.id;}
    849857    };
    850 
    851 
    852858
    853859    ListGraphBase()
     
    11651171  ///A general undirected graph structure.
    11661172
    1167   ///\ref ListGraph is a simple and fast <em>undirected graph</em>
    1168   ///implementation based on static linked lists that are stored in
     1173  ///\ref ListGraph is a versatile and fast undirected graph
     1174  ///implementation based on linked lists that are stored in
    11691175  ///\c std::vector structures.
    11701176  ///
    1171   ///It conforms to the \ref concepts::Graph "Graph concept" and it
    1172   ///also provides several useful additional functionalities.
    1173   ///Most of the member functions and nested classes are documented
     1177  ///This type fully conforms to the \ref concepts::Graph "Graph concept"
     1178  ///and it also provides several useful additional functionalities.
     1179  ///Most of its member functions and nested classes are documented
    11741180  ///only in the concept class.
    11751181  ///
    11761182  ///\sa concepts::Graph
    1177 
     1183  ///\sa ListDigraph
    11781184  class ListGraph : public ExtendedListGraphBase {
    11791185    typedef ExtendedListGraphBase Parent;
    11801186
    11811187  private:
    1182     ///ListGraph is \e not copy constructible. Use copyGraph() instead.
    1183 
    1184     ///ListGraph is \e not copy constructible. Use copyGraph() instead.
    1185     ///
     1188    /// Graphs are \e not copy constructible. Use GraphCopy instead.
    11861189    ListGraph(const ListGraph &) :ExtendedListGraphBase()  {};
    1187     ///\brief Assignment of ListGraph to another one is \e not allowed.
    1188     ///Use copyGraph() instead.
    1189 
    1190     ///Assignment of ListGraph to another one is \e not allowed.
    1191     ///Use copyGraph() instead.
     1190    /// \brief Assignment of a graph to another one is \e not allowed.
     1191    /// Use GraphCopy instead.
    11921192    void operator=(const ListGraph &) {}
    11931193  public:
     
    12021202    /// \brief Add a new node to the graph.
    12031203    ///
    1204     /// Add a new node to the graph.
     1204    /// This function adds a new node to the graph.
    12051205    /// \return The new node.
    12061206    Node addNode() { return Parent::addNode(); }
     
    12081208    /// \brief Add a new edge to the graph.
    12091209    ///
    1210     /// Add a new edge to the graph with source node \c s
    1211     /// and target node \c t.
     1210    /// This function adds a new edge to the graph between nodes
     1211    /// \c u and \c v with inherent orientation from node \c u to
     1212    /// node \c v.
    12121213    /// \return The new edge.
    1213     Edge addEdge(const Node& s, const Node& t) {
    1214       return Parent::addEdge(s, t);
    1215     }
    1216 
    1217     /// \brief Erase a node from the graph.
    1218     ///
    1219     /// Erase a node from the graph.
    1220     ///
    1221     void erase(const Node& n) { Parent::erase(n); }
    1222 
    1223     /// \brief Erase an edge from the graph.
    1224     ///
    1225     /// Erase an edge from the graph.
    1226     ///
    1227     void erase(const Edge& e) { Parent::erase(e); }
     1214    Edge addEdge(Node u, Node v) {
     1215      return Parent::addEdge(u, v);
     1216    }
     1217
     1218    ///\brief Erase a node from the graph.
     1219    ///
     1220    /// This function erases the given node from the graph.
     1221    void erase(Node n) { Parent::erase(n); }
     1222
     1223    ///\brief Erase an edge from the graph.
     1224    ///
     1225    /// This function erases the given edge from the graph.
     1226    void erase(Edge e) { Parent::erase(e); }
    12281227    /// Node validity check
    12291228
    1230     /// This function gives back true if the given node is valid,
    1231     /// ie. it is a real node of the graph.
    1232     ///
    1233     /// \warning A Node pointing to a removed item
    1234     /// could become valid again later if new nodes are
     1229    /// This function gives back \c true if the given node is valid,
     1230    /// i.e. it is a real node of the graph.
     1231    ///
     1232    /// \warning A removed node could become valid again if new nodes are
    12351233    /// added to the graph.
    12361234    bool valid(Node n) const { return Parent::valid(n); }
     1235    /// Edge validity check
     1236
     1237    /// This function gives back \c true if the given edge is valid,
     1238    /// i.e. it is a real edge of the graph.
     1239    ///
     1240    /// \warning A removed edge could become valid again if new edges are
     1241    /// added to the graph.
     1242    bool valid(Edge e) const { return Parent::valid(e); }
    12371243    /// Arc validity check
    12381244
    1239     /// This function gives back true if the given arc is valid,
    1240     /// ie. it is a real arc of the graph.
    1241     ///
    1242     /// \warning An Arc pointing to a removed item
    1243     /// could become valid again later if new edges are
     1245    /// This function gives back \c true if the given arc is valid,
     1246    /// i.e. it is a real arc of the graph.
     1247    ///
     1248    /// \warning A removed arc could become valid again if new edges are
    12441249    /// added to the graph.
    12451250    bool valid(Arc a) const { return Parent::valid(a); }
    1246     /// Edge validity check
    1247 
    1248     /// This function gives back true if the given edge is valid,
    1249     /// ie. it is a real arc of the graph.
    1250     ///
    1251     /// \warning A Edge pointing to a removed item
    1252     /// could become valid again later if new edges are
    1253     /// added to the graph.
    1254     bool valid(Edge e) const { return Parent::valid(e); }
    1255     /// \brief Change the end \c u of \c e to \c n
    1256     ///
    1257     /// This function changes the end \c u of \c e to node \c n.
    1258     ///
    1259     ///\note The <tt>EdgeIt</tt>s and <tt>ArcIt</tt>s referencing the
    1260     ///changed edge are invalidated and if the changed node is the
    1261     ///base node of an iterator then this iterator is also
    1262     ///invalidated.
     1251
     1252    /// \brief Change the first node of an edge.
     1253    ///
     1254    /// This function changes the first node of the given edge \c e to \c n.
     1255    ///
     1256    ///\note \c EdgeIt and \c ArcIt iterators referencing the
     1257    ///changed edge are invalidated and all other iterators whose
     1258    ///base node is the changed node are also invalidated.
    12631259    ///
    12641260    ///\warning This functionality cannot be used together with the
     
    12671263      Parent::changeU(e,n);
    12681264    }
    1269     /// \brief Change the end \c v of \c e to \c n
    1270     ///
    1271     /// This function changes the end \c v of \c e to \c n.
    1272     ///
    1273     ///\note The <tt>EdgeIt</tt>s referencing the changed edge remain
    1274     ///valid, however <tt>ArcIt</tt>s and if the changed node is the
    1275     ///base node of an iterator then this iterator is invalidated.
     1265    /// \brief Change the second node of an edge.
     1266    ///
     1267    /// This function changes the second node of the given edge \c e to \c n.
     1268    ///
     1269    ///\note \c EdgeIt iterators referencing the changed edge remain
     1270    ///valid, however \c ArcIt iterators referencing the changed edge and
     1271    ///all other iterators whose base node is the changed node are also
     1272    ///invalidated.
    12761273    ///
    12771274    ///\warning This functionality cannot be used together with the
     
    12801277      Parent::changeV(e,n);
    12811278    }
     1279
    12821280    /// \brief Contract two nodes.
    12831281    ///
    1284     /// This function contracts two nodes.
    1285     /// Node \p b will be removed but instead of deleting
    1286     /// its neighboring arcs, they will be joined to \p a.
    1287     /// The last parameter \p r controls whether to remove loops. \c true
    1288     /// means that loops will be removed.
    1289     ///
    1290     /// \note The <tt>ArcIt</tt>s referencing a moved arc remain
    1291     /// valid.
     1282    /// This function contracts the given two nodes.
     1283    /// Node \c b is removed, but instead of deleting
     1284    /// its incident edges, they are joined to node \c a.
     1285    /// If the last parameter \c r is \c true (this is the default value),
     1286    /// then the newly created loops are removed.
     1287    ///
     1288    /// \note The moved edges are joined to node \c a using changeU()
     1289    /// or changeV(), thus all edge and arc iterators whose base node is
     1290    /// \c b are invalidated.
     1291    /// Moreover all iterators referencing node \c b or the removed
     1292    /// loops are also invalidated. Other iterators remain valid.
    12921293    ///
    12931294    ///\warning This functionality cannot be used together with the
     
    13081309    }
    13091310
     1311    ///Clear the graph.
     1312
     1313    ///This function erases all nodes and arcs from the graph.
     1314    ///
     1315    void clear() {
     1316      Parent::clear();
     1317    }
     1318
     1319    /// Reserve memory for nodes.
     1320
     1321    /// Using this function, it is possible to avoid superfluous memory
     1322    /// allocation: if you know that the graph you want to build will
     1323    /// be large (e.g. it will contain millions of nodes and/or edges),
     1324    /// then it is worth reserving space for this amount before starting
     1325    /// to build the graph.
     1326    /// \sa reserveEdge()
     1327    void reserveNode(int n) { nodes.reserve(n); };
     1328
     1329    /// Reserve memory for edges.
     1330
     1331    /// Using this function, it is possible to avoid superfluous memory
     1332    /// allocation: if you know that the graph you want to build will
     1333    /// be large (e.g. it will contain millions of nodes and/or edges),
     1334    /// then it is worth reserving space for this amount before starting
     1335    /// to build the graph.
     1336    /// \sa reserveNode()
     1337    void reserveEdge(int m) { arcs.reserve(2 * m); };
    13101338
    13111339    /// \brief Class to make a snapshot of the graph and restore
     
    13171345    /// using the restore() function.
    13181346    ///
    1319     /// \warning Edge and node deletions and other modifications
    1320     /// (e.g. changing nodes of edges, contracting nodes) cannot be
    1321     /// restored. These events invalidate the snapshot.
     1347    /// \note After a state is restored, you cannot restore a later state,
     1348    /// i.e. you cannot add the removed nodes and edges again using
     1349    /// another Snapshot instance.
     1350    ///
     1351    /// \warning Node and edge deletions and other modifications
     1352    /// (e.g. changing the end-nodes of edges or contracting nodes)
     1353    /// cannot be restored. These events invalidate the snapshot.
     1354    /// However the edges and nodes that were added to the graph after
     1355    /// making the current snapshot can be removed without invalidating it.
    13221356    class Snapshot {
    13231357    protected:
     
    14891523      ///
    14901524      /// Default constructor.
    1491       /// To actually make a snapshot you must call save().
     1525      /// You have to call save() to actually make a snapshot.
    14921526      Snapshot()
    14931527        : graph(0), node_observer_proxy(*this),
     
    14961530      /// \brief Constructor that immediately makes a snapshot.
    14971531      ///
    1498       /// This constructor immediately makes a snapshot of the graph.
    1499       /// \param _graph The graph we make a snapshot of.
    1500       Snapshot(ListGraph &_graph)
     1532      /// This constructor immediately makes a snapshot of the given graph.
     1533      Snapshot(ListGraph &gr)
    15011534        : node_observer_proxy(*this),
    15021535          edge_observer_proxy(*this) {
    1503         attach(_graph);
     1536        attach(gr);
    15041537      }
    15051538
    15061539      /// \brief Make a snapshot.
    15071540      ///
    1508       /// Make a snapshot of the graph.
    1509       ///
    1510       /// This function can be called more than once. In case of a repeated
     1541      /// This function makes a snapshot of the given graph.
     1542      /// It can be called more than once. In case of a repeated
    15111543      /// call, the previous snapshot gets lost.
    1512       /// \param _graph The graph we make the snapshot of.
    1513       void save(ListGraph &_graph) {
     1544      void save(ListGraph &gr) {
    15141545        if (attached()) {
    15151546          detach();
    15161547          clear();
    15171548        }
    1518         attach(_graph);
     1549        attach(gr);
    15191550      }
    15201551
    15211552      /// \brief Undo the changes until the last snapshot.
    1522       //
    1523       /// Undo the changes until the last snapshot created by save().
     1553      ///
     1554      /// This function undos the changes until the last snapshot
     1555      /// created by save() or Snapshot(ListGraph&).
     1556      ///
     1557      /// \warning This method invalidates the snapshot, i.e. repeated
     1558      /// restoring is not supported unless you call save() again.
    15241559      void restore() {
    15251560        detach();
     
    15351570      }
    15361571
    1537       /// \brief Gives back true when the snapshot is valid.
     1572      /// \brief Returns \c true if the snapshot is valid.
    15381573      ///
    1539       /// Gives back true when the snapshot is valid.
     1574      /// This function returns \c true if the snapshot is valid.
    15401575      bool valid() const {
    15411576        return attached();
  • lemon/lp_base.h

    r631 r793  
    944944    virtual int _addRow() = 0;
    945945
     946    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u) {
     947      int row = _addRow();
     948      _setRowCoeffs(row, b, e);
     949      _setRowLowerBound(row, l);
     950      _setRowUpperBound(row, u);
     951      return row;
     952    }
     953
    946954    virtual void _eraseCol(int col) = 0;
    947955    virtual void _eraseRow(int row) = 0;
     
    12081216    ///\return The created row.
    12091217    Row addRow(Value l,const Expr &e, Value u) {
    1210       Row r=addRow();
    1211       row(r,l,e,u);
     1218      Row r;
     1219      e.simplify();
     1220      r._id = _addRowId(_addRow(l - *e, ExprIterator(e.comps.begin(), cols),
     1221                                ExprIterator(e.comps.end(), cols), u - *e));
    12121222      return r;
    12131223    }
     
    12181228    ///\return The created row.
    12191229    Row addRow(const Constr &c) {
    1220       Row r=addRow();
    1221       row(r,c);
     1230      Row r;
     1231      c.expr().simplify();
     1232      r._id = _addRowId(_addRow(c.lowerBounded()?c.lowerBound():-INF,
     1233                                ExprIterator(c.expr().comps.begin(), cols),
     1234                                ExprIterator(c.expr().comps.end(), cols),
     1235                                c.upperBounded()?c.upperBound():INF));
    12221236      return r;
    12231237    }
  • lemon/lp_skeleton.cc

    r623 r793  
    2929
    3030  int SkeletonSolverBase::_addRow()
     31  {
     32    return ++row_num;
     33  }
     34
     35  int SkeletonSolverBase::_addRow(Value, ExprIterator, ExprIterator, Value)
    3136  {
    3237    return ++row_num;
  • lemon/lp_skeleton.h

    r623 r793  
    4545    /// \e
    4646    virtual int _addRow();
     47    /// \e
     48    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
    4749    /// \e
    4850    virtual void _eraseCol(int i);
  • lemon/network_simplex.h

    r777 r802  
    4141  ///
    4242  /// \ref NetworkSimplex implements the primal Network Simplex algorithm
    43   /// for finding a \ref min_cost_flow "minimum cost flow".
     43  /// for finding a \ref min_cost_flow "minimum cost flow"
     44  /// \ref amo93networkflows, \ref dantzig63linearprog,
     45  /// \ref kellyoneill91netsimplex.
    4446  /// This algorithm is a specialized version of the linear programming
    4547  /// simplex method directly for the minimum cost flow problem.
  • lemon/path.h

    r606 r798  
    10161016  /// \brief The source of a path
    10171017  ///
    1018   /// This function returns the source of the given path.
     1018  /// This function returns the source node of the given path.
     1019  /// If the path is empty, then it returns \c INVALID.
    10191020  template <typename Digraph, typename Path>
    10201021  typename Digraph::Node pathSource(const Digraph& digraph, const Path& path) {
    1021     return digraph.source(path.front());
     1022    return path.empty() ? INVALID : digraph.source(path.front());
    10221023  }
    10231024
    10241025  /// \brief The target of a path
    10251026  ///
    1026   /// This function returns the target of the given path.
     1027  /// This function returns the target node of the given path.
     1028  /// If the path is empty, then it returns \c INVALID.
    10271029  template <typename Digraph, typename Path>
    10281030  typename Digraph::Node pathTarget(const Digraph& digraph, const Path& path) {
    1029     return digraph.target(path.back());
     1031    return path.empty() ? INVALID : digraph.target(path.back());
    10301032  }
    10311033
  • lemon/preflow.h

    r762 r802  
    103103  /// This class provides an implementation of Goldberg-Tarjan's \e preflow
    104104  /// \e push-relabel algorithm producing a \ref max_flow
    105   /// "flow of maximum value" in a digraph.
     105  /// "flow of maximum value" in a digraph \ref clrs01algorithms,
     106  /// \ref amo93networkflows, \ref goldberg88newapproach.
    106107  /// The preflow algorithms are the fastest known maximum
    107108  /// flow algorithms. The current implementation uses a mixture of the
  • lemon/smart_graph.h

    r664 r827  
    3333
    3434  class SmartDigraph;
    35   ///Base of SmartDigraph
    36 
    37   ///Base of SmartDigraph
    38   ///
     35
    3936  class SmartDigraphBase {
    4037  protected:
     
    188185  ///\brief A smart directed graph class.
    189186  ///
    190   ///This is a simple and fast digraph implementation.
    191   ///It is also quite memory efficient, but at the price
    192   ///that <b> it does support only limited (only stack-like)
    193   ///node and arc deletions</b>.
    194   ///It fully conforms to the \ref concepts::Digraph "Digraph concept".
     187  ///\ref SmartDigraph is a simple and fast digraph implementation.
     188  ///It is also quite memory efficient but at the price
     189  ///that it does not support node and arc deletion
     190  ///(except for the Snapshot feature).
    195191  ///
    196   ///\sa concepts::Digraph.
     192  ///This type fully conforms to the \ref concepts::Digraph "Digraph concept"
     193  ///and it also provides some additional functionalities.
     194  ///Most of its member functions and nested classes are documented
     195  ///only in the concept class.
     196  ///
     197  ///\sa concepts::Digraph
     198  ///\sa SmartGraph
    197199  class SmartDigraph : public ExtendedSmartDigraphBase {
    198200    typedef ExtendedSmartDigraphBase Parent;
    199201
    200202  private:
    201 
    202     ///SmartDigraph is \e not copy constructible. Use DigraphCopy() instead.
    203 
    204     ///SmartDigraph is \e not copy constructible. Use DigraphCopy() instead.
    205     ///
     203    /// Digraphs are \e not copy constructible. Use DigraphCopy instead.
    206204    SmartDigraph(const SmartDigraph &) : ExtendedSmartDigraphBase() {};
    207     ///\brief Assignment of SmartDigraph to another one is \e not allowed.
    208     ///Use DigraphCopy() instead.
    209 
    210     ///Assignment of SmartDigraph to another one is \e not allowed.
    211     ///Use DigraphCopy() instead.
     205    /// \brief Assignment of a digraph to another one is \e not allowed.
     206    /// Use DigraphCopy instead.
    212207    void operator=(const SmartDigraph &) {}
    213208
     
    222217    ///Add a new node to the digraph.
    223218
    224     /// Add a new node to the digraph.
    225     /// \return The new node.
     219    ///This function adds a new node to the digraph.
     220    ///\return The new node.
    226221    Node addNode() { return Parent::addNode(); }
    227222
    228223    ///Add a new arc to the digraph.
    229224
    230     ///Add a new arc to the digraph with source node \c s
     225    ///This function adds a new arc to the digraph with source node \c s
    231226    ///and target node \c t.
    232227    ///\return The new arc.
    233     Arc addArc(const Node& s, const Node& t) {
     228    Arc addArc(Node s, Node t) {
    234229      return Parent::addArc(s, t);
    235230    }
    236231
    237     /// \brief Using this it is possible to avoid the superfluous memory
    238     /// allocation.
    239 
    240     /// Using this it is possible to avoid the superfluous memory
    241     /// allocation: if you know that the digraph you want to build will
    242     /// be very large (e.g. it will contain millions of nodes and/or arcs)
    243     /// then it is worth reserving space for this amount before starting
    244     /// to build the digraph.
    245     /// \sa reserveArc
    246     void reserveNode(int n) { nodes.reserve(n); };
    247 
    248     /// \brief Using this it is possible to avoid the superfluous memory
    249     /// allocation.
    250 
    251     /// Using this it is possible to avoid the superfluous memory
    252     /// allocation: if you know that the digraph you want to build will
    253     /// be very large (e.g. it will contain millions of nodes and/or arcs)
    254     /// then it is worth reserving space for this amount before starting
    255     /// to build the digraph.
    256     /// \sa reserveNode
    257     void reserveArc(int m) { arcs.reserve(m); };
    258 
    259232    /// \brief Node validity check
    260233    ///
    261     /// This function gives back true if the given node is valid,
    262     /// ie. it is a real node of the graph.
     234    /// This function gives back \c true if the given node is valid,
     235    /// i.e. it is a real node of the digraph.
    263236    ///
    264237    /// \warning A removed node (using Snapshot) could become valid again
    265     /// when new nodes are added to the graph.
     238    /// if new nodes are added to the digraph.
    266239    bool valid(Node n) const { return Parent::valid(n); }
    267240
    268241    /// \brief Arc validity check
    269242    ///
    270     /// This function gives back true if the given arc is valid,
    271     /// ie. it is a real arc of the graph.
     243    /// This function gives back \c true if the given arc is valid,
     244    /// i.e. it is a real arc of the digraph.
    272245    ///
    273246    /// \warning A removed arc (using Snapshot) could become valid again
    274     /// when new arcs are added to the graph.
     247    /// if new arcs are added to the graph.
    275248    bool valid(Arc a) const { return Parent::valid(a); }
    276249
    277     ///Clear the digraph.
    278 
    279     ///Erase all the nodes and arcs from the digraph.
    280     ///
    281     void clear() {
    282       Parent::clear();
    283     }
    284 
    285250    ///Split a node.
    286251
    287     ///This function splits a node. First a new node is added to the digraph,
    288     ///then the source of each outgoing arc of \c n is moved to this new node.
    289     ///If \c connect is \c true (this is the default value), then a new arc
    290     ///from \c n to the newly created node is also added.
     252    ///This function splits the given node. First, a new node is added
     253    ///to the digraph, then the source of each outgoing arc of node \c n
     254    ///is moved to this new node.
     255    ///If the second parameter \c connect is \c true (this is the default
     256    ///value), then a new arc from node \c n to the newly created node
     257    ///is also added.
    291258    ///\return The newly created node.
    292259    ///
    293     ///\note The <tt>Arc</tt>s
    294     ///referencing a moved arc remain
    295     ///valid. However <tt>InArc</tt>'s and <tt>OutArc</tt>'s
    296     ///may be invalidated.
     260    ///\note All iterators remain valid.
     261    ///
    297262    ///\warning This functionality cannot be used together with the Snapshot
    298263    ///feature.
     
    309274    }
    310275
     276    ///Clear the digraph.
     277
     278    ///This function erases all nodes and arcs from the digraph.
     279    ///
     280    void clear() {
     281      Parent::clear();
     282    }
     283
     284    /// Reserve memory for nodes.
     285
     286    /// Using this function, it is possible to avoid superfluous memory
     287    /// allocation: if you know that the digraph you want to build will
     288    /// be large (e.g. it will contain millions of nodes and/or arcs),
     289    /// then it is worth reserving space for this amount before starting
     290    /// to build the digraph.
     291    /// \sa reserveArc()
     292    void reserveNode(int n) { nodes.reserve(n); };
     293
     294    /// Reserve memory for arcs.
     295
     296    /// Using this function, it is possible to avoid superfluous memory
     297    /// allocation: if you know that the digraph you want to build will
     298    /// be large (e.g. it will contain millions of nodes and/or arcs),
     299    /// then it is worth reserving space for this amount before starting
     300    /// to build the digraph.
     301    /// \sa reserveNode()
     302    void reserveArc(int m) { arcs.reserve(m); };
     303
    311304  public:
    312305
     
    333326  public:
    334327
    335     ///Class to make a snapshot of the digraph and to restrore to it later.
    336 
    337     ///Class to make a snapshot of the digraph and to restrore to it later.
     328    ///Class to make a snapshot of the digraph and to restore it later.
     329
     330    ///Class to make a snapshot of the digraph and to restore it later.
    338331    ///
    339332    ///The newly added nodes and arcs can be removed using the
    340     ///restore() function.
    341     ///\note After you restore a state, you cannot restore
    342     ///a later state, in other word you cannot add again the arcs deleted
    343     ///by restore() using another one Snapshot instance.
    344     ///
    345     ///\warning If you do not use correctly the snapshot that can cause
    346     ///either broken program, invalid state of the digraph, valid but
    347     ///not the restored digraph or no change. Because the runtime performance
    348     ///the validity of the snapshot is not stored.
     333    ///restore() function. This is the only way for deleting nodes and/or
     334    ///arcs from a SmartDigraph structure.
     335    ///
     336    ///\note After a state is restored, you cannot restore a later state,
     337    ///i.e. you cannot add the removed nodes and arcs again using
     338    ///another Snapshot instance.
     339    ///
     340    ///\warning Node splitting cannot be restored.
     341    ///\warning The validity of the snapshot is not stored due to
     342    ///performance reasons. If you do not use the snapshot correctly,
     343    ///it can cause broken program, invalid or not restored state of
     344    ///the digraph or no change.
    349345    class Snapshot
    350346    {
     
    358354
    359355      ///Default constructor.
    360       ///To actually make a snapshot you must call save().
    361       ///
     356      ///You have to call save() to actually make a snapshot.
    362357      Snapshot() : _graph(0) {}
    363358      ///Constructor that immediately makes a snapshot
    364359
    365       ///This constructor immediately makes a snapshot of the digraph.
    366       ///\param graph The digraph we make a snapshot of.
    367       Snapshot(SmartDigraph &graph) : _graph(&graph) {
     360      ///This constructor immediately makes a snapshot of the given digraph.
     361      ///
     362      Snapshot(SmartDigraph &gr) : _graph(&gr) {
    368363        node_num=_graph->nodes.size();
    369364        arc_num=_graph->arcs.size();
     
    372367      ///Make a snapshot.
    373368
    374       ///Make a snapshot of the digraph.
    375       ///
    376       ///This function can be called more than once. In case of a repeated
     369      ///This function makes a snapshot of the given digraph.
     370      ///It can be called more than once. In case of a repeated
    377371      ///call, the previous snapshot gets lost.
    378       ///\param graph The digraph we make the snapshot of.
    379       void save(SmartDigraph &graph)
    380       {
    381         _graph=&graph;
     372      void save(SmartDigraph &gr) {
     373        _graph=&gr;
    382374        node_num=_graph->nodes.size();
    383375        arc_num=_graph->arcs.size();
     
    386378      ///Undo the changes until a snapshot.
    387379
    388       ///Undo the changes until a snapshot created by save().
    389       ///
    390       ///\note After you restored a state, you cannot restore
    391       ///a later state, in other word you cannot add again the arcs deleted
    392       ///by restore().
     380      ///This function undos the changes until the last snapshot
     381      ///created by save() or Snapshot(SmartDigraph&).
    393382      void restore()
    394383      {
     
    509498    }
    510499
    511     void next(Node& node) const {
     500    static void next(Node& node) {
    512501      --node._id;
    513502    }
     
    517506    }
    518507
    519     void next(Arc& arc) const {
     508    static void next(Arc& arc) {
    520509      --arc._id;
    521510    }
     
    525514    }
    526515
    527     void next(Edge& arc) const {
     516    static void next(Edge& arc) {
    528517      --arc._id;
    529518    }
     
    622611  /// \brief A smart undirected graph class.
    623612  ///
    624   /// This is a simple and fast graph implementation.
    625   /// It is also quite memory efficient, but at the price
    626   /// that <b> it does support only limited (only stack-like)
    627   /// node and arc deletions</b>.
    628   /// It fully conforms to the \ref concepts::Graph "Graph concept".
     613  /// \ref SmartGraph is a simple and fast graph implementation.
     614  /// It is also quite memory efficient but at the price
     615  /// that it does not support node and edge deletion
     616  /// (except for the Snapshot feature).
    629617  ///
    630   /// \sa concepts::Graph.
     618  /// This type fully conforms to the \ref concepts::Graph "Graph concept"
     619  /// and it also provides some additional functionalities.
     620  /// Most of its member functions and nested classes are documented
     621  /// only in the concept class.
     622  ///
     623  /// \sa concepts::Graph
     624  /// \sa SmartDigraph
    631625  class SmartGraph : public ExtendedSmartGraphBase {
    632626    typedef ExtendedSmartGraphBase Parent;
    633627
    634628  private:
    635 
    636     ///SmartGraph is \e not copy constructible. Use GraphCopy() instead.
    637 
    638     ///SmartGraph is \e not copy constructible. Use GraphCopy() instead.
    639     ///
     629    /// Graphs are \e not copy constructible. Use GraphCopy instead.
    640630    SmartGraph(const SmartGraph &) : ExtendedSmartGraphBase() {};
    641 
    642     ///\brief Assignment of SmartGraph to another one is \e not allowed.
    643     ///Use GraphCopy() instead.
    644 
    645     ///Assignment of SmartGraph to another one is \e not allowed.
    646     ///Use GraphCopy() instead.
     631    /// \brief Assignment of a graph to another one is \e not allowed.
     632    /// Use GraphCopy instead.
    647633    void operator=(const SmartGraph &) {}
    648634
     
    655641    SmartGraph() {}
    656642
    657     ///Add a new node to the graph.
    658 
    659     /// Add a new node to the graph.
     643    /// \brief Add a new node to the graph.
     644    ///
     645    /// This function adds a new node to the graph.
    660646    /// \return The new node.
    661647    Node addNode() { return Parent::addNode(); }
    662648
    663     ///Add a new edge to the graph.
    664 
    665     ///Add a new edge to the graph with node \c s
    666     ///and \c t.
    667     ///\return The new edge.
    668     Edge addEdge(const Node& s, const Node& t) {
    669       return Parent::addEdge(s, t);
     649    /// \brief Add a new edge to the graph.
     650    ///
     651    /// This function adds a new edge to the graph between nodes
     652    /// \c u and \c v with inherent orientation from node \c u to
     653    /// node \c v.
     654    /// \return The new edge.
     655    Edge addEdge(Node u, Node v) {
     656      return Parent::addEdge(u, v);
    670657    }
    671658
    672659    /// \brief Node validity check
    673660    ///
    674     /// This function gives back true if the given node is valid,
    675     /// ie. it is a real node of the graph.
     661    /// This function gives back \c true if the given node is valid,
     662    /// i.e. it is a real node of the graph.
    676663    ///
    677664    /// \warning A removed node (using Snapshot) could become valid again
    678     /// when new nodes are added to the graph.
     665    /// if new nodes are added to the graph.
    679666    bool valid(Node n) const { return Parent::valid(n); }
    680667
     668    /// \brief Edge validity check
     669    ///
     670    /// This function gives back \c true if the given edge is valid,
     671    /// i.e. it is a real edge of the graph.
     672    ///
     673    /// \warning A removed edge (using Snapshot) could become valid again
     674    /// if new edges are added to the graph.
     675    bool valid(Edge e) const { return Parent::valid(e); }
     676
    681677    /// \brief Arc validity check
    682678    ///
    683     /// This function gives back true if the given arc is valid,
    684     /// ie. it is a real arc of the graph.
     679    /// This function gives back \c true if the given arc is valid,
     680    /// i.e. it is a real arc of the graph.
    685681    ///
    686682    /// \warning A removed arc (using Snapshot) could become valid again
    687     /// when new edges are added to the graph.
     683    /// if new edges are added to the graph.
    688684    bool valid(Arc a) const { return Parent::valid(a); }
    689685
    690     /// \brief Edge validity check
    691     ///
    692     /// This function gives back true if the given edge is valid,
    693     /// ie. it is a real edge of the graph.
    694     ///
    695     /// \warning A removed edge (using Snapshot) could become valid again
    696     /// when new edges are added to the graph.
    697     bool valid(Edge e) const { return Parent::valid(e); }
    698 
    699686    ///Clear the graph.
    700687
    701     ///Erase all the nodes and edges from the graph.
     688    ///This function erases all nodes and arcs from the graph.
    702689    ///
    703690    void clear() {
    704691      Parent::clear();
    705692    }
     693
     694    /// Reserve memory for nodes.
     695
     696    /// Using this function, it is possible to avoid superfluous memory
     697    /// allocation: if you know that the graph you want to build will
     698    /// be large (e.g. it will contain millions of nodes and/or edges),
     699    /// then it is worth reserving space for this amount before starting
     700    /// to build the graph.
     701    /// \sa reserveEdge()
     702    void reserveNode(int n) { nodes.reserve(n); };
     703
     704    /// Reserve memory for edges.
     705
     706    /// Using this function, it is possible to avoid superfluous memory
     707    /// allocation: if you know that the graph you want to build will
     708    /// be large (e.g. it will contain millions of nodes and/or edges),
     709    /// then it is worth reserving space for this amount before starting
     710    /// to build the graph.
     711    /// \sa reserveNode()
     712    void reserveEdge(int m) { arcs.reserve(2 * m); };
    706713
    707714  public:
     
    743750  public:
    744751
    745     ///Class to make a snapshot of the digraph and to restrore to it later.
    746 
    747     ///Class to make a snapshot of the digraph and to restrore to it later.
    748     ///
    749     ///The newly added nodes and arcs can be removed using the
    750     ///restore() function.
    751     ///
    752     ///\note After you restore a state, you cannot restore
    753     ///a later state, in other word you cannot add again the arcs deleted
    754     ///by restore() using another one Snapshot instance.
    755     ///
    756     ///\warning If you do not use correctly the snapshot that can cause
    757     ///either broken program, invalid state of the digraph, valid but
    758     ///not the restored digraph or no change. Because the runtime performance
    759     ///the validity of the snapshot is not stored.
     752    ///Class to make a snapshot of the graph and to restore it later.
     753
     754    ///Class to make a snapshot of the graph and to restore it later.
     755    ///
     756    ///The newly added nodes and edges can be removed using the
     757    ///restore() function. This is the only way for deleting nodes and/or
     758    ///edges from a SmartGraph structure.
     759    ///
     760    ///\note After a state is restored, you cannot restore a later state,
     761    ///i.e. you cannot add the removed nodes and edges again using
     762    ///another Snapshot instance.
     763    ///
     764    ///\warning The validity of the snapshot is not stored due to
     765    ///performance reasons. If you do not use the snapshot correctly,
     766    ///it can cause broken program, invalid or not restored state of
     767    ///the graph or no change.
    760768    class Snapshot
    761769    {
     
    769777
    770778      ///Default constructor.
    771       ///To actually make a snapshot you must call save().
    772       ///
     779      ///You have to call save() to actually make a snapshot.
    773780      Snapshot() : _graph(0) {}
    774781      ///Constructor that immediately makes a snapshot
    775782
    776       ///This constructor immediately makes a snapshot of the digraph.
    777       ///\param graph The digraph we make a snapshot of.
    778       Snapshot(SmartGraph &graph) {
    779         graph.saveSnapshot(*this);
     783      /// This constructor immediately makes a snapshot of the given graph.
     784      ///
     785      Snapshot(SmartGraph &gr) {
     786        gr.saveSnapshot(*this);
    780787      }
    781788
    782789      ///Make a snapshot.
    783790
    784       ///Make a snapshot of the graph.
    785       ///
    786       ///This function can be called more than once. In case of a repeated
     791      ///This function makes a snapshot of the given graph.
     792      ///It can be called more than once. In case of a repeated
    787793      ///call, the previous snapshot gets lost.
    788       ///\param graph The digraph we make the snapshot of.
    789       void save(SmartGraph &graph)
     794      void save(SmartGraph &gr)
    790795      {
    791         graph.saveSnapshot(*this);
    792       }
    793 
    794       ///Undo the changes until a snapshot.
    795 
    796       ///Undo the changes until a snapshot created by save().
    797       ///
    798       ///\note After you restored a state, you cannot restore
    799       ///a later state, in other word you cannot add again the arcs deleted
    800       ///by restore().
     796        gr.saveSnapshot(*this);
     797      }
     798
     799      ///Undo the changes until the last snapshot.
     800
     801      ///This function undos the changes until the last snapshot
     802      ///created by save() or Snapshot(SmartGraph&).
    801803      void restore()
    802804      {
  • lemon/soplex.cc

    r623 r793  
    9292  }
    9393
     94  int SoplexLp::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) {
     95    soplex::DSVector v;
     96    for (ExprIterator it = b; it != e; ++it) {
     97      v.add(it->first, it->second);
     98    }
     99    soplex::LPRow r(l, v, u);
     100    soplex->addRow(r);
     101
     102    _row_names.push_back(std::string());
     103
     104    return soplex->nRows() - 1;
     105  }
     106
    94107
    95108  void SoplexLp::_eraseCol(int i) {
  • lemon/soplex.h

    r623 r793  
    8585    virtual int _addCol();
    8686    virtual int _addRow();
     87    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
    8788
    8889    virtual void _eraseCol(int i);
  • m4/lx_check_coin.m4

    r674 r796  
    8989        CBC_LDFLAGS="-L$with_coin/lib"
    9090      fi
    91       CBC_LIBS="-lOsi -lCbc -lOsiCbc -lCbcSolver -lClp -lOsiClp -lCoinUtils -lVol -lOsiVol -lCgl -lm -llapack -lblas"
     91      CBC_LIBS="-lOsi -lCbc -lCbcSolver -lClp -lOsiClp -lCoinUtils -lVol -lOsiVol -lCgl -lm -llapack -lblas"
    9292
    9393      lx_save_cxxflags="$CXXFLAGS"
  • scripts/chg-len.py

    r439 r780  
    11#! /usr/bin/env python
     2#
     3# This file is a part of LEMON, a generic C++ optimization library.
     4#
     5# Copyright (C) 2003-2009
     6# Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7# (Egervary Research Group on Combinatorial Optimization, EGRES).
     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.
    216
    317import sys
  • scripts/mk-release.sh

    r611 r780  
    11#!/bin/bash
     2#
     3# This file is a part of LEMON, a generic C++ optimization library.
     4#
     5# Copyright (C) 2003-2009
     6# Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7# (Egervary Research Group on Combinatorial Optimization, EGRES).
     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.
    216
    317set -e
  • scripts/unify-sources.sh

    r702 r780  
    11#!/bin/bash
     2#
     3# This file is a part of LEMON, a generic C++ optimization library.
     4#
     5# Copyright (C) 2003-2009
     6# Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7# (Egervary Research Group on Combinatorial Optimization, EGRES).
     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.
    216
    317YEAR=`date +%Y`
  • test/CMakeLists.txt

    r745 r817  
    3333  min_cost_arborescence_test
    3434  min_cost_flow_test
     35  min_mean_cycle_test
    3536  path_test
    3637  preflow_test
  • test/Makefile.am

    r745 r817  
    3131        test/min_cost_arborescence_test \
    3232        test/min_cost_flow_test \
     33        test/min_mean_cycle_test \
    3334        test/path_test \
    3435        test/preflow_test \
     
    7980test_min_cost_arborescence_test_SOURCES = test/min_cost_arborescence_test.cc
    8081test_min_cost_flow_test_SOURCES = test/min_cost_flow_test.cc
     82test_min_mean_cycle_test_SOURCES = test/min_mean_cycle_test.cc
    8183test_path_test_SOURCES = test/path_test.cc
    8284test_preflow_test_SOURCES = test/preflow_test.cc
  • test/digraph_test.cc

    r463 r827  
    2020#include <lemon/list_graph.h>
    2121#include <lemon/smart_graph.h>
     22#include <lemon/static_graph.h>
    2223#include <lemon/full_graph.h>
    2324
     
    3536  checkGraphNodeList(G, 0);
    3637  checkGraphArcList(G, 0);
     38
     39  G.reserveNode(3);
     40  G.reserveArc(4);
    3741
    3842  Node
     
    284288
    285289  snapshot.restore();
     290  snapshot.save(G);
     291
     292  checkGraphNodeList(G, 4);
     293  checkGraphArcList(G, 4);
     294
     295  G.addArc(G.addNode(), G.addNode());
     296
     297  snapshot.restore();
    286298
    287299  checkGraphNodeList(G, 4);
     
    318330    checkConcept<ClearableDigraphComponent<>, SmartDigraph>();
    319331  }
     332  { // Checking StaticDigraph
     333    checkConcept<Digraph, StaticDigraph>();
     334    checkConcept<ClearableDigraphComponent<>, StaticDigraph>();
     335  }
    320336  { // Checking FullDigraph
    321337    checkConcept<Digraph, FullDigraph>();
     
    373389}
    374390
     391void checkStaticDigraph() {
     392  SmartDigraph g;
     393  SmartDigraph::NodeMap<StaticDigraph::Node> nref(g);
     394  SmartDigraph::ArcMap<StaticDigraph::Arc> aref(g);
     395 
     396  StaticDigraph G;
     397 
     398  checkGraphNodeList(G, 0);
     399  checkGraphArcList(G, 0);
     400
     401  G.build(g, nref, aref);
     402
     403  checkGraphNodeList(G, 0);
     404  checkGraphArcList(G, 0);
     405
     406  SmartDigraph::Node
     407    n1 = g.addNode(),
     408    n2 = g.addNode(),
     409    n3 = g.addNode();
     410
     411  G.build(g, nref, aref);
     412
     413  checkGraphNodeList(G, 3);
     414  checkGraphArcList(G, 0);
     415
     416  SmartDigraph::Arc a1 = g.addArc(n1, n2);
     417
     418  G.build(g, nref, aref);
     419
     420  check(G.source(aref[a1]) == nref[n1] && G.target(aref[a1]) == nref[n2],
     421        "Wrong arc or wrong references");
     422  checkGraphNodeList(G, 3);
     423  checkGraphArcList(G, 1);
     424
     425  checkGraphOutArcList(G, nref[n1], 1);
     426  checkGraphOutArcList(G, nref[n2], 0);
     427  checkGraphOutArcList(G, nref[n3], 0);
     428
     429  checkGraphInArcList(G, nref[n1], 0);
     430  checkGraphInArcList(G, nref[n2], 1);
     431  checkGraphInArcList(G, nref[n3], 0);
     432
     433  checkGraphConArcList(G, 1);
     434
     435  SmartDigraph::Arc
     436    a2 = g.addArc(n2, n1),
     437    a3 = g.addArc(n2, n3),
     438    a4 = g.addArc(n2, n3);
     439
     440  digraphCopy(g, G).nodeRef(nref).run();
     441
     442  checkGraphNodeList(G, 3);
     443  checkGraphArcList(G, 4);
     444
     445  checkGraphOutArcList(G, nref[n1], 1);
     446  checkGraphOutArcList(G, nref[n2], 3);
     447  checkGraphOutArcList(G, nref[n3], 0);
     448
     449  checkGraphInArcList(G, nref[n1], 1);
     450  checkGraphInArcList(G, nref[n2], 1);
     451  checkGraphInArcList(G, nref[n3], 2);
     452
     453  checkGraphConArcList(G, 4);
     454
     455  std::vector<std::pair<int,int> > arcs;
     456  arcs.push_back(std::make_pair(0,1));
     457  arcs.push_back(std::make_pair(0,2));
     458  arcs.push_back(std::make_pair(1,3));
     459  arcs.push_back(std::make_pair(1,2));
     460  arcs.push_back(std::make_pair(3,0));
     461  arcs.push_back(std::make_pair(3,3));
     462  arcs.push_back(std::make_pair(4,2));
     463  arcs.push_back(std::make_pair(4,3));
     464  arcs.push_back(std::make_pair(4,1));
     465
     466  G.build(6, arcs.begin(), arcs.end());
     467 
     468  checkGraphNodeList(G, 6);
     469  checkGraphArcList(G, 9);
     470
     471  checkGraphOutArcList(G, G.node(0), 2);
     472  checkGraphOutArcList(G, G.node(1), 2);
     473  checkGraphOutArcList(G, G.node(2), 0);
     474  checkGraphOutArcList(G, G.node(3), 2);
     475  checkGraphOutArcList(G, G.node(4), 3);
     476  checkGraphOutArcList(G, G.node(5), 0);
     477
     478  checkGraphInArcList(G, G.node(0), 1);
     479  checkGraphInArcList(G, G.node(1), 2);
     480  checkGraphInArcList(G, G.node(2), 3);
     481  checkGraphInArcList(G, G.node(3), 3);
     482  checkGraphInArcList(G, G.node(4), 0);
     483  checkGraphInArcList(G, G.node(5), 0);
     484
     485  checkGraphConArcList(G, 9);
     486
     487  checkNodeIds(G);
     488  checkArcIds(G);
     489  checkGraphNodeMap(G);
     490  checkGraphArcMap(G);
     491 
     492  int n = G.nodeNum();
     493  int m = G.arcNum();
     494  check(G.index(G.node(n-1)) == n-1, "Wrong index.");
     495  check(G.index(G.arc(m-1)) == m-1, "Wrong index.");
     496}
     497
    375498void checkFullDigraph(int num) {
    376499  typedef FullDigraph Digraph;
    377500  DIGRAPH_TYPEDEFS(Digraph);
     501
    378502  Digraph G(num);
     503  check(G.nodeNum() == num && G.arcNum() == num * num, "Wrong size");
     504
     505  G.resize(num);
     506  check(G.nodeNum() == num && G.arcNum() == num * num, "Wrong size");
    379507
    380508  checkGraphNodeList(G, num);
     
    420548    checkDigraphValidity<SmartDigraph>();
    421549  }
     550  { // Checking StaticDigraph
     551    checkStaticDigraph();
     552  }
    422553  { // Checking FullDigraph
    423554    checkFullDigraph(8);
  • test/graph_test.cc

    r463 r787  
    3939  checkGraphArcList(G, 0);
    4040
     41  G.reserveNode(3);
     42  G.reserveEdge(3);
     43
    4144  Node
    4245    n1 = G.addNode(),
     
    257260
    258261  snapshot.restore();
     262  snapshot.save(G);
     263
     264  checkGraphNodeList(G, 4);
     265  checkGraphEdgeList(G, 3);
     266  checkGraphArcList(G, 6);
     267 
     268  G.addEdge(G.addNode(), G.addNode());
     269
     270  snapshot.restore();
    259271
    260272  checkGraphNodeList(G, 4);
     
    268280
    269281  Graph G(num);
     282  check(G.nodeNum() == num && G.edgeNum() == num * (num - 1) / 2,
     283        "Wrong size");
     284
     285  G.resize(num);
     286  check(G.nodeNum() == num && G.edgeNum() == num * (num - 1) / 2,
     287        "Wrong size");
     288
    270289  checkGraphNodeList(G, num);
    271290  checkGraphEdgeList(G, num * (num - 1) / 2);
     
    412431  check(G.height() == height, "Wrong row number");
    413432
     433  G.resize(width, height);
     434  check(G.width() == width, "Wrong column number");
     435  check(G.height() == height, "Wrong row number");
     436
    414437  for (int i = 0; i < width; ++i) {
    415438    for (int j = 0; j < height; ++j) {
     
    487510
    488511  HypercubeGraph G(dim);
     512  check(G.dimension() == dim, "Wrong dimension");
     513
     514  G.resize(dim);
     515  check(G.dimension() == dim, "Wrong dimension");
     516 
    489517  checkGraphNodeList(G, 1 << dim);
    490518  checkGraphEdgeList(G, dim * (1 << (dim-1)));
  • test/mip_test.cc

    r678 r795  
    5151  if (stat ==  MipSolver::OPTIMAL) {
    5252    std::ostringstream sbuf;
    53     buf << "Wrong optimal value: the right optimum is " << exp_opt;
     53    sbuf << "Wrong optimal value ("<< mip.solValue()
     54         <<" instead of " << exp_opt << ")";
    5455    check(std::abs(mip.solValue()-exp_opt) < 1e-3, sbuf.str());
    5556    //+ecvt(exp_opt,2)
  • test/test_tools.h

    r463 r810  
    3838///print something like this (and then exits).
    3939///\verbatim file_name.cc:123: error: This is obviously false. \endverbatim
    40 #define check(rc, msg) \
    41   if(!(rc)) { \
    42     std::cerr << __FILE__ ":" << __LINE__ << ": error: " << msg << std::endl; \
    43     abort(); \
    44   } else { } \
     40#define check(rc, msg)                                                  \
     41  {                                                                     \
     42    if(!(rc)) {                                                         \
     43      std::cerr << __FILE__ ":" << __LINE__ << ": error: "              \
     44                << msg << std::endl;                                    \
     45      abort();                                                          \
     46    } else { }                                                          \
     47  }                                                                     \
     48   
    4549
    4650#endif
Note: See TracChangeset for help on using the changeset viewer.