COIN-OR::LEMON - Graph Library

Changeset 764:684964884a2e in lemon


Ignore:
Timestamp:
09/25/09 09:13:03 (14 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Parents:
763:f47b6c94577e (diff), 762:ece80147fb08 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge

Location:
lemon
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • lemon/bfs.h

    r760 r764  
    4848    ///The type of the map that stores the predecessor
    4949    ///arcs of the shortest paths.
    50     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     50    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    5151    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
    5252    ///Instantiates a \c PredMap.
     
    6363
    6464    ///The type of the map that indicates which nodes are processed.
    65     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     65    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     66    ///By default it is a NullMap.
    6667    typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
    6768    ///Instantiates a \c ProcessedMap.
     
    8283
    8384    ///The type of the map that indicates which nodes are reached.
    84     ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     85    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    8586    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    8687    ///Instantiates a \c ReachedMap.
     
    9798
    9899    ///The type of the map that stores the distances of the nodes.
    99     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     100    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    100101    typedef typename Digraph::template NodeMap<int> DistMap;
    101102    ///Instantiates a \c DistMap.
     
    226227    ///\ref named-templ-param "Named parameter" for setting
    227228    ///\c PredMap type.
    228     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     229    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    229230    template <class T>
    230231    struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > {
     
    246247    ///\ref named-templ-param "Named parameter" for setting
    247248    ///\c DistMap type.
    248     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     249    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    249250    template <class T>
    250251    struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > {
     
    266267    ///\ref named-templ-param "Named parameter" for setting
    267268    ///\c ReachedMap type.
    268     ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     269    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    269270    template <class T>
    270271    struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > {
     
    286287    ///\ref named-templ-param "Named parameter" for setting
    287288    ///\c ProcessedMap type.
    288     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     289    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    289290    template <class T>
    290291    struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > {
     
    738739    ///@{
    739740
    740     ///The shortest path to a node.
    741 
    742     ///Returns the shortest path to a node.
     741    ///The shortest path to the given node.
     742
     743    ///Returns the shortest path to the given node from the root(s).
    743744    ///
    744745    ///\warning \c t should be reached from the root(s).
     
    748749    Path path(Node t) const { return Path(*G, *_pred, t); }
    749750
    750     ///The distance of a node from the root(s).
    751 
    752     ///Returns the distance of a node from the root(s).
     751    ///The distance of the given node from the root(s).
     752
     753    ///Returns the distance of the given node from the root(s).
    753754    ///
    754755    ///\warning If node \c v is not reached from the root(s), then
     
    759760    int dist(Node v) const { return (*_dist)[v]; }
    760761
    761     ///Returns the 'previous arc' of the shortest path tree for a node.
    762 
     762    ///\brief Returns the 'previous arc' of the shortest path tree for
     763    ///the given node.
     764    ///
    763765    ///This function returns the 'previous arc' of the shortest path
    764766    ///tree for the node \c v, i.e. it returns the last arc of a
     
    767769    ///
    768770    ///The shortest path tree used here is equal to the shortest path
    769     ///tree used in \ref predNode().
     771    ///tree used in \ref predNode() and \ref predMap().
    770772    ///
    771773    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    773775    Arc predArc(Node v) const { return (*_pred)[v];}
    774776
    775     ///Returns the 'previous node' of the shortest path tree for a node.
    776 
     777    ///\brief Returns the 'previous node' of the shortest path tree for
     778    ///the given node.
     779    ///
    777780    ///This function returns the 'previous node' of the shortest path
    778781    ///tree for the node \c v, i.e. it returns the last but one node
    779     ///from a shortest path from a root to \c v. It is \c INVALID
     782    ///of a shortest path from a root to \c v. It is \c INVALID
    780783    ///if \c v is not reached from the root(s) or if \c v is a root.
    781784    ///
    782785    ///The shortest path tree used here is equal to the shortest path
    783     ///tree used in \ref predArc().
     786    ///tree used in \ref predArc() and \ref predMap().
    784787    ///
    785788    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    802805    ///
    803806    ///Returns a const reference to the node map that stores the predecessor
    804     ///arcs, which form the shortest path tree.
     807    ///arcs, which form the shortest path tree (forest).
    805808    ///
    806809    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    808811    const PredMap &predMap() const { return *_pred;}
    809812
    810     ///Checks if a node is reached from the root(s).
     813    ///Checks if the given node is reached from the root(s).
    811814
    812815    ///Returns \c true if \c v is reached from the root(s).
     
    834837    ///The type of the map that stores the predecessor
    835838    ///arcs of the shortest paths.
    836     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     839    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    837840    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
    838841    ///Instantiates a PredMap.
     
    849852
    850853    ///The type of the map that indicates which nodes are processed.
    851     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     854    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    852855    ///By default it is a NullMap.
    853856    typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
     
    869872
    870873    ///The type of the map that indicates which nodes are reached.
    871     ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     874    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    872875    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    873876    ///Instantiates a ReachedMap.
     
    884887
    885888    ///The type of the map that stores the distances of the nodes.
    886     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     889    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    887890    typedef typename Digraph::template NodeMap<int> DistMap;
    888891    ///Instantiates a DistMap.
     
    899902
    900903    ///The type of the shortest paths.
    901     ///It must meet the \ref concepts::Path "Path" concept.
     904    ///It must conform to the \ref concepts::Path "Path" concept.
    902905    typedef lemon::Path<Digraph> Path;
    903906  };
     
    905908  /// Default traits class used by BfsWizard
    906909
    907   /// To make it easier to use Bfs algorithm
    908   /// we have created a wizard class.
    909   /// This \ref BfsWizard class needs default traits,
    910   /// as well as the \ref Bfs class.
    911   /// The \ref BfsWizardBase is a class to be the default traits of the
    912   /// \ref BfsWizard class.
     910  /// Default traits class used by BfsWizard.
     911  /// \tparam GR The type of the digraph.
    913912  template<class GR>
    914913  class BfsWizardBase : public BfsWizardDefaultTraits<GR>
     
    938937    /// Constructor.
    939938
    940     /// This constructor does not require parameters, therefore it initiates
     939    /// This constructor does not require parameters, it initiates
    941940    /// all of the attributes to \c 0.
    942941    BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
     
    968967    typedef TR Base;
    969968
    970     ///The type of the digraph the algorithm runs on.
    971969    typedef typename TR::Digraph Digraph;
    972970
     
    976974    typedef typename Digraph::OutArcIt OutArcIt;
    977975
    978     ///\brief The type of the map that stores the predecessor
    979     ///arcs of the shortest paths.
    980976    typedef typename TR::PredMap PredMap;
    981     ///\brief The type of the map that stores the distances of the nodes.
    982977    typedef typename TR::DistMap DistMap;
    983     ///\brief The type of the map that indicates which nodes are reached.
    984978    typedef typename TR::ReachedMap ReachedMap;
    985     ///\brief The type of the map that indicates which nodes are processed.
    986979    typedef typename TR::ProcessedMap ProcessedMap;
    987     ///The type of the shortest paths
    988980    typedef typename TR::Path Path;
    989981
     
    10681060      SetPredMapBase(const TR &b) : TR(b) {}
    10691061    };
    1070     ///\brief \ref named-func-param "Named parameter"
    1071     ///for setting PredMap object.
    1072     ///
    1073     ///\ref named-func-param "Named parameter"
    1074     ///for setting PredMap object.
     1062
     1063    ///\brief \ref named-templ-param "Named parameter" for setting
     1064    ///the predecessor map.
     1065    ///
     1066    ///\ref named-templ-param "Named parameter" function for setting
     1067    ///the map that stores the predecessor arcs of the nodes.
    10751068    template<class T>
    10761069    BfsWizard<SetPredMapBase<T> > predMap(const T &t)
     
    10861079      SetReachedMapBase(const TR &b) : TR(b) {}
    10871080    };
    1088     ///\brief \ref named-func-param "Named parameter"
    1089     ///for setting ReachedMap object.
    1090     ///
    1091     /// \ref named-func-param "Named parameter"
    1092     ///for setting ReachedMap object.
     1081
     1082    ///\brief \ref named-templ-param "Named parameter" for setting
     1083    ///the reached map.
     1084    ///
     1085    ///\ref named-templ-param "Named parameter" function for setting
     1086    ///the map that indicates which nodes are reached.
    10931087    template<class T>
    10941088    BfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
     
    11041098      SetDistMapBase(const TR &b) : TR(b) {}
    11051099    };
    1106     ///\brief \ref named-func-param "Named parameter"
    1107     ///for setting DistMap object.
    1108     ///
    1109     /// \ref named-func-param "Named parameter"
    1110     ///for setting DistMap object.
     1100
     1101    ///\brief \ref named-templ-param "Named parameter" for setting
     1102    ///the distance map.
     1103    ///
     1104    ///\ref named-templ-param "Named parameter" function for setting
     1105    ///the map that stores the distances of the nodes calculated
     1106    ///by the algorithm.
    11111107    template<class T>
    11121108    BfsWizard<SetDistMapBase<T> > distMap(const T &t)
     
    11221118      SetProcessedMapBase(const TR &b) : TR(b) {}
    11231119    };
    1124     ///\brief \ref named-func-param "Named parameter"
    1125     ///for setting ProcessedMap object.
    1126     ///
    1127     /// \ref named-func-param "Named parameter"
    1128     ///for setting ProcessedMap object.
     1120
     1121    ///\brief \ref named-func-param "Named parameter" for setting
     1122    ///the processed map.
     1123    ///
     1124    ///\ref named-templ-param "Named parameter" function for setting
     1125    ///the map that indicates which nodes are processed.
    11291126    template<class T>
    11301127    BfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
     
    12651262    ///
    12661263    /// The type of the map that indicates which nodes are reached.
    1267     /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     1264    /// It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    12681265    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    12691266
     
    17361733    ///@{
    17371734
    1738     /// \brief Checks if a node is reached from the root(s).
     1735    /// \brief Checks if the given node is reached from the root(s).
    17391736    ///
    17401737    /// Returns \c true if \c v is reached from the root(s).
  • lemon/bfs.h

    r763 r764  
    415415    ///The simplest way to execute the BFS algorithm is to use one of the
    416416    ///member functions called \ref run(Node) "run()".\n
    417     ///If you need more control on the execution, first you have to call
    418     ///\ref init(), then you can add several source nodes with
     417    ///If you need better control on the execution, you have to call
     418    ///\ref init() first, then you can add several source nodes with
    419419    ///\ref addSource(). Finally the actual path computation can be
    420420    ///performed with one of the \ref start() functions.
     
    14231423    /// The simplest way to execute the BFS algorithm is to use one of the
    14241424    /// member functions called \ref run(Node) "run()".\n
    1425     /// If you need more control on the execution, first you have to call
    1426     /// \ref init(), then you can add several source nodes with
     1425    /// If you need better control on the execution, you have to call
     1426    /// \ref init() first, then you can add several source nodes with
    14271427    /// \ref addSource(). Finally the actual path computation can be
    14281428    /// performed with one of the \ref start() functions.
  • lemon/dfs.h

    r760 r764  
    4848    ///The type of the map that stores the predecessor
    4949    ///arcs of the %DFS paths.
    50     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     50    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    5151    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
    5252    ///Instantiates a \c PredMap.
     
    6363
    6464    ///The type of the map that indicates which nodes are processed.
    65     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     65    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
     66    ///By default it is a NullMap.
    6667    typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
    6768    ///Instantiates a \c ProcessedMap.
     
    8283
    8384    ///The type of the map that indicates which nodes are reached.
    84     ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     85    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    8586    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    8687    ///Instantiates a \c ReachedMap.
     
    9798
    9899    ///The type of the map that stores the distances of the nodes.
    99     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     100    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    100101    typedef typename Digraph::template NodeMap<int> DistMap;
    101102    ///Instantiates a \c DistMap.
     
    225226    ///\ref named-templ-param "Named parameter" for setting
    226227    ///\c PredMap type.
    227     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     228    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    228229    template <class T>
    229230    struct SetPredMap : public Dfs<Digraph, SetPredMapTraits<T> > {
     
    245246    ///\ref named-templ-param "Named parameter" for setting
    246247    ///\c DistMap type.
    247     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     248    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    248249    template <class T>
    249250    struct SetDistMap : public Dfs< Digraph, SetDistMapTraits<T> > {
     
    265266    ///\ref named-templ-param "Named parameter" for setting
    266267    ///\c ReachedMap type.
    267     ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     268    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    268269    template <class T>
    269270    struct SetReachedMap : public Dfs< Digraph, SetReachedMapTraits<T> > {
     
    285286    ///\ref named-templ-param "Named parameter" for setting
    286287    ///\c ProcessedMap type.
    287     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     288    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    288289    template <class T>
    289290    struct SetProcessedMap : public Dfs< Digraph, SetProcessedMapTraits<T> > {
     
    670671    ///@{
    671672
    672     ///The DFS path to a node.
    673 
    674     ///Returns the DFS path to a node.
     673    ///The DFS path to the given node.
     674
     675    ///Returns the DFS path to the given node from the root(s).
    675676    ///
    676677    ///\warning \c t should be reached from the root(s).
     
    680681    Path path(Node t) const { return Path(*G, *_pred, t); }
    681682
    682     ///The distance of a node from the root(s).
    683 
    684     ///Returns the distance of a node from the root(s).
     683    ///The distance of the given node from the root(s).
     684
     685    ///Returns the distance of the given node from the root(s).
    685686    ///
    686687    ///\warning If node \c v is not reached from the root(s), then
     
    691692    int dist(Node v) const { return (*_dist)[v]; }
    692693
    693     ///Returns the 'previous arc' of the %DFS tree for a node.
     694    ///Returns the 'previous arc' of the %DFS tree for the given node.
    694695
    695696    ///This function returns the 'previous arc' of the %DFS tree for the
     
    699700    ///
    700701    ///The %DFS tree used here is equal to the %DFS tree used in
    701     ///\ref predNode().
     702    ///\ref predNode() and \ref predMap().
    702703    ///
    703704    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    705706    Arc predArc(Node v) const { return (*_pred)[v];}
    706707
    707     ///Returns the 'previous node' of the %DFS tree.
     708    ///Returns the 'previous node' of the %DFS tree for the given node.
    708709
    709710    ///This function returns the 'previous node' of the %DFS
    710711    ///tree for the node \c v, i.e. it returns the last but one node
    711     ///from a %DFS path from a root to \c v. It is \c INVALID
     712    ///of a %DFS path from a root to \c v. It is \c INVALID
    712713    ///if \c v is not reached from the root(s) or if \c v is a root.
    713714    ///
    714715    ///The %DFS tree used here is equal to the %DFS tree used in
    715     ///\ref predArc().
     716    ///\ref predArc() and \ref predMap().
    716717    ///
    717718    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    734735    ///
    735736    ///Returns a const reference to the node map that stores the predecessor
    736     ///arcs, which form the DFS tree.
     737    ///arcs, which form the DFS tree (forest).
    737738    ///
    738739    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    740741    const PredMap &predMap() const { return *_pred;}
    741742
    742     ///Checks if a node is reached from the root(s).
     743    ///Checks if the given node. node is reached from the root(s).
    743744
    744745    ///Returns \c true if \c v is reached from the root(s).
     
    766767    ///The type of the map that stores the predecessor
    767768    ///arcs of the %DFS paths.
    768     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     769    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    769770    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
    770771    ///Instantiates a PredMap.
     
    781782
    782783    ///The type of the map that indicates which nodes are processed.
    783     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     784    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    784785    ///By default it is a NullMap.
    785786    typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
     
    801802
    802803    ///The type of the map that indicates which nodes are reached.
    803     ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     804    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    804805    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    805806    ///Instantiates a ReachedMap.
     
    816817
    817818    ///The type of the map that stores the distances of the nodes.
    818     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     819    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    819820    typedef typename Digraph::template NodeMap<int> DistMap;
    820821    ///Instantiates a DistMap.
     
    831832
    832833    ///The type of the DFS paths.
    833     ///It must meet the \ref concepts::Path "Path" concept.
     834    ///It must conform to the \ref concepts::Path "Path" concept.
    834835    typedef lemon::Path<Digraph> Path;
    835836  };
     
    837838  /// Default traits class used by DfsWizard
    838839
    839   /// To make it easier to use Dfs algorithm
    840   /// we have created a wizard class.
    841   /// This \ref DfsWizard class needs default traits,
    842   /// as well as the \ref Dfs class.
    843   /// The \ref DfsWizardBase is a class to be the default traits of the
    844   /// \ref DfsWizard class.
     840  /// Default traits class used by DfsWizard.
     841  /// \tparam GR The type of the digraph.
    845842  template<class GR>
    846843  class DfsWizardBase : public DfsWizardDefaultTraits<GR>
     
    870867    /// Constructor.
    871868
    872     /// This constructor does not require parameters, therefore it initiates
     869    /// This constructor does not require parameters, it initiates
    873870    /// all of the attributes to \c 0.
    874871    DfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
     
    900897    typedef TR Base;
    901898
    902     ///The type of the digraph the algorithm runs on.
    903899    typedef typename TR::Digraph Digraph;
    904900
     
    908904    typedef typename Digraph::OutArcIt OutArcIt;
    909905
    910     ///\brief The type of the map that stores the predecessor
    911     ///arcs of the DFS paths.
    912906    typedef typename TR::PredMap PredMap;
    913     ///\brief The type of the map that stores the distances of the nodes.
    914907    typedef typename TR::DistMap DistMap;
    915     ///\brief The type of the map that indicates which nodes are reached.
    916908    typedef typename TR::ReachedMap ReachedMap;
    917     ///\brief The type of the map that indicates which nodes are processed.
    918909    typedef typename TR::ProcessedMap ProcessedMap;
    919     ///The type of the DFS paths
    920910    typedef typename TR::Path Path;
    921911
     
    1000990      SetPredMapBase(const TR &b) : TR(b) {}
    1001991    };
    1002     ///\brief \ref named-func-param "Named parameter"
    1003     ///for setting PredMap object.
    1004     ///
    1005     ///\ref named-func-param "Named parameter"
    1006     ///for setting PredMap object.
     992
     993    ///\brief \ref named-templ-param "Named parameter" for setting
     994    ///the predecessor map.
     995    ///
     996    ///\ref named-templ-param "Named parameter" function for setting
     997    ///the map that stores the predecessor arcs of the nodes.
    1007998    template<class T>
    1008999    DfsWizard<SetPredMapBase<T> > predMap(const T &t)
     
    10181009      SetReachedMapBase(const TR &b) : TR(b) {}
    10191010    };
    1020     ///\brief \ref named-func-param "Named parameter"
    1021     ///for setting ReachedMap object.
    1022     ///
    1023     /// \ref named-func-param "Named parameter"
    1024     ///for setting ReachedMap object.
     1011
     1012    ///\brief \ref named-templ-param "Named parameter" for setting
     1013    ///the reached map.
     1014    ///
     1015    ///\ref named-templ-param "Named parameter" function for setting
     1016    ///the map that indicates which nodes are reached.
    10251017    template<class T>
    10261018    DfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
     
    10361028      SetDistMapBase(const TR &b) : TR(b) {}
    10371029    };
    1038     ///\brief \ref named-func-param "Named parameter"
    1039     ///for setting DistMap object.
    1040     ///
    1041     /// \ref named-func-param "Named parameter"
    1042     ///for setting DistMap object.
     1030
     1031    ///\brief \ref named-templ-param "Named parameter" for setting
     1032    ///the distance map.
     1033    ///
     1034    ///\ref named-templ-param "Named parameter" function for setting
     1035    ///the map that stores the distances of the nodes calculated
     1036    ///by the algorithm.
    10431037    template<class T>
    10441038    DfsWizard<SetDistMapBase<T> > distMap(const T &t)
     
    10541048      SetProcessedMapBase(const TR &b) : TR(b) {}
    10551049    };
    1056     ///\brief \ref named-func-param "Named parameter"
    1057     ///for setting ProcessedMap object.
    1058     ///
    1059     /// \ref named-func-param "Named parameter"
    1060     ///for setting ProcessedMap object.
     1050
     1051    ///\brief \ref named-func-param "Named parameter" for setting
     1052    ///the processed map.
     1053    ///
     1054    ///\ref named-templ-param "Named parameter" function for setting
     1055    ///the map that indicates which nodes are processed.
    10611056    template<class T>
    10621057    DfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
     
    12091204    ///
    12101205    /// The type of the map that indicates which nodes are reached.
    1211     /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     1206    /// It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    12121207    typedef typename Digraph::template NodeMap<bool> ReachedMap;
    12131208
     
    16211616    ///@{
    16221617
    1623     /// \brief Checks if a node is reached from the root(s).
     1618    /// \brief Checks if the given node is reached from the root(s).
    16241619    ///
    16251620    /// Returns \c true if \c v is reached from the root(s).
  • lemon/dfs.h

    r763 r764  
    413413    ///The simplest way to execute the DFS algorithm is to use one of the
    414414    ///member functions called \ref run(Node) "run()".\n
    415     ///If you need more control on the execution, first you have to call
    416     ///\ref init(), then you can add a source node with \ref addSource()
     415    ///If you need better control on the execution, you have to call
     416    ///\ref init() first, then you can add a source node with \ref addSource()
    417417    ///and perform the actual computation with \ref start().
    418418    ///This procedure can be repeated if there are nodes that have not
     
    13651365    /// The simplest way to execute the DFS algorithm is to use one of the
    13661366    /// member functions called \ref run(Node) "run()".\n
    1367     /// If you need more control on the execution, first you have to call
    1368     /// \ref init(), then you can add a source node with \ref addSource()
     1367    /// If you need better control on the execution, you have to call
     1368    /// \ref init() first, then you can add a source node with \ref addSource()
    13691369    /// and perform the actual computation with \ref start().
    13701370    /// This procedure can be repeated if there are nodes that have not
  • lemon/dijkstra.h

    r760 r764  
    7171
    7272    ///The type of the map that stores the arc lengths.
    73     ///It must meet the \ref concepts::ReadMap "ReadMap" concept.
     73    ///It must conform to the \ref concepts::ReadMap "ReadMap" concept.
    7474    typedef LEN LengthMap;
    75     ///The type of the length of the arcs.
     75    ///The type of the arc lengths.
    7676    typedef typename LEN::Value Value;
    7777
     
    117117    ///The type of the map that stores the predecessor
    118118    ///arcs of the shortest paths.
    119     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     119    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    120120    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
    121121    ///Instantiates a \c PredMap.
     
    132132
    133133    ///The type of the map that indicates which nodes are processed.
    134     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     134    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    135135    ///By default it is a NullMap.
    136136    typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
     
    152152
    153153    ///The type of the map that stores the distances of the nodes.
    154     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     154    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    155155    typedef typename Digraph::template NodeMap<typename LEN::Value> DistMap;
    156156    ///Instantiates a \c DistMap.
     
    169169  /// \ingroup shortest_path
    170170  ///This class provides an efficient implementation of the %Dijkstra algorithm.
     171  ///
     172  ///The %Dijkstra algorithm solves the single-source shortest path problem
     173  ///when all arc lengths are non-negative. If there are negative lengths,
     174  ///the BellmanFord algorithm should be used instead.
    171175  ///
    172176  ///The arc lengths are passed to the algorithm using a
     
    202206    typedef typename TR::Digraph Digraph;
    203207
    204     ///The type of the length of the arcs.
     208    ///The type of the arc lengths.
    205209    typedef typename TR::LengthMap::Value Value;
    206210    ///The type of the map that stores the arc lengths.
     
    305309    ///\ref named-templ-param "Named parameter" for setting
    306310    ///\c PredMap type.
    307     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     311    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    308312    template <class T>
    309313    struct SetPredMap
     
    326330    ///\ref named-templ-param "Named parameter" for setting
    327331    ///\c DistMap type.
    328     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     332    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    329333    template <class T>
    330334    struct SetDistMap
     
    347351    ///\ref named-templ-param "Named parameter" for setting
    348352    ///\c ProcessedMap type.
    349     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     353    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    350354    template <class T>
    351355    struct SetProcessedMap
     
    444448    ///\ref named-templ-param "Named parameter" for setting
    445449    ///\c OperationTraits type.
     450    /// For more information see \ref DijkstraDefaultOperationTraits.
    446451    template <class T>
    447452    struct SetOperationTraits
     
    802807    ///The results of the %Dijkstra algorithm can be obtained using these
    803808    ///functions.\n
    804     ///Either \ref run(Node) "run()" or \ref start() should be called
     809    ///Either \ref run(Node) "run()" or \ref init() should be called
    805810    ///before using them.
    806811
    807812    ///@{
    808813
    809     ///The shortest path to a node.
    810 
    811     ///Returns the shortest path to a node.
     814    ///The shortest path to the given node.
     815
     816    ///Returns the shortest path to the given node from the root(s).
    812817    ///
    813818    ///\warning \c t should be reached from the root(s).
     
    817822    Path path(Node t) const { return Path(*G, *_pred, t); }
    818823
    819     ///The distance of a node from the root(s).
    820 
    821     ///Returns the distance of a node from the root(s).
     824    ///The distance of the given node from the root(s).
     825
     826    ///Returns the distance of the given node from the root(s).
    822827    ///
    823828    ///\warning If node \c v is not reached from the root(s), then
     
    828833    Value dist(Node v) const { return (*_dist)[v]; }
    829834
    830     ///Returns the 'previous arc' of the shortest path tree for a node.
    831 
     835    ///\brief Returns the 'previous arc' of the shortest path tree for
     836    ///the given node.
     837    ///
    832838    ///This function returns the 'previous arc' of the shortest path
    833839    ///tree for the node \c v, i.e. it returns the last arc of a
     
    836842    ///
    837843    ///The shortest path tree used here is equal to the shortest path
    838     ///tree used in \ref predNode().
     844    ///tree used in \ref predNode() and \ref predMap().
    839845    ///
    840846    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    842848    Arc predArc(Node v) const { return (*_pred)[v]; }
    843849
    844     ///Returns the 'previous node' of the shortest path tree for a node.
    845 
     850    ///\brief Returns the 'previous node' of the shortest path tree for
     851    ///the given node.
     852    ///
    846853    ///This function returns the 'previous node' of the shortest path
    847854    ///tree for the node \c v, i.e. it returns the last but one node
    848     ///from a shortest path from a root to \c v. It is \c INVALID
     855    ///of a shortest path from a root to \c v. It is \c INVALID
    849856    ///if \c v is not reached from the root(s) or if \c v is a root.
    850857    ///
    851858    ///The shortest path tree used here is equal to the shortest path
    852     ///tree used in \ref predArc().
     859    ///tree used in \ref predArc() and \ref predMap().
    853860    ///
    854861    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    871878    ///
    872879    ///Returns a const reference to the node map that stores the predecessor
    873     ///arcs, which form the shortest path tree.
     880    ///arcs, which form the shortest path tree (forest).
    874881    ///
    875882    ///\pre Either \ref run(Node) "run()" or \ref init()
     
    877884    const PredMap &predMap() const { return *_pred;}
    878885
    879     ///Checks if a node is reached from the root(s).
     886    ///Checks if the given node is reached from the root(s).
    880887
    881888    ///Returns \c true if \c v is reached from the root(s).
     
    896903                                          Heap::POST_HEAP; }
    897904
    898     ///The current distance of a node from the root(s).
    899 
    900     ///Returns the current distance of a node from the root(s).
     905    ///The current distance of the given node from the root(s).
     906
     907    ///Returns the current distance of the given node from the root(s).
    901908    ///It may be decreased in the following processes.
    902909    ///
     
    925932
    926933    ///The type of the map that stores the arc lengths.
    927     ///It must meet the \ref concepts::ReadMap "ReadMap" concept.
     934    ///It must conform to the \ref concepts::ReadMap "ReadMap" concept.
    928935    typedef LEN LengthMap;
    929     ///The type of the length of the arcs.
     936    ///The type of the arc lengths.
    930937    typedef typename LEN::Value Value;
    931938
     
    974981    ///The type of the map that stores the predecessor
    975982    ///arcs of the shortest paths.
    976     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     983    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    977984    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
    978985    ///Instantiates a PredMap.
     
    989996
    990997    ///The type of the map that indicates which nodes are processed.
    991     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     998    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    992999    ///By default it is a NullMap.
    9931000    typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
     
    10091016
    10101017    ///The type of the map that stores the distances of the nodes.
    1011     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     1018    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    10121019    typedef typename Digraph::template NodeMap<typename LEN::Value> DistMap;
    10131020    ///Instantiates a DistMap.
     
    10241031
    10251032    ///The type of the shortest paths.
    1026     ///It must meet the \ref concepts::Path "Path" concept.
     1033    ///It must conform to the \ref concepts::Path "Path" concept.
    10271034    typedef lemon::Path<Digraph> Path;
    10281035  };
     
    10301037  /// Default traits class used by DijkstraWizard
    10311038
    1032   /// To make it easier to use Dijkstra algorithm
    1033   /// we have created a wizard class.
    1034   /// This \ref DijkstraWizard class needs default traits,
    1035   /// as well as the \ref Dijkstra class.
    1036   /// The \ref DijkstraWizardBase is a class to be the default traits of the
    1037   /// \ref DijkstraWizard class.
     1039  /// Default traits class used by DijkstraWizard.
     1040  /// \tparam GR The type of the digraph.
     1041  /// \tparam LEN The type of the length map.
    10381042  template<typename GR, typename LEN>
    10391043  class DijkstraWizardBase : public DijkstraWizardDefaultTraits<GR,LEN>
     
    10941098    typedef TR Base;
    10951099
    1096     ///The type of the digraph the algorithm runs on.
    10971100    typedef typename TR::Digraph Digraph;
    10981101
     
    11021105    typedef typename Digraph::OutArcIt OutArcIt;
    11031106
    1104     ///The type of the map that stores the arc lengths.
    11051107    typedef typename TR::LengthMap LengthMap;
    1106     ///The type of the length of the arcs.
    11071108    typedef typename LengthMap::Value Value;
    1108     ///\brief The type of the map that stores the predecessor
    1109     ///arcs of the shortest paths.
    11101109    typedef typename TR::PredMap PredMap;
    1111     ///The type of the map that stores the distances of the nodes.
    11121110    typedef typename TR::DistMap DistMap;
    1113     ///The type of the map that indicates which nodes are processed.
    11141111    typedef typename TR::ProcessedMap ProcessedMap;
    1115     ///The type of the shortest paths
    11161112    typedef typename TR::Path Path;
    1117     ///The heap type used by the dijkstra algorithm.
    11181113    typedef typename TR::Heap Heap;
    11191114
     
    11871182      SetPredMapBase(const TR &b) : TR(b) {}
    11881183    };
    1189     ///\brief \ref named-func-param "Named parameter"
    1190     ///for setting PredMap object.
    1191     ///
    1192     ///\ref named-func-param "Named parameter"
    1193     ///for setting PredMap object.
     1184
     1185    ///\brief \ref named-templ-param "Named parameter" for setting
     1186    ///the predecessor map.
     1187    ///
     1188    ///\ref named-templ-param "Named parameter" function for setting
     1189    ///the map that stores the predecessor arcs of the nodes.
    11941190    template<class T>
    11951191    DijkstraWizard<SetPredMapBase<T> > predMap(const T &t)
     
    12051201      SetDistMapBase(const TR &b) : TR(b) {}
    12061202    };
    1207     ///\brief \ref named-func-param "Named parameter"
    1208     ///for setting DistMap object.
    1209     ///
    1210     ///\ref named-func-param "Named parameter"
    1211     ///for setting DistMap object.
     1203
     1204    ///\brief \ref named-templ-param "Named parameter" for setting
     1205    ///the distance map.
     1206    ///
     1207    ///\ref named-templ-param "Named parameter" function for setting
     1208    ///the map that stores the distances of the nodes calculated
     1209    ///by the algorithm.
    12121210    template<class T>
    12131211    DijkstraWizard<SetDistMapBase<T> > distMap(const T &t)
     
    12231221      SetProcessedMapBase(const TR &b) : TR(b) {}
    12241222    };
    1225     ///\brief \ref named-func-param "Named parameter"
    1226     ///for setting ProcessedMap object.
    1227     ///
    1228     /// \ref named-func-param "Named parameter"
    1229     ///for setting ProcessedMap object.
     1223
     1224    ///\brief \ref named-func-param "Named parameter" for setting
     1225    ///the processed map.
     1226    ///
     1227    ///\ref named-templ-param "Named parameter" function for setting
     1228    ///the map that indicates which nodes are processed.
    12301229    template<class T>
    12311230    DijkstraWizard<SetProcessedMapBase<T> > processedMap(const T &t)
     
    12401239      SetPathBase(const TR &b) : TR(b) {}
    12411240    };
     1241
    12421242    ///\brief \ref named-func-param "Named parameter"
    12431243    ///for getting the shortest path to the target node.
  • lemon/dijkstra.h

    r763 r764  
    590590    ///The simplest way to execute the %Dijkstra algorithm is to use
    591591    ///one of the member functions called \ref run(Node) "run()".\n
    592     ///If you need more control on the execution, first you have to call
    593     ///\ref init(), then you can add several source nodes with
     592    ///If you need better control on the execution, you have to call
     593    ///\ref init() first, then you can add several source nodes with
    594594    ///\ref addSource(). Finally the actual path computation can be
    595595    ///performed with one of the \ref start() functions.
  • lemon/maps.h

    r742 r764  
    17901790  /// \code
    17911791  ///   std::vector<Node> v;
    1792   ///   dfs(g,s).processedMap(loggerBoolMap(std::back_inserter(v))).run();
     1792  ///   dfs(g).processedMap(loggerBoolMap(std::back_inserter(v))).run(s);
    17931793  /// \endcode
    17941794  /// \code
    17951795  ///   std::vector<Node> v(countNodes(g));
    1796   ///   dfs(g,s).processedMap(loggerBoolMap(v.begin())).run();
     1796  ///   dfs(g).processedMap(loggerBoolMap(v.begin())).run(s);
    17971797  /// \endcode
    17981798  ///
  • lemon/maps.h

    r763 r764  
    2323#include <functional>
    2424#include <vector>
     25#include <map>
    2526
    2627#include <lemon/core.h>
     
    2930///\ingroup maps
    3031///\brief Miscellaneous property maps
    31 
    32 #include <map>
    3332
    3433namespace lemon {
     
    18191818  ///
    18201819  /// IdMap provides a unique and immutable id for each item of the
    1821   /// same type (\c Node, \c Arc or \c Edge) in a graph. This id is 
     1820  /// same type (\c Node, \c Arc or \c Edge) in a graph. This id is
    18221821  ///  - \b unique: different items get different ids,
    18231822  ///  - \b immutable: the id of an item does not change (even if you
     
    19031902
    19041903  /// This class provides simple invertable graph maps.
    1905   /// It wraps an arbitrary \ref concepts::ReadWriteMap "ReadWriteMap"
    1906   /// and if a key is set to a new value then store it
    1907   /// in the inverse map.
    1908   ///
     1904  /// It wraps a standard graph map (\c NodeMap, \c ArcMap or \c EdgeMap)
     1905  /// and if a key is set to a new value, then stores it in the inverse map.
    19091906  /// The values of the map can be accessed
    19101907  /// with stl compatible forward iterator.
     1908  ///
     1909  /// This type is not reference map, so it cannot be modified with
     1910  /// the subscript operator.
    19111911  ///
    19121912  /// \tparam GR The graph type.
     
    19241924      template Map<V>::Type Map;
    19251925
    1926     typedef std::map<V, K> Container;
     1926    typedef std::multimap<V, K> Container;
    19271927    Container _inv_map;
    19281928
     
    19491949    /// iterator on the values of the map. The values can
    19501950    /// be accessed in the <tt>[beginValue, endValue)</tt> range.
     1951    /// They are considered with multiplicity, so each value is
     1952    /// traversed for each item it is assigned to.
    19511953    class ValueIterator
    19521954      : public std::iterator<std::forward_iterator_tag, Value> {
     
    20012003    void set(const Key& key, const Value& val) {
    20022004      Value oldval = Map::operator[](key);
    2003       typename Container::iterator it = _inv_map.find(oldval);
    2004       if (it != _inv_map.end() && it->second == key) {
    2005         _inv_map.erase(it);
    2006       }
    2007       _inv_map.insert(make_pair(val, key));
     2005      typename Container::iterator it;
     2006      for (it = _inv_map.equal_range(oldval).first;
     2007           it != _inv_map.equal_range(oldval).second; ++it) {
     2008        if (it->second == key) {
     2009          _inv_map.erase(it);
     2010          break;
     2011        }
     2012      }
     2013      _inv_map.insert(std::make_pair(val, key));
    20082014      Map::set(key, val);
    20092015    }
     
    20172023    }
    20182024
    2019     /// \brief Gives back the item by its value.
    2020     ///
    2021     /// Gives back the item by its value.
    2022     Key operator()(const Value& key) const {
    2023       typename Container::const_iterator it = _inv_map.find(key);
     2025    /// \brief Gives back an item by its value.
     2026    ///
     2027    /// This function gives back an item that is assigned to
     2028    /// the given value or \c INVALID if no such item exists.
     2029    /// If there are more items with the same associated value,
     2030    /// only one of them is returned.
     2031    Key operator()(const Value& val) const {
     2032      typename Container::const_iterator it = _inv_map.find(val);
    20242033      return it != _inv_map.end() ? it->second : INVALID;
    20252034    }
     
    20332042    virtual void erase(const Key& key) {
    20342043      Value val = Map::operator[](key);
    2035       typename Container::iterator it = _inv_map.find(val);
    2036       if (it != _inv_map.end() && it->second == key) {
    2037         _inv_map.erase(it);
     2044      typename Container::iterator it;
     2045      for (it = _inv_map.equal_range(val).first;
     2046           it != _inv_map.equal_range(val).second; ++it) {
     2047        if (it->second == key) {
     2048          _inv_map.erase(it);
     2049          break;
     2050        }
    20382051      }
    20392052      Map::erase(key);
     
    20472060      for (int i = 0; i < int(keys.size()); ++i) {
    20482061        Value val = Map::operator[](keys[i]);
    2049         typename Container::iterator it = _inv_map.find(val);
    2050         if (it != _inv_map.end() && it->second == keys[i]) {
    2051           _inv_map.erase(it);
     2062        typename Container::iterator it;
     2063        for (it = _inv_map.equal_range(val).first;
     2064             it != _inv_map.equal_range(val).second; ++it) {
     2065          if (it->second == keys[i]) {
     2066            _inv_map.erase(it);
     2067            break;
     2068          }
    20522069        }
    20532070      }
     
    20852102      /// \brief Subscript operator.
    20862103      ///
    2087       /// Subscript operator. It gives back the item
    2088       /// that was last assigned to the given value.
     2104      /// Subscript operator. It gives back an item
     2105      /// that is assigned to the given value or \c INVALID
     2106      /// if no such item exists.
    20892107      Value operator[](const Key& key) const {
    20902108        return _inverted(key);
     
    22552273
    22562274    /// \brief Gives back the item belonging to a \e RangeId
    2257     /// 
     2275    ///
    22582276    /// Gives back the item belonging to a \e RangeId.
    22592277    Item operator()(int id) const {
     
    23122330  };
    23132331
     2332  /// \brief Dynamic iterable \c bool map.
     2333  ///
     2334  /// This class provides a special graph map type which can store a
     2335  /// \c bool value for graph items (\c Node, \c Arc or \c Edge).
     2336  /// For both \c true and \c false values it is possible to iterate on
     2337  /// the keys.
     2338  ///
     2339  /// This type is a reference map, so it can be modified with the
     2340  /// subscript operator.
     2341  ///
     2342  /// \tparam GR The graph type.
     2343  /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
     2344  /// \c GR::Edge).
     2345  ///
     2346  /// \see IterableIntMap, IterableValueMap
     2347  /// \see CrossRefMap
     2348  template <typename GR, typename K>
     2349  class IterableBoolMap
     2350    : protected ItemSetTraits<GR, K>::template Map<int>::Type {
     2351  private:
     2352    typedef GR Graph;
     2353
     2354    typedef typename ItemSetTraits<GR, K>::ItemIt KeyIt;
     2355    typedef typename ItemSetTraits<GR, K>::template Map<int>::Type Parent;
     2356
     2357    std::vector<K> _array;
     2358    int _sep;
     2359
     2360  public:
     2361
     2362    /// Indicates that the map is reference map.
     2363    typedef True ReferenceMapTag;
     2364
     2365    /// The key type
     2366    typedef K Key;
     2367    /// The value type
     2368    typedef bool Value;
     2369    /// The const reference type.
     2370    typedef const Value& ConstReference;
     2371
     2372  private:
     2373
     2374    int position(const Key& key) const {
     2375      return Parent::operator[](key);
     2376    }
     2377
     2378  public:
     2379
     2380    /// \brief Reference to the value of the map.
     2381    ///
     2382    /// This class is similar to the \c bool type. It can be converted to
     2383    /// \c bool and it provides the same operators.
     2384    class Reference {
     2385      friend class IterableBoolMap;
     2386    private:
     2387      Reference(IterableBoolMap& map, const Key& key)
     2388        : _key(key), _map(map) {}
     2389    public:
     2390
     2391      Reference& operator=(const Reference& value) {
     2392        _map.set(_key, static_cast<bool>(value));
     2393         return *this;
     2394      }
     2395
     2396      operator bool() const {
     2397        return static_cast<const IterableBoolMap&>(_map)[_key];
     2398      }
     2399
     2400      Reference& operator=(bool value) {
     2401        _map.set(_key, value);
     2402        return *this;
     2403      }
     2404      Reference& operator&=(bool value) {
     2405        _map.set(_key, _map[_key] & value);
     2406        return *this;
     2407      }
     2408      Reference& operator|=(bool value) {
     2409        _map.set(_key, _map[_key] | value);
     2410        return *this;
     2411      }
     2412      Reference& operator^=(bool value) {
     2413        _map.set(_key, _map[_key] ^ value);
     2414        return *this;
     2415      }
     2416    private:
     2417      Key _key;
     2418      IterableBoolMap& _map;
     2419    };
     2420
     2421    /// \brief Constructor of the map with a default value.
     2422    ///
     2423    /// Constructor of the map with a default value.
     2424    explicit IterableBoolMap(const Graph& graph, bool def = false)
     2425      : Parent(graph) {
     2426      typename Parent::Notifier* nf = Parent::notifier();
     2427      Key it;
     2428      for (nf->first(it); it != INVALID; nf->next(it)) {
     2429        Parent::set(it, _array.size());
     2430        _array.push_back(it);
     2431      }
     2432      _sep = (def ? _array.size() : 0);
     2433    }
     2434
     2435    /// \brief Const subscript operator of the map.
     2436    ///
     2437    /// Const subscript operator of the map.
     2438    bool operator[](const Key& key) const {
     2439      return position(key) < _sep;
     2440    }
     2441
     2442    /// \brief Subscript operator of the map.
     2443    ///
     2444    /// Subscript operator of the map.
     2445    Reference operator[](const Key& key) {
     2446      return Reference(*this, key);
     2447    }
     2448
     2449    /// \brief Set operation of the map.
     2450    ///
     2451    /// Set operation of the map.
     2452    void set(const Key& key, bool value) {
     2453      int pos = position(key);
     2454      if (value) {
     2455        if (pos < _sep) return;
     2456        Key tmp = _array[_sep];
     2457        _array[_sep] = key;
     2458        Parent::set(key, _sep);
     2459        _array[pos] = tmp;
     2460        Parent::set(tmp, pos);
     2461        ++_sep;
     2462      } else {
     2463        if (pos >= _sep) return;
     2464        --_sep;
     2465        Key tmp = _array[_sep];
     2466        _array[_sep] = key;
     2467        Parent::set(key, _sep);
     2468        _array[pos] = tmp;
     2469        Parent::set(tmp, pos);
     2470      }
     2471    }
     2472
     2473    /// \brief Set all items.
     2474    ///
     2475    /// Set all items in the map.
     2476    /// \note Constant time operation.
     2477    void setAll(bool value) {
     2478      _sep = (value ? _array.size() : 0);
     2479    }
     2480
     2481    /// \brief Returns the number of the keys mapped to \c true.
     2482    ///
     2483    /// Returns the number of the keys mapped to \c true.
     2484    int trueNum() const {
     2485      return _sep;
     2486    }
     2487
     2488    /// \brief Returns the number of the keys mapped to \c false.
     2489    ///
     2490    /// Returns the number of the keys mapped to \c false.
     2491    int falseNum() const {
     2492      return _array.size() - _sep;
     2493    }
     2494
     2495    /// \brief Iterator for the keys mapped to \c true.
     2496    ///
     2497    /// Iterator for the keys mapped to \c true. It works
     2498    /// like a graph item iterator, it can be converted to
     2499    /// the key type of the map, incremented with \c ++ operator, and
     2500    /// if the iterator leaves the last valid key, it will be equal to
     2501    /// \c INVALID.
     2502    class TrueIt : public Key {
     2503    public:
     2504      typedef Key Parent;
     2505
     2506      /// \brief Creates an iterator.
     2507      ///
     2508      /// Creates an iterator. It iterates on the
     2509      /// keys mapped to \c true.
     2510      /// \param map The IterableBoolMap.
     2511      explicit TrueIt(const IterableBoolMap& map)
     2512        : Parent(map._sep > 0 ? map._array[map._sep - 1] : INVALID),
     2513          _map(&map) {}
     2514
     2515      /// \brief Invalid constructor \& conversion.
     2516      ///
     2517      /// This constructor initializes the iterator to be invalid.
     2518      /// \sa Invalid for more details.
     2519      TrueIt(Invalid) : Parent(INVALID), _map(0) {}
     2520
     2521      /// \brief Increment operator.
     2522      ///
     2523      /// Increment operator.
     2524      TrueIt& operator++() {
     2525        int pos = _map->position(*this);
     2526        Parent::operator=(pos > 0 ? _map->_array[pos - 1] : INVALID);
     2527        return *this;
     2528      }
     2529
     2530    private:
     2531      const IterableBoolMap* _map;
     2532    };
     2533
     2534    /// \brief Iterator for the keys mapped to \c false.
     2535    ///
     2536    /// Iterator for the keys mapped to \c false. It works
     2537    /// like a graph item iterator, it can be converted to
     2538    /// the key type of the map, incremented with \c ++ operator, and
     2539    /// if the iterator leaves the last valid key, it will be equal to
     2540    /// \c INVALID.
     2541    class FalseIt : public Key {
     2542    public:
     2543      typedef Key Parent;
     2544
     2545      /// \brief Creates an iterator.
     2546      ///
     2547      /// Creates an iterator. It iterates on the
     2548      /// keys mapped to \c false.
     2549      /// \param map The IterableBoolMap.
     2550      explicit FalseIt(const IterableBoolMap& map)
     2551        : Parent(map._sep < int(map._array.size()) ?
     2552                 map._array.back() : INVALID), _map(&map) {}
     2553
     2554      /// \brief Invalid constructor \& conversion.
     2555      ///
     2556      /// This constructor initializes the iterator to be invalid.
     2557      /// \sa Invalid for more details.
     2558      FalseIt(Invalid) : Parent(INVALID), _map(0) {}
     2559
     2560      /// \brief Increment operator.
     2561      ///
     2562      /// Increment operator.
     2563      FalseIt& operator++() {
     2564        int pos = _map->position(*this);
     2565        Parent::operator=(pos > _map->_sep ? _map->_array[pos - 1] : INVALID);
     2566        return *this;
     2567      }
     2568
     2569    private:
     2570      const IterableBoolMap* _map;
     2571    };
     2572
     2573    /// \brief Iterator for the keys mapped to a given value.
     2574    ///
     2575    /// Iterator for the keys mapped to a given value. It works
     2576    /// like a graph item iterator, it can be converted to
     2577    /// the key type of the map, incremented with \c ++ operator, and
     2578    /// if the iterator leaves the last valid key, it will be equal to
     2579    /// \c INVALID.
     2580    class ItemIt : public Key {
     2581    public:
     2582      typedef Key Parent;
     2583
     2584      /// \brief Creates an iterator with a value.
     2585      ///
     2586      /// Creates an iterator with a value. It iterates on the
     2587      /// keys mapped to the given value.
     2588      /// \param map The IterableBoolMap.
     2589      /// \param value The value.
     2590      ItemIt(const IterableBoolMap& map, bool value)
     2591        : Parent(value ?
     2592                 (map._sep > 0 ?
     2593                  map._array[map._sep - 1] : INVALID) :
     2594                 (map._sep < int(map._array.size()) ?
     2595                  map._array.back() : INVALID)), _map(&map) {}
     2596
     2597      /// \brief Invalid constructor \& conversion.
     2598      ///
     2599      /// This constructor initializes the iterator to be invalid.
     2600      /// \sa Invalid for more details.
     2601      ItemIt(Invalid) : Parent(INVALID), _map(0) {}
     2602
     2603      /// \brief Increment operator.
     2604      ///
     2605      /// Increment operator.
     2606      ItemIt& operator++() {
     2607        int pos = _map->position(*this);
     2608        int _sep = pos >= _map->_sep ? _map->_sep : 0;
     2609        Parent::operator=(pos > _sep ? _map->_array[pos - 1] : INVALID);
     2610        return *this;
     2611      }
     2612
     2613    private:
     2614      const IterableBoolMap* _map;
     2615    };
     2616
     2617  protected:
     2618
     2619    virtual void add(const Key& key) {
     2620      Parent::add(key);
     2621      Parent::set(key, _array.size());
     2622      _array.push_back(key);
     2623    }
     2624
     2625    virtual void add(const std::vector<Key>& keys) {
     2626      Parent::add(keys);
     2627      for (int i = 0; i < int(keys.size()); ++i) {
     2628        Parent::set(keys[i], _array.size());
     2629        _array.push_back(keys[i]);
     2630      }
     2631    }
     2632
     2633    virtual void erase(const Key& key) {
     2634      int pos = position(key);
     2635      if (pos < _sep) {
     2636        --_sep;
     2637        Parent::set(_array[_sep], pos);
     2638        _array[pos] = _array[_sep];
     2639        Parent::set(_array.back(), _sep);
     2640        _array[_sep] = _array.back();
     2641        _array.pop_back();
     2642      } else {
     2643        Parent::set(_array.back(), pos);
     2644        _array[pos] = _array.back();
     2645        _array.pop_back();
     2646      }
     2647      Parent::erase(key);
     2648    }
     2649
     2650    virtual void erase(const std::vector<Key>& keys) {
     2651      for (int i = 0; i < int(keys.size()); ++i) {
     2652        int pos = position(keys[i]);
     2653        if (pos < _sep) {
     2654          --_sep;
     2655          Parent::set(_array[_sep], pos);
     2656          _array[pos] = _array[_sep];
     2657          Parent::set(_array.back(), _sep);
     2658          _array[_sep] = _array.back();
     2659          _array.pop_back();
     2660        } else {
     2661          Parent::set(_array.back(), pos);
     2662          _array[pos] = _array.back();
     2663          _array.pop_back();
     2664        }
     2665      }
     2666      Parent::erase(keys);
     2667    }
     2668
     2669    virtual void build() {
     2670      Parent::build();
     2671      typename Parent::Notifier* nf = Parent::notifier();
     2672      Key it;
     2673      for (nf->first(it); it != INVALID; nf->next(it)) {
     2674        Parent::set(it, _array.size());
     2675        _array.push_back(it);
     2676      }
     2677      _sep = 0;
     2678    }
     2679
     2680    virtual void clear() {
     2681      _array.clear();
     2682      _sep = 0;
     2683      Parent::clear();
     2684    }
     2685
     2686  };
     2687
     2688
     2689  namespace _maps_bits {
     2690    template <typename Item>
     2691    struct IterableIntMapNode {
     2692      IterableIntMapNode() : value(-1) {}
     2693      IterableIntMapNode(int _value) : value(_value) {}
     2694      Item prev, next;
     2695      int value;
     2696    };
     2697  }
     2698
     2699  /// \brief Dynamic iterable integer map.
     2700  ///
     2701  /// This class provides a special graph map type which can store an
     2702  /// integer value for graph items (\c Node, \c Arc or \c Edge).
     2703  /// For each non-negative value it is possible to iterate on the keys
     2704  /// mapped to the value.
     2705  ///
     2706  /// This type is a reference map, so it can be modified with the
     2707  /// subscript operator.
     2708  ///
     2709  /// \note The size of the data structure depends on the largest
     2710  /// value in the map.
     2711  ///
     2712  /// \tparam GR The graph type.
     2713  /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
     2714  /// \c GR::Edge).
     2715  ///
     2716  /// \see IterableBoolMap, IterableValueMap
     2717  /// \see CrossRefMap
     2718  template <typename GR, typename K>
     2719  class IterableIntMap
     2720    : protected ItemSetTraits<GR, K>::
     2721        template Map<_maps_bits::IterableIntMapNode<K> >::Type {
     2722  public:
     2723    typedef typename ItemSetTraits<GR, K>::
     2724      template Map<_maps_bits::IterableIntMapNode<K> >::Type Parent;
     2725
     2726    /// The key type
     2727    typedef K Key;
     2728    /// The value type
     2729    typedef int Value;
     2730    /// The graph type
     2731    typedef GR Graph;
     2732
     2733    /// \brief Constructor of the map.
     2734    ///
     2735    /// Constructor of the map. It sets all values to -1.
     2736    explicit IterableIntMap(const Graph& graph)
     2737      : Parent(graph) {}
     2738
     2739    /// \brief Constructor of the map with a given value.
     2740    ///
     2741    /// Constructor of the map with a given value.
     2742    explicit IterableIntMap(const Graph& graph, int value)
     2743      : Parent(graph, _maps_bits::IterableIntMapNode<K>(value)) {
     2744      if (value >= 0) {
     2745        for (typename Parent::ItemIt it(*this); it != INVALID; ++it) {
     2746          lace(it);
     2747        }
     2748      }
     2749    }
     2750
     2751  private:
     2752
     2753    void unlace(const Key& key) {
     2754      typename Parent::Value& node = Parent::operator[](key);
     2755      if (node.value < 0) return;
     2756      if (node.prev != INVALID) {
     2757        Parent::operator[](node.prev).next = node.next;
     2758      } else {
     2759        _first[node.value] = node.next;
     2760      }
     2761      if (node.next != INVALID) {
     2762        Parent::operator[](node.next).prev = node.prev;
     2763      }
     2764      while (!_first.empty() && _first.back() == INVALID) {
     2765        _first.pop_back();
     2766      }
     2767    }
     2768
     2769    void lace(const Key& key) {
     2770      typename Parent::Value& node = Parent::operator[](key);
     2771      if (node.value < 0) return;
     2772      if (node.value >= int(_first.size())) {
     2773        _first.resize(node.value + 1, INVALID);
     2774      }
     2775      node.prev = INVALID;
     2776      node.next = _first[node.value];
     2777      if (node.next != INVALID) {
     2778        Parent::operator[](node.next).prev = key;
     2779      }
     2780      _first[node.value] = key;
     2781    }
     2782
     2783  public:
     2784
     2785    /// Indicates that the map is reference map.
     2786    typedef True ReferenceMapTag;
     2787
     2788    /// \brief Reference to the value of the map.
     2789    ///
     2790    /// This class is similar to the \c int type. It can
     2791    /// be converted to \c int and it has the same operators.
     2792    class Reference {
     2793      friend class IterableIntMap;
     2794    private:
     2795      Reference(IterableIntMap& map, const Key& key)
     2796        : _key(key), _map(map) {}
     2797    public:
     2798
     2799      Reference& operator=(const Reference& value) {
     2800        _map.set(_key, static_cast<const int&>(value));
     2801         return *this;
     2802      }
     2803
     2804      operator const int&() const {
     2805        return static_cast<const IterableIntMap&>(_map)[_key];
     2806      }
     2807
     2808      Reference& operator=(int value) {
     2809        _map.set(_key, value);
     2810        return *this;
     2811      }
     2812      Reference& operator++() {
     2813        _map.set(_key, _map[_key] + 1);
     2814        return *this;
     2815      }
     2816      int operator++(int) {
     2817        int value = _map[_key];
     2818        _map.set(_key, value + 1);
     2819        return value;
     2820      }
     2821      Reference& operator--() {
     2822        _map.set(_key, _map[_key] - 1);
     2823        return *this;
     2824      }
     2825      int operator--(int) {
     2826        int value = _map[_key];
     2827        _map.set(_key, value - 1);
     2828        return value;
     2829      }
     2830      Reference& operator+=(int value) {
     2831        _map.set(_key, _map[_key] + value);
     2832        return *this;
     2833      }
     2834      Reference& operator-=(int value) {
     2835        _map.set(_key, _map[_key] - value);
     2836        return *this;
     2837      }
     2838      Reference& operator*=(int value) {
     2839        _map.set(_key, _map[_key] * value);
     2840        return *this;
     2841      }
     2842      Reference& operator/=(int value) {
     2843        _map.set(_key, _map[_key] / value);
     2844        return *this;
     2845      }
     2846      Reference& operator%=(int value) {
     2847        _map.set(_key, _map[_key] % value);
     2848        return *this;
     2849      }
     2850      Reference& operator&=(int value) {
     2851        _map.set(_key, _map[_key] & value);
     2852        return *this;
     2853      }
     2854      Reference& operator|=(int value) {
     2855        _map.set(_key, _map[_key] | value);
     2856        return *this;
     2857      }
     2858      Reference& operator^=(int value) {
     2859        _map.set(_key, _map[_key] ^ value);
     2860        return *this;
     2861      }
     2862      Reference& operator<<=(int value) {
     2863        _map.set(_key, _map[_key] << value);
     2864        return *this;
     2865      }
     2866      Reference& operator>>=(int value) {
     2867        _map.set(_key, _map[_key] >> value);
     2868        return *this;
     2869      }
     2870
     2871    private:
     2872      Key _key;
     2873      IterableIntMap& _map;
     2874    };
     2875
     2876    /// The const reference type.
     2877    typedef const Value& ConstReference;
     2878
     2879    /// \brief Gives back the maximal value plus one.
     2880    ///
     2881    /// Gives back the maximal value plus one.
     2882    int size() const {
     2883      return _first.size();
     2884    }
     2885
     2886    /// \brief Set operation of the map.
     2887    ///
     2888    /// Set operation of the map.
     2889    void set(const Key& key, const Value& value) {
     2890      unlace(key);
     2891      Parent::operator[](key).value = value;
     2892      lace(key);
     2893    }
     2894
     2895    /// \brief Const subscript operator of the map.
     2896    ///
     2897    /// Const subscript operator of the map.
     2898    const Value& operator[](const Key& key) const {
     2899      return Parent::operator[](key).value;
     2900    }
     2901
     2902    /// \brief Subscript operator of the map.
     2903    ///
     2904    /// Subscript operator of the map.
     2905    Reference operator[](const Key& key) {
     2906      return Reference(*this, key);
     2907    }
     2908
     2909    /// \brief Iterator for the keys with the same value.
     2910    ///
     2911    /// Iterator for the keys with the same value. It works
     2912    /// like a graph item iterator, it can be converted to
     2913    /// the item type of the map, incremented with \c ++ operator, and
     2914    /// if the iterator leaves the last valid item, it will be equal to
     2915    /// \c INVALID.
     2916    class ItemIt : public Key {
     2917    public:
     2918      typedef Key Parent;
     2919
     2920      /// \brief Invalid constructor \& conversion.
     2921      ///
     2922      /// This constructor initializes the iterator to be invalid.
     2923      /// \sa Invalid for more details.
     2924      ItemIt(Invalid) : Parent(INVALID), _map(0) {}
     2925
     2926      /// \brief Creates an iterator with a value.
     2927      ///
     2928      /// Creates an iterator with a value. It iterates on the
     2929      /// keys mapped to the given value.
     2930      /// \param map The IterableIntMap.
     2931      /// \param value The value.
     2932      ItemIt(const IterableIntMap& map, int value) : _map(&map) {
     2933        if (value < 0 || value >= int(_map->_first.size())) {
     2934          Parent::operator=(INVALID);
     2935        } else {
     2936          Parent::operator=(_map->_first[value]);
     2937        }
     2938      }
     2939
     2940      /// \brief Increment operator.
     2941      ///
     2942      /// Increment operator.
     2943      ItemIt& operator++() {
     2944        Parent::operator=(_map->IterableIntMap::Parent::
     2945                          operator[](static_cast<Parent&>(*this)).next);
     2946        return *this;
     2947      }
     2948
     2949    private:
     2950      const IterableIntMap* _map;
     2951    };
     2952
     2953  protected:
     2954
     2955    virtual void erase(const Key& key) {
     2956      unlace(key);
     2957      Parent::erase(key);
     2958    }
     2959
     2960    virtual void erase(const std::vector<Key>& keys) {
     2961      for (int i = 0; i < int(keys.size()); ++i) {
     2962        unlace(keys[i]);
     2963      }
     2964      Parent::erase(keys);
     2965    }
     2966
     2967    virtual void clear() {
     2968      _first.clear();
     2969      Parent::clear();
     2970    }
     2971
     2972  private:
     2973    std::vector<Key> _first;
     2974  };
     2975
     2976  namespace _maps_bits {
     2977    template <typename Item, typename Value>
     2978    struct IterableValueMapNode {
     2979      IterableValueMapNode(Value _value = Value()) : value(_value) {}
     2980      Item prev, next;
     2981      Value value;
     2982    };
     2983  }
     2984
     2985  /// \brief Dynamic iterable map for comparable values.
     2986  ///
     2987  /// This class provides a special graph map type which can store an
     2988  /// comparable value for graph items (\c Node, \c Arc or \c Edge).
     2989  /// For each value it is possible to iterate on the keys mapped to
     2990  /// the value.
     2991  ///
     2992  /// The map stores for each value a linked list with
     2993  /// the items which mapped to the value, and the values are stored
     2994  /// in balanced binary tree. The values of the map can be accessed
     2995  /// with stl compatible forward iterator.
     2996  ///
     2997  /// This type is not reference map, so it cannot be modified with
     2998  /// the subscript operator.
     2999  ///
     3000  /// \tparam GR The graph type.
     3001  /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
     3002  /// \c GR::Edge).
     3003  /// \tparam V The value type of the map. It can be any comparable
     3004  /// value type.
     3005  ///
     3006  /// \see IterableBoolMap, IterableIntMap
     3007  /// \see CrossRefMap
     3008  template <typename GR, typename K, typename V>
     3009  class IterableValueMap
     3010    : protected ItemSetTraits<GR, K>::
     3011        template Map<_maps_bits::IterableValueMapNode<K, V> >::Type {
     3012  public:
     3013    typedef typename ItemSetTraits<GR, K>::
     3014      template Map<_maps_bits::IterableValueMapNode<K, V> >::Type Parent;
     3015
     3016    /// The key type
     3017    typedef K Key;
     3018    /// The value type
     3019    typedef V Value;
     3020    /// The graph type
     3021    typedef GR Graph;
     3022
     3023  public:
     3024
     3025    /// \brief Constructor of the map with a given value.
     3026    ///
     3027    /// Constructor of the map with a given value.
     3028    explicit IterableValueMap(const Graph& graph,
     3029                              const Value& value = Value())
     3030      : Parent(graph, _maps_bits::IterableValueMapNode<K, V>(value)) {
     3031      for (typename Parent::ItemIt it(*this); it != INVALID; ++it) {
     3032        lace(it);
     3033      }
     3034    }
     3035
     3036  protected:
     3037
     3038    void unlace(const Key& key) {
     3039      typename Parent::Value& node = Parent::operator[](key);
     3040      if (node.prev != INVALID) {
     3041        Parent::operator[](node.prev).next = node.next;
     3042      } else {
     3043        if (node.next != INVALID) {
     3044          _first[node.value] = node.next;
     3045        } else {
     3046          _first.erase(node.value);
     3047        }
     3048      }
     3049      if (node.next != INVALID) {
     3050        Parent::operator[](node.next).prev = node.prev;
     3051      }
     3052    }
     3053
     3054    void lace(const Key& key) {
     3055      typename Parent::Value& node = Parent::operator[](key);
     3056      typename std::map<Value, Key>::iterator it = _first.find(node.value);
     3057      if (it == _first.end()) {
     3058        node.prev = node.next = INVALID;
     3059        _first.insert(std::make_pair(node.value, key));
     3060      } else {
     3061        node.prev = INVALID;
     3062        node.next = it->second;
     3063        if (node.next != INVALID) {
     3064          Parent::operator[](node.next).prev = key;
     3065        }
     3066        it->second = key;
     3067      }
     3068    }
     3069
     3070  public:
     3071
     3072    /// \brief Forward iterator for values.
     3073    ///
     3074    /// This iterator is an stl compatible forward
     3075    /// iterator on the values of the map. The values can
     3076    /// be accessed in the <tt>[beginValue, endValue)</tt> range.
     3077    class ValueIterator
     3078      : public std::iterator<std::forward_iterator_tag, Value> {
     3079      friend class IterableValueMap;
     3080    private:
     3081      ValueIterator(typename std::map<Value, Key>::const_iterator _it)
     3082        : it(_it) {}
     3083    public:
     3084
     3085      ValueIterator() {}
     3086
     3087      ValueIterator& operator++() { ++it; return *this; }
     3088      ValueIterator operator++(int) {
     3089        ValueIterator tmp(*this);
     3090        operator++();
     3091        return tmp;
     3092      }
     3093
     3094      const Value& operator*() const { return it->first; }
     3095      const Value* operator->() const { return &(it->first); }
     3096
     3097      bool operator==(ValueIterator jt) const { return it == jt.it; }
     3098      bool operator!=(ValueIterator jt) const { return it != jt.it; }
     3099
     3100    private:
     3101      typename std::map<Value, Key>::const_iterator it;
     3102    };
     3103
     3104    /// \brief Returns an iterator to the first value.
     3105    ///
     3106    /// Returns an stl compatible iterator to the
     3107    /// first value of the map. The values of the
     3108    /// map can be accessed in the <tt>[beginValue, endValue)</tt>
     3109    /// range.
     3110    ValueIterator beginValue() const {
     3111      return ValueIterator(_first.begin());
     3112    }
     3113
     3114    /// \brief Returns an iterator after the last value.
     3115    ///
     3116    /// Returns an stl compatible iterator after the
     3117    /// last value of the map. The values of the
     3118    /// map can be accessed in the <tt>[beginValue, endValue)</tt>
     3119    /// range.
     3120    ValueIterator endValue() const {
     3121      return ValueIterator(_first.end());
     3122    }
     3123
     3124    /// \brief Set operation of the map.
     3125    ///
     3126    /// Set operation of the map.
     3127    void set(const Key& key, const Value& value) {
     3128      unlace(key);
     3129      Parent::operator[](key).value = value;
     3130      lace(key);
     3131    }
     3132
     3133    /// \brief Const subscript operator of the map.
     3134    ///
     3135    /// Const subscript operator of the map.
     3136    const Value& operator[](const Key& key) const {
     3137      return Parent::operator[](key).value;
     3138    }
     3139
     3140    /// \brief Iterator for the keys with the same value.
     3141    ///
     3142    /// Iterator for the keys with the same value. It works
     3143    /// like a graph item iterator, it can be converted to
     3144    /// the item type of the map, incremented with \c ++ operator, and
     3145    /// if the iterator leaves the last valid item, it will be equal to
     3146    /// \c INVALID.
     3147    class ItemIt : public Key {
     3148    public:
     3149      typedef Key Parent;
     3150
     3151      /// \brief Invalid constructor \& conversion.
     3152      ///
     3153      /// This constructor initializes the iterator to be invalid.
     3154      /// \sa Invalid for more details.
     3155      ItemIt(Invalid) : Parent(INVALID), _map(0) {}
     3156
     3157      /// \brief Creates an iterator with a value.
     3158      ///
     3159      /// Creates an iterator with a value. It iterates on the
     3160      /// keys which have the given value.
     3161      /// \param map The IterableValueMap
     3162      /// \param value The value
     3163      ItemIt(const IterableValueMap& map, const Value& value) : _map(&map) {
     3164        typename std::map<Value, Key>::const_iterator it =
     3165          map._first.find(value);
     3166        if (it == map._first.end()) {
     3167          Parent::operator=(INVALID);
     3168        } else {
     3169          Parent::operator=(it->second);
     3170        }
     3171      }
     3172
     3173      /// \brief Increment operator.
     3174      ///
     3175      /// Increment Operator.
     3176      ItemIt& operator++() {
     3177        Parent::operator=(_map->IterableValueMap::Parent::
     3178                          operator[](static_cast<Parent&>(*this)).next);
     3179        return *this;
     3180      }
     3181
     3182
     3183    private:
     3184      const IterableValueMap* _map;
     3185    };
     3186
     3187  protected:
     3188
     3189    virtual void add(const Key& key) {
     3190      Parent::add(key);
     3191      unlace(key);
     3192    }
     3193
     3194    virtual void add(const std::vector<Key>& keys) {
     3195      Parent::add(keys);
     3196      for (int i = 0; i < int(keys.size()); ++i) {
     3197        lace(keys[i]);
     3198      }
     3199    }
     3200
     3201    virtual void erase(const Key& key) {
     3202      unlace(key);
     3203      Parent::erase(key);
     3204    }
     3205
     3206    virtual void erase(const std::vector<Key>& keys) {
     3207      for (int i = 0; i < int(keys.size()); ++i) {
     3208        unlace(keys[i]);
     3209      }
     3210      Parent::erase(keys);
     3211    }
     3212
     3213    virtual void build() {
     3214      Parent::build();
     3215      for (typename Parent::ItemIt it(*this); it != INVALID; ++it) {
     3216        lace(it);
     3217      }
     3218    }
     3219
     3220    virtual void clear() {
     3221      _first.clear();
     3222      Parent::clear();
     3223    }
     3224
     3225  private:
     3226    std::map<Value, Key> _first;
     3227  };
     3228
    23143229  /// \brief Map of the source nodes of arcs in a digraph.
    23153230  ///
     
    24813396  /// whenever the digraph changes.
    24823397  ///
    2483   /// \warning Besides \c addNode() and \c addArc(), a digraph structure 
     3398  /// \warning Besides \c addNode() and \c addArc(), a digraph structure
    24843399  /// may provide alternative ways to modify the digraph.
    24853400  /// The correct behavior of InDegMap is not guarantied if these additional
     
    24973412
    24983413  public:
    2499    
     3414
    25003415    /// The graph type of InDegMap
    25013416    typedef GR Graph;
     
    26113526  /// whenever the digraph changes.
    26123527  ///
    2613   /// \warning Besides \c addNode() and \c addArc(), a digraph structure 
     3528  /// \warning Besides \c addNode() and \c addArc(), a digraph structure
    26143529  /// may provide alternative ways to modify the digraph.
    26153530  /// The correct behavior of OutDegMap is not guarantied if these additional
Note: See TracChangeset for help on using the changeset viewer.