COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/core.h

    r220 r319  
    2525#include <lemon/bits/enable_if.h>
    2626#include <lemon/bits/traits.h>
     27#include <lemon/assert.h>
    2728
    2829///\file
    2930///\brief LEMON core utilities.
     31///
     32///This header file contains core utilities for LEMON.
     33///It is automatically included by all graph types, therefore it usually
     34///do not have to be included directly.
    3035
    3136namespace lemon {
     
    5560  /// @{
    5661
    57   ///Creates convenience typedefs for the digraph types and iterators
    58 
    59   ///This \c \#define creates convenience typedefs for the following types
    60   ///of \c Digraph: \c Node,  \c NodeIt, \c Arc, \c ArcIt, \c InArcIt,
     62  ///Create convenience typedefs for the digraph types and iterators
     63
     64  ///This \c \#define creates convenient type definitions for the following
     65  ///types of \c Digraph: \c Node,  \c NodeIt, \c Arc, \c ArcIt, \c InArcIt,
    6166  ///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap,
    6267  ///\c BoolArcMap, \c IntArcMap, \c DoubleArcMap.
     
    7984  typedef Digraph::ArcMap<double> DoubleArcMap
    8085
    81   ///Creates convenience typedefs for the digraph types and iterators
     86  ///Create convenience typedefs for the digraph types and iterators
    8287
    8388  ///\see DIGRAPH_TYPEDEFS
     
    99104  typedef typename Digraph::template ArcMap<double> DoubleArcMap
    100105
    101   ///Creates convenience typedefs for the graph types and iterators
    102 
    103   ///This \c \#define creates the same convenience typedefs as defined
     106  ///Create convenience typedefs for the graph types and iterators
     107
     108  ///This \c \#define creates the same convenient type definitions as defined
    104109  ///by \ref DIGRAPH_TYPEDEFS(Graph) and six more, namely it creates
    105110  ///\c Edge, \c EdgeIt, \c IncEdgeIt, \c BoolEdgeMap, \c IntEdgeMap,
     
    107112  ///
    108113  ///\note If the graph type is a dependent type, ie. the graph type depend
    109   ///on a template parameter, then use \c TEMPLATE_DIGRAPH_TYPEDEFS()
     114  ///on a template parameter, then use \c TEMPLATE_GRAPH_TYPEDEFS()
    110115  ///macro.
    111116#define GRAPH_TYPEDEFS(Graph)                                           \
     
    118123  typedef Graph::EdgeMap<double> DoubleEdgeMap
    119124
    120   ///Creates convenience typedefs for the graph types and iterators
     125  ///Create convenience typedefs for the graph types and iterators
    121126
    122127  ///\see GRAPH_TYPEDEFS
     
    133138  typedef typename Graph::template EdgeMap<double> DoubleEdgeMap
    134139
    135   /// \brief Function to count the items in the graph.
    136   ///
    137   /// This function counts the items (nodes, arcs etc) in the graph.
    138   /// The complexity of the function is O(n) because
     140  /// \brief Function to count the items in a graph.
     141  ///
     142  /// This function counts the items (nodes, arcs etc.) in a graph.
     143  /// The complexity of the function is linear because
    139144  /// it iterates on all of the items.
    140145  template <typename Graph, typename Item>
     
    173178  ///
    174179  /// This function counts the nodes in the graph.
    175   /// The complexity of the function is O(n) but for some
    176   /// graph structures it is specialized to run in O(1).
    177   ///
    178   /// If the graph contains a \e nodeNum() member function and a
    179   /// \e NodeNumTag tag then this function calls directly the member
     180  /// The complexity of the function is <em>O</em>(<em>n</em>), but for some
     181  /// graph structures it is specialized to run in <em>O</em>(1).
     182  ///
     183  /// \note If the graph contains a \c nodeNum() member function and a
     184  /// \c NodeNumTag tag then this function calls directly the member
    180185  /// function to query the cardinality of the node set.
    181186  template <typename Graph>
     
    209214  ///
    210215  /// This function counts the arcs in the graph.
    211   /// The complexity of the function is O(e) but for some
    212   /// graph structures it is specialized to run in O(1).
    213   ///
    214   /// If the graph contains a \e arcNum() member function and a
    215   /// \e EdgeNumTag tag then this function calls directly the member
     216  /// The complexity of the function is <em>O</em>(<em>m</em>), but for some
     217  /// graph structures it is specialized to run in <em>O</em>(1).
     218  ///
     219  /// \note If the graph contains a \c arcNum() member function and a
     220  /// \c ArcNumTag tag then this function calls directly the member
    216221  /// function to query the cardinality of the arc set.
    217222  template <typename Graph>
     
    221226
    222227  // Edge counting:
     228
    223229  namespace _core_bits {
    224230
     
    244250  ///
    245251  /// This function counts the edges in the graph.
    246   /// The complexity of the function is O(m) but for some
    247   /// graph structures it is specialized to run in O(1).
    248   ///
    249   /// If the graph contains a \e edgeNum() member function and a
    250   /// \e EdgeNumTag tag then this function calls directly the member
     252  /// The complexity of the function is <em>O</em>(<em>m</em>), but for some
     253  /// graph structures it is specialized to run in <em>O</em>(1).
     254  ///
     255  /// \note If the graph contains a \c edgeNum() member function and a
     256  /// \c EdgeNumTag tag then this function calls directly the member
    251257  /// function to query the cardinality of the edge set.
    252258  template <typename Graph>
     
    269275  ///
    270276  /// This function counts the number of the out-arcs from node \c n
    271   /// in the graph.
     277  /// in the graph \c g.
    272278  template <typename Graph>
    273   inline int countOutArcs(const Graph& _g,  const typename Graph::Node& _n) {
    274     return countNodeDegree<Graph, typename Graph::OutArcIt>(_g, _n);
     279  inline int countOutArcs(const Graph& g,  const typename Graph::Node& n) {
     280    return countNodeDegree<Graph, typename Graph::OutArcIt>(g, n);
    275281  }
    276282
     
    278284  ///
    279285  /// This function counts the number of the in-arcs to node \c n
    280   /// in the graph.
     286  /// in the graph \c g.
    281287  template <typename Graph>
    282   inline int countInArcs(const Graph& _g,  const typename Graph::Node& _n) {
    283     return countNodeDegree<Graph, typename Graph::InArcIt>(_g, _n);
     288  inline int countInArcs(const Graph& g,  const typename Graph::Node& n) {
     289    return countNodeDegree<Graph, typename Graph::InArcIt>(g, n);
    284290  }
    285291
     
    287293  ///
    288294  /// This function counts the number of the inc-edges to node \c n
    289   /// in the graph.
     295  /// in the undirected graph \c g.
    290296  template <typename Graph>
    291   inline int countIncEdges(const Graph& _g,  const typename Graph::Node& _n) {
    292     return countNodeDegree<Graph, typename Graph::IncEdgeIt>(_g, _n);
     297  inline int countIncEdges(const Graph& g,  const typename Graph::Node& n) {
     298    return countNodeDegree<Graph, typename Graph::IncEdgeIt>(g, n);
    293299  }
    294300
     
    304310
    305311    template <typename Digraph, typename Item, typename RefMap,
    306               typename ToMap, typename FromMap>
     312              typename FromMap, typename ToMap>
    307313    class MapCopy : public MapCopyBase<Digraph, Item, RefMap> {
    308314    public:
    309315
    310       MapCopy(ToMap& tmap, const FromMap& map)
    311         : _tmap(tmap), _map(map) {}
     316      MapCopy(const FromMap& map, ToMap& tmap)
     317        : _map(map), _tmap(tmap) {}
    312318
    313319      virtual void copy(const Digraph& digraph, const RefMap& refMap) {
     
    319325
    320326    private:
     327      const FromMap& _map;
    321328      ToMap& _tmap;
    322       const FromMap& _map;
    323329    };
    324330
     
    327333    public:
    328334
    329       ItemCopy(It& it, const Item& item) : _it(it), _item(item) {}
     335      ItemCopy(const Item& item, It& it) : _item(item), _it(it) {}
    330336
    331337      virtual void copy(const Digraph&, const RefMap& refMap) {
     
    334340
    335341    private:
     342      Item _item;
    336343      It& _it;
    337       Item _item;
    338344    };
    339345
     
    376382    struct DigraphCopySelector {
    377383      template <typename From, typename NodeRefMap, typename ArcRefMap>
    378       static void copy(Digraph &to, const From& from,
     384      static void copy(const From& from, Digraph &to,
    379385                       NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) {
    380386        for (typename From::NodeIt it(from); it != INVALID; ++it) {
     
    394400    {
    395401      template <typename From, typename NodeRefMap, typename ArcRefMap>
    396       static void copy(Digraph &to, const From& from,
     402      static void copy(const From& from, Digraph &to,
    397403                       NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) {
    398404        to.build(from, nodeRefMap, arcRefMap);
     
    403409    struct GraphCopySelector {
    404410      template <typename From, typename NodeRefMap, typename EdgeRefMap>
    405       static void copy(Graph &to, const From& from,
     411      static void copy(const From& from, Graph &to,
    406412                       NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) {
    407413        for (typename From::NodeIt it(from); it != INVALID; ++it) {
     
    421427    {
    422428      template <typename From, typename NodeRefMap, typename EdgeRefMap>
    423       static void copy(Graph &to, const From& from,
     429      static void copy(const From& from, Graph &to,
    424430                       NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) {
    425431        to.build(from, nodeRefMap, edgeRefMap);
     
    432438  ///
    433439  /// Class to copy a digraph to another digraph (duplicate a digraph). The
    434   /// simplest way of using it is through the \c copyDigraph() function.
    435   ///
    436   /// This class not just make a copy of a graph, but it can create
     440  /// simplest way of using it is through the \c digraphCopy() function.
     441  ///
     442  /// This class not only make a copy of a digraph, but it can create
    437443  /// references and cross references between the nodes and arcs of
    438   /// the two graphs, it can copy maps for use with the newly created
    439   /// graph and copy nodes and arcs.
    440   ///
    441   /// To make a copy from a graph, first an instance of DigraphCopy
    442   /// should be created, then the data belongs to the graph should
     444  /// the two digraphs, and it can copy maps to use with the newly created
     445  /// digraph.
     446  ///
     447  /// To make a copy from a digraph, first an instance of DigraphCopy
     448  /// should be created, then the data belongs to the digraph should
    443449  /// assigned to copy. In the end, the \c run() member should be
    444450  /// called.
    445451  ///
    446   /// The next code copies a graph with several data:
     452  /// The next code copies a digraph with several data:
    447453  ///\code
    448   ///  DigraphCopy<NewGraph, OrigGraph> dc(new_graph, orig_graph);
    449   ///  // create a reference for the nodes
     454  ///  DigraphCopy<OrigGraph, NewGraph> cg(orig_graph, new_graph);
     455  ///  // Create references for the nodes
    450456  ///  OrigGraph::NodeMap<NewGraph::Node> nr(orig_graph);
    451   ///  dc.nodeRef(nr);
    452   ///  // create a cross reference (inverse) for the arcs
     457  ///  cg.nodeRef(nr);
     458  ///  // Create cross references (inverse) for the arcs
    453459  ///  NewGraph::ArcMap<OrigGraph::Arc> acr(new_graph);
    454   ///  dc.arcCrossRef(acr);
    455   ///  // copy an arc map
     460  ///  cg.arcCrossRef(acr);
     461  ///  // Copy an arc map
    456462  ///  OrigGraph::ArcMap<double> oamap(orig_graph);
    457463  ///  NewGraph::ArcMap<double> namap(new_graph);
    458   ///  dc.arcMap(namap, oamap);
    459   ///  // copy a node
     464  ///  cg.arcMap(oamap, namap);
     465  ///  // Copy a node
    460466  ///  OrigGraph::Node on;
    461467  ///  NewGraph::Node nn;
    462   ///  dc.node(nn, on);
    463   ///  // Executions of copy
    464   ///  dc.run();
     468  ///  cg.node(on, nn);
     469  ///  // Execute copying
     470  ///  cg.run();
    465471  ///\endcode
    466   template <typename To, typename From>
     472  template <typename From, typename To>
    467473  class DigraphCopy {
    468474  private:
     
    479485    typedef typename From::template ArcMap<TArc> ArcRefMap;
    480486
    481 
    482487  public:
    483488
    484 
    485     /// \brief Constructor for the DigraphCopy.
    486     ///
    487     /// It copies the content of the \c _from digraph into the
    488     /// \c _to digraph.
    489     DigraphCopy(To& to, const From& from)
     489    /// \brief Constructor of DigraphCopy.
     490    ///
     491    /// Constructor of DigraphCopy for copying the content of the
     492    /// \c from digraph into the \c to digraph.
     493    DigraphCopy(const From& from, To& to)
    490494      : _from(from), _to(to) {}
    491495
    492     /// \brief Destructor of the DigraphCopy
    493     ///
    494     /// Destructor of the DigraphCopy
     496    /// \brief Destructor of DigraphCopy
     497    ///
     498    /// Destructor of DigraphCopy.
    495499    ~DigraphCopy() {
    496500      for (int i = 0; i < int(_node_maps.size()); ++i) {
     
    503507    }
    504508
    505     /// \brief Copies the node references into the given map.
    506     ///
    507     /// Copies the node references into the given map. The parameter
    508     /// should be a map, which key type is the Node type of the source
    509     /// graph, while the value type is the Node type of the
    510     /// destination graph.
     509    /// \brief Copy the node references into the given map.
     510    ///
     511    /// This function copies the node references into the given map.
     512    /// The parameter should be a map, whose key type is the Node type of
     513    /// the source digraph, while the value type is the Node type of the
     514    /// destination digraph.
    511515    template <typename NodeRef>
    512516    DigraphCopy& nodeRef(NodeRef& map) {
     
    516520    }
    517521
    518     /// \brief Copies the node cross references into the given map.
    519     ///
    520     ///  Copies the node cross references (reverse references) into
    521     ///  the given map. The parameter should be a map, which key type
    522     ///  is the Node type of the destination graph, while the value type is
    523     ///  the Node type of the source graph.
     522    /// \brief Copy the node cross references into the given map.
     523    ///
     524    /// This function copies the node cross references (reverse references)
     525    /// into the given map. The parameter should be a map, whose key type
     526    /// is the Node type of the destination digraph, while the value type is
     527    /// the Node type of the source digraph.
    524528    template <typename NodeCrossRef>
    525529    DigraphCopy& nodeCrossRef(NodeCrossRef& map) {
     
    529533    }
    530534
    531     /// \brief Make copy of the given map.
    532     ///
    533     /// Makes copy of the given map for the newly created digraph.
    534     /// The new map's key type is the destination graph's node type,
    535     /// and the copied map's key type is the source graph's node type.
    536     template <typename ToMap, typename FromMap>
    537     DigraphCopy& nodeMap(ToMap& tmap, const FromMap& map) {
     535    /// \brief Make a copy of the given node map.
     536    ///
     537    /// This function makes a copy of the given node map for the newly
     538    /// created digraph.
     539    /// The key type of the new map \c tmap should be the Node type of the
     540    /// destination digraph, and the key type of the original map \c map
     541    /// should be the Node type of the source digraph.
     542    template <typename FromMap, typename ToMap>
     543    DigraphCopy& nodeMap(const FromMap& map, ToMap& tmap) {
    538544      _node_maps.push_back(new _core_bits::MapCopy<From, Node,
    539                            NodeRefMap, ToMap, FromMap>(tmap, map));
     545                           NodeRefMap, FromMap, ToMap>(map, tmap));
    540546      return *this;
    541547    }
     
    543549    /// \brief Make a copy of the given node.
    544550    ///
    545     /// Make a copy of the given node.
    546     DigraphCopy& node(TNode& tnode, const Node& snode) {
     551    /// This function makes a copy of the given node.
     552    DigraphCopy& node(const Node& node, TNode& tnode) {
    547553      _node_maps.push_back(new _core_bits::ItemCopy<From, Node,
    548                            NodeRefMap, TNode>(tnode, snode));
    549       return *this;
    550     }
    551 
    552     /// \brief Copies the arc references into the given map.
    553     ///
    554     /// Copies the arc references into the given map.
     554                           NodeRefMap, TNode>(node, tnode));
     555      return *this;
     556    }
     557
     558    /// \brief Copy the arc references into the given map.
     559    ///
     560    /// This function copies the arc references into the given map.
     561    /// The parameter should be a map, whose key type is the Arc type of
     562    /// the source digraph, while the value type is the Arc type of the
     563    /// destination digraph.
    555564    template <typename ArcRef>
    556565    DigraphCopy& arcRef(ArcRef& map) {
     
    560569    }
    561570
    562     /// \brief Copies the arc cross references into the given map.
    563     ///
    564     ///  Copies the arc cross references (reverse references) into
    565     ///  the given map.
     571    /// \brief Copy the arc cross references into the given map.
     572    ///
     573    /// This function copies the arc cross references (reverse references)
     574    /// into the given map. The parameter should be a map, whose key type
     575    /// is the Arc type of the destination digraph, while the value type is
     576    /// the Arc type of the source digraph.
    566577    template <typename ArcCrossRef>
    567578    DigraphCopy& arcCrossRef(ArcCrossRef& map) {
     
    571582    }
    572583
    573     /// \brief Make copy of the given map.
    574     ///
    575     /// Makes copy of the given map for the newly created digraph.
    576     /// The new map's key type is the to digraph's arc type,
    577     /// and the copied map's key type is the from digraph's arc
    578     /// type.
    579     template <typename ToMap, typename FromMap>
    580     DigraphCopy& arcMap(ToMap& tmap, const FromMap& map) {
     584    /// \brief Make a copy of the given arc map.
     585    ///
     586    /// This function makes a copy of the given arc map for the newly
     587    /// created digraph.
     588    /// The key type of the new map \c tmap should be the Arc type of the
     589    /// destination digraph, and the key type of the original map \c map
     590    /// should be the Arc type of the source digraph.
     591    template <typename FromMap, typename ToMap>
     592    DigraphCopy& arcMap(const FromMap& map, ToMap& tmap) {
    581593      _arc_maps.push_back(new _core_bits::MapCopy<From, Arc,
    582                           ArcRefMap, ToMap, FromMap>(tmap, map));
     594                          ArcRefMap, FromMap, ToMap>(map, tmap));
    583595      return *this;
    584596    }
     
    586598    /// \brief Make a copy of the given arc.
    587599    ///
    588     /// Make a copy of the given arc.
    589     DigraphCopy& arc(TArc& tarc, const Arc& sarc) {
     600    /// This function makes a copy of the given arc.
     601    DigraphCopy& arc(const Arc& arc, TArc& tarc) {
    590602      _arc_maps.push_back(new _core_bits::ItemCopy<From, Arc,
    591                           ArcRefMap, TArc>(tarc, sarc));
    592       return *this;
    593     }
    594 
    595     /// \brief Executes the copies.
    596     ///
    597     /// Executes the copies.
     603                          ArcRefMap, TArc>(arc, tarc));
     604      return *this;
     605    }
     606
     607    /// \brief Execute copying.
     608    ///
     609    /// This function executes the copying of the digraph along with the
     610    /// copying of the assigned data.
    598611    void run() {
    599612      NodeRefMap nodeRefMap(_from);
    600613      ArcRefMap arcRefMap(_from);
    601614      _core_bits::DigraphCopySelector<To>::
    602         copy(_to, _from, nodeRefMap, arcRefMap);
     615        copy(_from, _to, nodeRefMap, arcRefMap);
    603616      for (int i = 0; i < int(_node_maps.size()); ++i) {
    604617        _node_maps[i]->copy(_from, nodeRefMap);
     
    611624  protected:
    612625
    613 
    614626    const From& _from;
    615627    To& _to;
    616628
    617629    std::vector<_core_bits::MapCopyBase<From, Node, NodeRefMap>* >
    618     _node_maps;
     630      _node_maps;
    619631
    620632    std::vector<_core_bits::MapCopyBase<From, Arc, ArcRefMap>* >
    621     _arc_maps;
     633      _arc_maps;
    622634
    623635  };
     
    625637  /// \brief Copy a digraph to another digraph.
    626638  ///
    627   /// Copy a digraph to another digraph. The complete usage of the
    628   /// function is detailed in the DigraphCopy class, but a short
    629   /// example shows a basic work:
     639  /// This function copies a digraph to another digraph.
     640  /// The complete usage of it is detailed in the DigraphCopy class, but
     641  /// a short example shows a basic work:
    630642  ///\code
    631   /// copyDigraph(trg, src).nodeRef(nr).arcCrossRef(ecr).run();
     643  /// digraphCopy(src, trg).nodeRef(nr).arcCrossRef(acr).run();
    632644  ///\endcode
    633645  ///
    634646  /// After the copy the \c nr map will contain the mapping from the
    635647  /// nodes of the \c from digraph to the nodes of the \c to digraph and
    636   /// \c ecr will contain the mapping from the arcs of the \c to digraph
     648  /// \c acr will contain the mapping from the arcs of the \c to digraph
    637649  /// to the arcs of the \c from digraph.
    638650  ///
    639651  /// \see DigraphCopy
    640   template <typename To, typename From>
    641   DigraphCopy<To, From> copyDigraph(To& to, const From& from) {
    642     return DigraphCopy<To, From>(to, from);
     652  template <typename From, typename To>
     653  DigraphCopy<From, To> digraphCopy(const From& from, To& to) {
     654    return DigraphCopy<From, To>(from, to);
    643655  }
    644656
     
    646658  ///
    647659  /// Class to copy a graph to another graph (duplicate a graph). The
    648   /// simplest way of using it is through the \c copyGraph() function.
    649   ///
    650   /// This class not just make a copy of a graph, but it can create
     660  /// simplest way of using it is through the \c graphCopy() function.
     661  ///
     662  /// This class not only make a copy of a graph, but it can create
    651663  /// references and cross references between the nodes, edges and arcs of
    652   /// the two graphs, it can copy maps for use with the newly created
    653   /// graph and copy nodes, edges and arcs.
     664  /// the two graphs, and it can copy maps for using with the newly created
     665  /// graph.
    654666  ///
    655667  /// To make a copy from a graph, first an instance of GraphCopy
     
    660672  /// The next code copies a graph with several data:
    661673  ///\code
    662   ///  GraphCopy<NewGraph, OrigGraph> dc(new_graph, orig_graph);
    663   ///  // create a reference for the nodes
     674  ///  GraphCopy<OrigGraph, NewGraph> cg(orig_graph, new_graph);
     675  ///  // Create references for the nodes
    664676  ///  OrigGraph::NodeMap<NewGraph::Node> nr(orig_graph);
    665   ///  dc.nodeRef(nr);
    666   ///  // create a cross reference (inverse) for the edges
    667   ///  NewGraph::EdgeMap<OrigGraph::Arc> ecr(new_graph);
    668   ///  dc.edgeCrossRef(ecr);
    669   ///  // copy an arc map
    670   ///  OrigGraph::ArcMap<double> oamap(orig_graph);
    671   ///  NewGraph::ArcMap<double> namap(new_graph);
    672   ///  dc.arcMap(namap, oamap);
    673   ///  // copy a node
     677  ///  cg.nodeRef(nr);
     678  ///  // Create cross references (inverse) for the edges
     679  ///  NewGraph::EdgeMap<OrigGraph::Edge> ecr(new_graph);
     680  ///  cg.edgeCrossRef(ecr);
     681  ///  // Copy an edge map
     682  ///  OrigGraph::EdgeMap<double> oemap(orig_graph);
     683  ///  NewGraph::EdgeMap<double> nemap(new_graph);
     684  ///  cg.edgeMap(oemap, nemap);
     685  ///  // Copy a node
    674686  ///  OrigGraph::Node on;
    675687  ///  NewGraph::Node nn;
    676   ///  dc.node(nn, on);
    677   ///  // Executions of copy
    678   ///  dc.run();
     688  ///  cg.node(on, nn);
     689  ///  // Execute copying
     690  ///  cg.run();
    679691  ///\endcode
    680   template <typename To, typename From>
     692  template <typename From, typename To>
    681693  class GraphCopy {
    682694  private:
     
    697709
    698710    struct ArcRefMap {
    699       ArcRefMap(const To& to, const From& from,
     711      ArcRefMap(const From& from, const To& to,
    700712                const EdgeRefMap& edge_ref, const NodeRefMap& node_ref)
    701         : _to(to), _from(from),
     713        : _from(from), _to(to),
    702714          _edge_ref(edge_ref), _node_ref(node_ref) {}
    703715
     
    713725      }
    714726
     727      const From& _from;
    715728      const To& _to;
    716       const From& _from;
    717729      const EdgeRefMap& _edge_ref;
    718730      const NodeRefMap& _node_ref;
    719731    };
    720732
    721 
    722733  public:
    723734
    724 
    725     /// \brief Constructor for the GraphCopy.
    726     ///
    727     /// It copies the content of the \c _from graph into the
    728     /// \c _to graph.
    729     GraphCopy(To& to, const From& from)
     735    /// \brief Constructor of GraphCopy.
     736    ///
     737    /// Constructor of GraphCopy for copying the content of the
     738    /// \c from graph into the \c to graph.
     739    GraphCopy(const From& from, To& to)
    730740      : _from(from), _to(to) {}
    731741
    732     /// \brief Destructor of the GraphCopy
    733     ///
    734     /// Destructor of the GraphCopy
     742    /// \brief Destructor of GraphCopy
     743    ///
     744    /// Destructor of GraphCopy.
    735745    ~GraphCopy() {
    736746      for (int i = 0; i < int(_node_maps.size()); ++i) {
     
    743753        delete _edge_maps[i];
    744754      }
    745 
    746     }
    747 
    748     /// \brief Copies the node references into the given map.
    749     ///
    750     /// Copies the node references into the given map.
     755    }
     756
     757    /// \brief Copy the node references into the given map.
     758    ///
     759    /// This function copies the node references into the given map.
     760    /// The parameter should be a map, whose key type is the Node type of
     761    /// the source graph, while the value type is the Node type of the
     762    /// destination graph.
    751763    template <typename NodeRef>
    752764    GraphCopy& nodeRef(NodeRef& map) {
     
    756768    }
    757769
    758     /// \brief Copies the node cross references into the given map.
    759     ///
    760     ///  Copies the node cross references (reverse references) into
    761     ///  the given map.
     770    /// \brief Copy the node cross references into the given map.
     771    ///
     772    /// This function copies the node cross references (reverse references)
     773    /// into the given map. The parameter should be a map, whose key type
     774    /// is the Node type of the destination graph, while the value type is
     775    /// the Node type of the source graph.
    762776    template <typename NodeCrossRef>
    763777    GraphCopy& nodeCrossRef(NodeCrossRef& map) {
     
    767781    }
    768782
    769     /// \brief Make copy of the given map.
    770     ///
    771     /// Makes copy of the given map for the newly created graph.
    772     /// The new map's key type is the to graph's node type,
    773     /// and the copied map's key type is the from graph's node
    774     /// type.
    775     template <typename ToMap, typename FromMap>
    776     GraphCopy& nodeMap(ToMap& tmap, const FromMap& map) {
     783    /// \brief Make a copy of the given node map.
     784    ///
     785    /// This function makes a copy of the given node map for the newly
     786    /// created graph.
     787    /// The key type of the new map \c tmap should be the Node type of the
     788    /// destination graph, and the key type of the original map \c map
     789    /// should be the Node type of the source graph.
     790    template <typename FromMap, typename ToMap>
     791    GraphCopy& nodeMap(const FromMap& map, ToMap& tmap) {
    777792      _node_maps.push_back(new _core_bits::MapCopy<From, Node,
    778                            NodeRefMap, ToMap, FromMap>(tmap, map));
     793                           NodeRefMap, FromMap, ToMap>(map, tmap));
    779794      return *this;
    780795    }
     
    782797    /// \brief Make a copy of the given node.
    783798    ///
    784     /// Make a copy of the given node.
    785     GraphCopy& node(TNode& tnode, const Node& snode) {
     799    /// This function makes a copy of the given node.
     800    GraphCopy& node(const Node& node, TNode& tnode) {
    786801      _node_maps.push_back(new _core_bits::ItemCopy<From, Node,
    787                            NodeRefMap, TNode>(tnode, snode));
    788       return *this;
    789     }
    790 
    791     /// \brief Copies the arc references into the given map.
    792     ///
    793     /// Copies the arc references into the given map.
     802                           NodeRefMap, TNode>(node, tnode));
     803      return *this;
     804    }
     805
     806    /// \brief Copy the arc references into the given map.
     807    ///
     808    /// This function copies the arc references into the given map.
     809    /// The parameter should be a map, whose key type is the Arc type of
     810    /// the source graph, while the value type is the Arc type of the
     811    /// destination graph.
    794812    template <typename ArcRef>
    795813    GraphCopy& arcRef(ArcRef& map) {
     
    799817    }
    800818
    801     /// \brief Copies the arc cross references into the given map.
    802     ///
    803     ///  Copies the arc cross references (reverse references) into
    804     ///  the given map.
     819    /// \brief Copy the arc cross references into the given map.
     820    ///
     821    /// This function copies the arc cross references (reverse references)
     822    /// into the given map. The parameter should be a map, whose key type
     823    /// is the Arc type of the destination graph, while the value type is
     824    /// the Arc type of the source graph.
    805825    template <typename ArcCrossRef>
    806826    GraphCopy& arcCrossRef(ArcCrossRef& map) {
     
    810830    }
    811831
    812     /// \brief Make copy of the given map.
    813     ///
    814     /// Makes copy of the given map for the newly created graph.
    815     /// The new map's key type is the to graph's arc type,
    816     /// and the copied map's key type is the from graph's arc
    817     /// type.
    818     template <typename ToMap, typename FromMap>
    819     GraphCopy& arcMap(ToMap& tmap, const FromMap& map) {
     832    /// \brief Make a copy of the given arc map.
     833    ///
     834    /// This function makes a copy of the given arc map for the newly
     835    /// created graph.
     836    /// The key type of the new map \c tmap should be the Arc type of the
     837    /// destination graph, and the key type of the original map \c map
     838    /// should be the Arc type of the source graph.
     839    template <typename FromMap, typename ToMap>
     840    GraphCopy& arcMap(const FromMap& map, ToMap& tmap) {
    820841      _arc_maps.push_back(new _core_bits::MapCopy<From, Arc,
    821                           ArcRefMap, ToMap, FromMap>(tmap, map));
     842                          ArcRefMap, FromMap, ToMap>(map, tmap));
    822843      return *this;
    823844    }
     
    825846    /// \brief Make a copy of the given arc.
    826847    ///
    827     /// Make a copy of the given arc.
    828     GraphCopy& arc(TArc& tarc, const Arc& sarc) {
     848    /// This function makes a copy of the given arc.
     849    GraphCopy& arc(const Arc& arc, TArc& tarc) {
    829850      _arc_maps.push_back(new _core_bits::ItemCopy<From, Arc,
    830                           ArcRefMap, TArc>(tarc, sarc));
    831       return *this;
    832     }
    833 
    834     /// \brief Copies the edge references into the given map.
    835     ///
    836     /// Copies the edge references into the given map.
     851                          ArcRefMap, TArc>(arc, tarc));
     852      return *this;
     853    }
     854
     855    /// \brief Copy the edge references into the given map.
     856    ///
     857    /// This function copies the edge references into the given map.
     858    /// The parameter should be a map, whose key type is the Edge type of
     859    /// the source graph, while the value type is the Edge type of the
     860    /// destination graph.
    837861    template <typename EdgeRef>
    838862    GraphCopy& edgeRef(EdgeRef& map) {
     
    842866    }
    843867
    844     /// \brief Copies the edge cross references into the given map.
    845     ///
    846     /// Copies the edge cross references (reverse
    847     /// references) into the given map.
     868    /// \brief Copy the edge cross references into the given map.
     869    ///
     870    /// This function copies the edge cross references (reverse references)
     871    /// into the given map. The parameter should be a map, whose key type
     872    /// is the Edge type of the destination graph, while the value type is
     873    /// the Edge type of the source graph.
    848874    template <typename EdgeCrossRef>
    849875    GraphCopy& edgeCrossRef(EdgeCrossRef& map) {
     
    853879    }
    854880
    855     /// \brief Make copy of the given map.
    856     ///
    857     /// Makes copy of the given map for the newly created graph.
    858     /// The new map's key type is the to graph's edge type,
    859     /// and the copied map's key type is the from graph's edge
    860     /// type.
    861     template <typename ToMap, typename FromMap>
    862     GraphCopy& edgeMap(ToMap& tmap, const FromMap& map) {
     881    /// \brief Make a copy of the given edge map.
     882    ///
     883    /// This function makes a copy of the given edge map for the newly
     884    /// created graph.
     885    /// The key type of the new map \c tmap should be the Edge type of the
     886    /// destination graph, and the key type of the original map \c map
     887    /// should be the Edge type of the source graph.
     888    template <typename FromMap, typename ToMap>
     889    GraphCopy& edgeMap(const FromMap& map, ToMap& tmap) {
    863890      _edge_maps.push_back(new _core_bits::MapCopy<From, Edge,
    864                            EdgeRefMap, ToMap, FromMap>(tmap, map));
     891                           EdgeRefMap, FromMap, ToMap>(map, tmap));
    865892      return *this;
    866893    }
     
    868895    /// \brief Make a copy of the given edge.
    869896    ///
    870     /// Make a copy of the given edge.
    871     GraphCopy& edge(TEdge& tedge, const Edge& sedge) {
     897    /// This function makes a copy of the given edge.
     898    GraphCopy& edge(const Edge& edge, TEdge& tedge) {
    872899      _edge_maps.push_back(new _core_bits::ItemCopy<From, Edge,
    873                            EdgeRefMap, TEdge>(tedge, sedge));
    874       return *this;
    875     }
    876 
    877     /// \brief Executes the copies.
    878     ///
    879     /// Executes the copies.
     900                           EdgeRefMap, TEdge>(edge, tedge));
     901      return *this;
     902    }
     903
     904    /// \brief Execute copying.
     905    ///
     906    /// This function executes the copying of the graph along with the
     907    /// copying of the assigned data.
    880908    void run() {
    881909      NodeRefMap nodeRefMap(_from);
    882910      EdgeRefMap edgeRefMap(_from);
    883       ArcRefMap arcRefMap(_to, _from, edgeRefMap, nodeRefMap);
     911      ArcRefMap arcRefMap(_from, _to, edgeRefMap, nodeRefMap);
    884912      _core_bits::GraphCopySelector<To>::
    885         copy(_to, _from, nodeRefMap, edgeRefMap);
     913        copy(_from, _to, nodeRefMap, edgeRefMap);
    886914      for (int i = 0; i < int(_node_maps.size()); ++i) {
    887915        _node_maps[i]->copy(_from, nodeRefMap);
     
    901929
    902930    std::vector<_core_bits::MapCopyBase<From, Node, NodeRefMap>* >
    903     _node_maps;
     931      _node_maps;
    904932
    905933    std::vector<_core_bits::MapCopyBase<From, Arc, ArcRefMap>* >
    906     _arc_maps;
     934      _arc_maps;
    907935
    908936    std::vector<_core_bits::MapCopyBase<From, Edge, EdgeRefMap>* >
    909     _edge_maps;
     937      _edge_maps;
    910938
    911939  };
     
    913941  /// \brief Copy a graph to another graph.
    914942  ///
    915   /// Copy a graph to another graph. The complete usage of the
    916   /// function is detailed in the GraphCopy class, but a short
    917   /// example shows a basic work:
     943  /// This function copies a graph to another graph.
     944  /// The complete usage of it is detailed in the GraphCopy class,
     945  /// but a short example shows a basic work:
    918946  ///\code
    919   /// copyGraph(trg, src).nodeRef(nr).arcCrossRef(ecr).run();
     947  /// graphCopy(src, trg).nodeRef(nr).edgeCrossRef(ecr).run();
    920948  ///\endcode
    921949  ///
    922950  /// After the copy the \c nr map will contain the mapping from the
    923951  /// nodes of the \c from graph to the nodes of the \c to graph and
    924   /// \c ecr will contain the mapping from the arcs of the \c to graph
    925   /// to the arcs of the \c from graph.
     952  /// \c ecr will contain the mapping from the edges of the \c to graph
     953  /// to the edges of the \c from graph.
    926954  ///
    927955  /// \see GraphCopy
    928   template <typename To, typename From>
    929   GraphCopy<To, From>
    930   copyGraph(To& to, const From& from) {
    931     return GraphCopy<To, From>(to, from);
     956  template <typename From, typename To>
     957  GraphCopy<From, To>
     958  graphCopy(const From& from, To& to) {
     959    return GraphCopy<From, To>(from, to);
    932960  }
    933961
     
    954982    struct FindArcSelector<
    955983      Graph,
    956       typename enable_if<typename Graph::FindEdgeTag, void>::type>
     984      typename enable_if<typename Graph::FindArcTag, void>::type>
    957985    {
    958986      typedef typename Graph::Node Node;
     
    964992  }
    965993
    966   /// \brief Finds an arc between two nodes of a graph.
    967   ///
    968   /// Finds an arc from node \c u to node \c v in graph \c g.
     994  /// \brief Find an arc between two nodes of a digraph.
     995  ///
     996  /// This function finds an arc from node \c u to node \c v in the
     997  /// digraph \c g.
    969998  ///
    970999  /// If \c prev is \ref INVALID (this is the default value), then
     
    9751004  /// Thus you can iterate through each arc from \c u to \c v as it follows.
    9761005  ///\code
    977   /// for(Arc e=findArc(g,u,v);e!=INVALID;e=findArc(g,u,v,e)) {
     1006  /// for(Arc e = findArc(g,u,v); e != INVALID; e = findArc(g,u,v,e)) {
    9781007  ///   ...
    9791008  /// }
    9801009  ///\endcode
    9811010  ///
    982   ///\sa ArcLookUp
    983   ///\sa AllArcLookUp
    984   ///\sa DynArcLookUp
     1011  /// \note \ref ConArcIt provides iterator interface for the same
     1012  /// functionality.
     1013  ///
    9851014  ///\sa ConArcIt
     1015  ///\sa ArcLookUp, AllArcLookUp, DynArcLookUp
    9861016  template <typename Graph>
    9871017  inline typename Graph::Arc
     
    9911021  }
    9921022
    993   /// \brief Iterator for iterating on arcs connected the same nodes.
    994   ///
    995   /// Iterator for iterating on arcs connected the same nodes. It is
    996   /// higher level interface for the findArc() function. You can
     1023  /// \brief Iterator for iterating on parallel arcs connecting the same nodes.
     1024  ///
     1025  /// Iterator for iterating on parallel arcs connecting the same nodes. It is
     1026  /// a higher level interface for the \ref findArc() function. You can
    9971027  /// use it the following way:
    9981028  ///\code
     
    10031033  ///
    10041034  ///\sa findArc()
    1005   ///\sa ArcLookUp
    1006   ///\sa AllArcLookUp
    1007   ///\sa DynArcLookUp
     1035  ///\sa ArcLookUp, AllArcLookUp, DynArcLookUp
    10081036  template <typename _Graph>
    10091037  class ConArcIt : public _Graph::Arc {
     
    10181046    /// \brief Constructor.
    10191047    ///
    1020     /// Construct a new ConArcIt iterating on the arcs which
    1021     /// connects the \c u and \c v node.
     1048    /// Construct a new ConArcIt iterating on the arcs that
     1049    /// connects nodes \c u and \c v.
    10221050    ConArcIt(const Graph& g, Node u, Node v) : _graph(g) {
    10231051      Parent::operator=(findArc(_graph, u, v));
     
    10261054    /// \brief Constructor.
    10271055    ///
    1028     /// Construct a new ConArcIt which continues the iterating from
    1029     /// the \c e arc.
     1056    /// Construct a new ConArcIt that continues the iterating from arc \c a.
    10301057    ConArcIt(const Graph& g, Arc a) : Parent(a), _graph(g) {}
    10311058
     
    10881115  }
    10891116
    1090   /// \brief Finds an edge between two nodes of a graph.
    1091   ///
    1092   /// Finds an edge from node \c u to node \c v in graph \c g.
    1093   /// If the node \c u and node \c v is equal then each loop edge
     1117  /// \brief Find an edge between two nodes of a graph.
     1118  ///
     1119  /// This function finds an edge from node \c u to node \c v in graph \c g.
     1120  /// If node \c u and node \c v is equal then each loop edge
    10941121  /// will be enumerated once.
    10951122  ///
    10961123  /// If \c prev is \ref INVALID (this is the default value), then
    1097   /// it finds the first arc from \c u to \c v. Otherwise it looks for
    1098   /// the next arc from \c u to \c v after \c prev.
    1099   /// \return The found arc or \ref INVALID if there is no such an arc.
    1100   ///
    1101   /// Thus you can iterate through each arc from \c u to \c v as it follows.
     1124  /// it finds the first edge from \c u to \c v. Otherwise it looks for
     1125  /// the next edge from \c u to \c v after \c prev.
     1126  /// \return The found edge or \ref INVALID if there is no such an edge.
     1127  ///
     1128  /// Thus you can iterate through each edge between \c u and \c v
     1129  /// as it follows.
    11021130  ///\code
    1103   /// for(Edge e = findEdge(g,u,v); e != INVALID;
    1104   ///     e = findEdge(g,u,v,e)) {
     1131  /// for(Edge e = findEdge(g,u,v); e != INVALID; e = findEdge(g,u,v,e)) {
    11051132  ///   ...
    11061133  /// }
    11071134  ///\endcode
    11081135  ///
     1136  /// \note \ref ConEdgeIt provides iterator interface for the same
     1137  /// functionality.
     1138  ///
    11091139  ///\sa ConEdgeIt
    1110 
    11111140  template <typename Graph>
    11121141  inline typename Graph::Edge
     
    11161145  }
    11171146
    1118   /// \brief Iterator for iterating on edges connected the same nodes.
    1119   ///
    1120   /// Iterator for iterating on edges connected the same nodes. It is
    1121   /// higher level interface for the findEdge() function. You can
     1147  /// \brief Iterator for iterating on parallel edges connecting the same nodes.
     1148  ///
     1149  /// Iterator for iterating on parallel edges connecting the same nodes.
     1150  /// It is a higher level interface for the findEdge() function. You can
    11221151  /// use it the following way:
    11231152  ///\code
    1124   /// for (ConEdgeIt<Graph> it(g, src, trg); it != INVALID; ++it) {
     1153  /// for (ConEdgeIt<Graph> it(g, u, v); it != INVALID; ++it) {
    11251154  ///   ...
    11261155  /// }
     
    11401169    /// \brief Constructor.
    11411170    ///
    1142     /// Construct a new ConEdgeIt iterating on the edges which
    1143     /// connects the \c u and \c v node.
     1171    /// Construct a new ConEdgeIt iterating on the edges that
     1172    /// connects nodes \c u and \c v.
    11441173    ConEdgeIt(const Graph& g, Node u, Node v) : _graph(g) {
    11451174      Parent::operator=(findEdge(_graph, u, v));
     
    11481177    /// \brief Constructor.
    11491178    ///
    1150     /// Construct a new ConEdgeIt which continues the iterating from
    1151     /// the \c e edge.
     1179    /// Construct a new ConEdgeIt that continues iterating from edge \c e.
    11521180    ConEdgeIt(const Graph& g, Edge e) : Parent(e), _graph(g) {}
    11531181
     
    11651193
    11661194
    1167   ///Dynamic arc look up between given endpoints.
     1195  ///Dynamic arc look-up between given endpoints.
    11681196
    11691197  ///Using this class, you can find an arc in a digraph from a given
    1170   ///source to a given target in amortized time <em>O(log d)</em>,
     1198  ///source to a given target in amortized time <em>O</em>(log<em>d</em>),
    11711199  ///where <em>d</em> is the out-degree of the source node.
    11721200  ///
    11731201  ///It is possible to find \e all parallel arcs between two nodes with
    1174   ///the \c findFirst() and \c findNext() members.
    1175   ///
    1176   ///See the \ref ArcLookUp and \ref AllArcLookUp classes if your
    1177   ///digraph is not changed so frequently.
    1178   ///
    1179   ///This class uses a self-adjusting binary search tree, Sleator's
    1180   ///and Tarjan's Splay tree for guarantee the logarithmic amortized
    1181   ///time bound for arc lookups. This class also guarantees the
     1202  ///the \c operator() member.
     1203  ///
     1204  ///This is a dynamic data structure. Consider to use \ref ArcLookUp or
     1205  ///\ref AllArcLookUp if your digraph is not changed so frequently.
     1206  ///
     1207  ///This class uses a self-adjusting binary search tree, the Splay tree
     1208  ///of Sleator and Tarjan to guarantee the logarithmic amortized
     1209  ///time bound for arc look-ups. This class also guarantees the
    11821210  ///optimal time bound in a constant factor for any distribution of
    11831211  ///queries.
     
    13811409          _right.set(e, _right[arc]);
    13821410          _parent.set(_right[arc], e);
     1411          _parent.set(e, _parent[arc]);
    13831412
    13841413          if (_parent[arc] != INVALID) {
     
    14191448      for(NodeIt n(_g);n!=INVALID;++n) {
    14201449        std::vector<Arc> v;
    1421         for(OutArcIt e(_g,n);e!=INVALID;++e) v.push_back(e);
    1422         if(v.size()) {
     1450        for(OutArcIt a(_g,n);a!=INVALID;++a) v.push_back(a);
     1451        if (!v.empty()) {
    14231452          std::sort(v.begin(),v.end(),ArcLess(_g));
    14241453          Arc head = refreshRec(v,0,v.size()-1);
     
    15021531    ///Find an arc between two nodes.
    15031532
    1504     ///Find an arc between two nodes in time <em>O(</em>log<em>d)</em>, where
    1505     /// <em>d</em> is the number of outgoing arcs of \c s.
    1506     ///\param s The source node
    1507     ///\param t The target node
    1508     ///\return An arc from \c s to \c t if there exists,
    1509     ///\ref INVALID otherwise.
    1510     Arc operator()(Node s, Node t) const
    1511     {
    1512       Arc a = _head[s];
    1513       while (true) {
    1514         if (_g.target(a) == t) {
     1533    ///Find an arc between two nodes.
     1534    ///\param s The source node.
     1535    ///\param t The target node.
     1536    ///\param p The previous arc between \c s and \c t. It it is INVALID or
     1537    ///not given, the operator finds the first appropriate arc.
     1538    ///\return An arc from \c s to \c t after \c p or
     1539    ///\ref INVALID if there is no more.
     1540    ///
     1541    ///For example, you can count the number of arcs from \c u to \c v in the
     1542    ///following way.
     1543    ///\code
     1544    ///DynArcLookUp<ListDigraph> ae(g);
     1545    ///...
     1546    ///int n = 0;
     1547    ///for(Arc a = ae(u,v); a != INVALID; a = ae(u,v,a)) n++;
     1548    ///\endcode
     1549    ///
     1550    ///Finding the arcs take at most <em>O</em>(log<em>d</em>)
     1551    ///amortized time, specifically, the time complexity of the lookups
     1552    ///is equal to the optimal search tree implementation for the
     1553    ///current query distribution in a constant factor.
     1554    ///
     1555    ///\note This is a dynamic data structure, therefore the data
     1556    ///structure is updated after each graph alteration. Thus although
     1557    ///this data structure is theoretically faster than \ref ArcLookUp
     1558    ///and \ref AllArcLookUp, it often provides worse performance than
     1559    ///them.
     1560    Arc operator()(Node s, Node t, Arc p = INVALID) const  {
     1561      if (p == INVALID) {
     1562        Arc a = _head[s];
     1563        if (a == INVALID) return INVALID;
     1564        Arc r = INVALID;
     1565        while (true) {
     1566          if (_g.target(a) < t) {
     1567            if (_right[a] == INVALID) {
     1568              const_cast<DynArcLookUp&>(*this).splay(a);
     1569              return r;
     1570            } else {
     1571              a = _right[a];
     1572            }
     1573          } else {
     1574            if (_g.target(a) == t) {
     1575              r = a;
     1576            }
     1577            if (_left[a] == INVALID) {
     1578              const_cast<DynArcLookUp&>(*this).splay(a);
     1579              return r;
     1580            } else {
     1581              a = _left[a];
     1582            }
     1583          }
     1584        }
     1585      } else {
     1586        Arc a = p;
     1587        if (_right[a] != INVALID) {
     1588          a = _right[a];
     1589          while (_left[a] != INVALID) {
     1590            a = _left[a];
     1591          }
    15151592          const_cast<DynArcLookUp&>(*this).splay(a);
    1516           return a;
    1517         } else if (t < _g.target(a)) {
    1518           if (_left[a] == INVALID) {
    1519             const_cast<DynArcLookUp&>(*this).splay(a);
     1593        } else {
     1594          while (_parent[a] != INVALID && _right[_parent[a]] ==  a) {
     1595            a = _parent[a];
     1596          }
     1597          if (_parent[a] == INVALID) {
    15201598            return INVALID;
    15211599          } else {
    1522             a = _left[a];
     1600            a = _parent[a];
     1601            const_cast<DynArcLookUp&>(*this).splay(a);
    15231602          }
    1524         } else  {
    1525           if (_right[a] == INVALID) {
    1526             const_cast<DynArcLookUp&>(*this).splay(a);
    1527             return INVALID;
    1528           } else {
    1529             a = _right[a];
    1530           }
    1531         }
    1532       }
    1533     }
    1534 
    1535     ///Find the first arc between two nodes.
    1536 
    1537     ///Find the first arc between two nodes in time
    1538     /// <em>O(</em>log<em>d)</em>, where <em>d</em> is the number of
    1539     /// outgoing arcs of \c s.
    1540     ///\param s The source node
    1541     ///\param t The target node
    1542     ///\return An arc from \c s to \c t if there exists, \ref INVALID
    1543     /// otherwise.
    1544     Arc findFirst(Node s, Node t) const
    1545     {
    1546       Arc a = _head[s];
    1547       Arc r = INVALID;
    1548       while (true) {
    1549         if (_g.target(a) < t) {
    1550           if (_right[a] == INVALID) {
    1551             const_cast<DynArcLookUp&>(*this).splay(a);
    1552             return r;
    1553           } else {
    1554             a = _right[a];
    1555           }
    1556         } else {
    1557           if (_g.target(a) == t) {
    1558             r = a;
    1559           }
    1560           if (_left[a] == INVALID) {
    1561             const_cast<DynArcLookUp&>(*this).splay(a);
    1562             return r;
    1563           } else {
    1564             a = _left[a];
    1565           }
    1566         }
    1567       }
    1568     }
    1569 
    1570     ///Find the next arc between two nodes.
    1571 
    1572     ///Find the next arc between two nodes in time
    1573     /// <em>O(</em>log<em>d)</em>, where <em>d</em> is the number of
    1574     /// outgoing arcs of \c s.
    1575     ///\param s The source node
    1576     ///\param t The target node
    1577     ///\return An arc from \c s to \c t if there exists, \ref INVALID
    1578     /// otherwise.
    1579 
    1580     ///\note If \c e is not the result of the previous \c findFirst()
    1581     ///operation then the amorized time bound can not be guaranteed.
    1582 #ifdef DOXYGEN
    1583     Arc findNext(Node s, Node t, Arc a) const
    1584 #else
    1585     Arc findNext(Node, Node t, Arc a) const
    1586 #endif
    1587     {
    1588       if (_right[a] != INVALID) {
    1589         a = _right[a];
    1590         while (_left[a] != INVALID) {
    1591           a = _left[a];
    1592         }
    1593         const_cast<DynArcLookUp&>(*this).splay(a);
    1594       } else {
    1595         while (_parent[a] != INVALID && _right[_parent[a]] ==  a) {
    1596           a = _parent[a];
    1597         }
    1598         if (_parent[a] == INVALID) {
    1599           return INVALID;
    1600         } else {
    1601           a = _parent[a];
    1602           const_cast<DynArcLookUp&>(*this).splay(a);
    1603         }
    1604       }
    1605       if (_g.target(a) == t) return a;
    1606       else return INVALID;
     1603        }
     1604        if (_g.target(a) == t) return a;
     1605        else return INVALID;
     1606      }
    16071607    }
    16081608
    16091609  };
    16101610
    1611   ///Fast arc look up between given endpoints.
     1611  ///Fast arc look-up between given endpoints.
    16121612
    16131613  ///Using this class, you can find an arc in a digraph from a given
    1614   ///source to a given target in time <em>O(log d)</em>,
     1614  ///source to a given target in time <em>O</em>(log<em>d</em>),
    16151615  ///where <em>d</em> is the out-degree of the source node.
    16161616  ///
     
    16181618  ///Use \ref AllArcLookUp for this purpose.
    16191619  ///
    1620   ///\warning This class is static, so you should refresh() (or at least
    1621   ///refresh(Node)) this data structure
    1622   ///whenever the digraph changes. This is a time consuming (superlinearly
    1623   ///proportional (<em>O(m</em>log<em>m)</em>) to the number of arcs).
     1620  ///\warning This class is static, so you should call refresh() (or at
     1621  ///least refresh(Node)) to refresh this data structure whenever the
     1622  ///digraph changes. This is a time consuming (superlinearly proportional
     1623  ///(<em>O</em>(<em>m</em> log<em>m</em>)) to the number of arcs).
    16241624  ///
    16251625  ///\tparam G The type of the underlying digraph.
     
    16701670    }
    16711671  public:
    1672     ///Refresh the data structure at a node.
     1672    ///Refresh the search data structure at a node.
    16731673
    16741674    ///Build up the search database of node \c n.
    16751675    ///
    1676     ///It runs in time <em>O(d</em>log<em>d)</em>, where <em>d</em> is
    1677     ///the number of the outgoing arcs of \c n.
     1676    ///It runs in time <em>O</em>(<em>d</em> log<em>d</em>), where <em>d</em>
     1677    ///is the number of the outgoing arcs of \c n.
    16781678    void refresh(Node n)
    16791679    {
     
    16911691    ///\ref refresh(Node) "refresh(n)" for each node \c n.
    16921692    ///
    1693     ///It runs in time <em>O(m</em>log<em>D)</em>, where <em>m</em> is
    1694     ///the number of the arcs of \c n and <em>D</em> is the maximum
     1693    ///It runs in time <em>O</em>(<em>m</em> log<em>D</em>), where <em>m</em> is
     1694    ///the number of the arcs in the digraph and <em>D</em> is the maximum
    16951695    ///out-degree of the digraph.
    1696 
    16971696    void refresh()
    16981697    {
     
    17021701    ///Find an arc between two nodes.
    17031702
    1704     ///Find an arc between two nodes in time <em>O(</em>log<em>d)</em>, where
    1705     /// <em>d</em> is the number of outgoing arcs of \c s.
    1706     ///\param s The source node
    1707     ///\param t The target node
     1703    ///Find an arc between two nodes in time <em>O</em>(log<em>d</em>),
     1704    ///where <em>d</em> is the number of outgoing arcs of \c s.
     1705    ///\param s The source node.
     1706    ///\param t The target node.
    17081707    ///\return An arc from \c s to \c t if there exists,
    17091708    ///\ref INVALID otherwise.
     
    17111710    ///\warning If you change the digraph, refresh() must be called before using
    17121711    ///this operator. If you change the outgoing arcs of
    1713     ///a single node \c n, then
    1714     ///\ref refresh(Node) "refresh(n)" is enough.
    1715     ///
     1712    ///a single node \c n, then \ref refresh(Node) "refresh(n)" is enough.
    17161713    Arc operator()(Node s, Node t) const
    17171714    {
     
    17251722  };
    17261723
    1727   ///Fast look up of all arcs between given endpoints.
     1724  ///Fast look-up of all arcs between given endpoints.
    17281725
    17291726  ///This class is the same as \ref ArcLookUp, with the addition
    1730   ///that it makes it possible to find all arcs between given endpoints.
    1731   ///
    1732   ///\warning This class is static, so you should refresh() (or at least
    1733   ///refresh(Node)) this data structure
    1734   ///whenever the digraph changes. This is a time consuming (superlinearly
    1735   ///proportional (<em>O(m</em>log<em>m)</em>) to the number of arcs).
     1727  ///that it makes it possible to find all parallel arcs between given
     1728  ///endpoints.
     1729  ///
     1730  ///\warning This class is static, so you should call refresh() (or at
     1731  ///least refresh(Node)) to refresh this data structure whenever the
     1732  ///digraph changes. This is a time consuming (superlinearly proportional
     1733  ///(<em>O</em>(<em>m</em> log<em>m</em>)) to the number of arcs).
    17361734  ///
    17371735  ///\tparam G The type of the underlying digraph.
     
    17571755      else {
    17581756        next=refreshNext(_right[head],next);
    1759 //         _next[head]=next;
    17601757        _next[head]=( next!=INVALID && _g.target(next)==_g.target(head))
    17611758          ? next : INVALID;
     
    17821779    ///Build up the search database of node \c n.
    17831780    ///
    1784     ///It runs in time <em>O(d</em>log<em>d)</em>, where <em>d</em> is
     1781    ///It runs in time <em>O</em>(<em>d</em> log<em>d</em>), where <em>d</em> is
    17851782    ///the number of the outgoing arcs of \c n.
    1786 
    17871783    void refresh(Node n)
    17881784    {
     
    17961792    ///\ref refresh(Node) "refresh(n)" for each node \c n.
    17971793    ///
    1798     ///It runs in time <em>O(m</em>log<em>D)</em>, where <em>m</em> is
    1799     ///the number of the arcs of \c n and <em>D</em> is the maximum
     1794    ///It runs in time <em>O</em>(<em>m</em> log<em>D</em>), where <em>m</em> is
     1795    ///the number of the arcs in the digraph and <em>D</em> is the maximum
    18001796    ///out-degree of the digraph.
    1801 
    18021797    void refresh()
    18031798    {
     
    18081803
    18091804    ///Find an arc between two nodes.
    1810     ///\param s The source node
    1811     ///\param t The target node
     1805    ///\param s The source node.
     1806    ///\param t The target node.
    18121807    ///\param prev The previous arc between \c s and \c t. It it is INVALID or
    18131808    ///not given, the operator finds the first appropriate arc.
     
    18201815    ///AllArcLookUp<ListDigraph> ae(g);
    18211816    ///...
    1822     ///int n=0;
    1823     ///for(Arc e=ae(u,v);e!=INVALID;e=ae(u,v,e)) n++;
     1817    ///int n = 0;
     1818    ///for(Arc a = ae(u,v); a != INVALID; a=ae(u,v,a)) n++;
    18241819    ///\endcode
    18251820    ///
    1826     ///Finding the first arc take <em>O(</em>log<em>d)</em> time, where
    1827     /// <em>d</em> is the number of outgoing arcs of \c s. Then, the
     1821    ///Finding the first arc take <em>O</em>(log<em>d</em>) time,
     1822    ///where <em>d</em> is the number of outgoing arcs of \c s. Then the
    18281823    ///consecutive arcs are found in constant time.
    18291824    ///
    18301825    ///\warning If you change the digraph, refresh() must be called before using
    18311826    ///this operator. If you change the outgoing arcs of
    1832     ///a single node \c n, then
    1833     ///\ref refresh(Node) "refresh(n)" is enough.
     1827    ///a single node \c n, then \ref refresh(Node) "refresh(n)" is enough.
    18341828    ///
    18351829#ifdef DOXYGEN
Note: See TracChangeset for help on using the changeset viewer.