lemon/list_graph.h
changeset 736 2e20aad15754
parent 735 853fcddcf282
child 738 456fa5bc3256
     1.1 --- a/lemon/list_graph.h	Sun Aug 23 11:09:22 2009 +0200
     1.2 +++ b/lemon/list_graph.h	Sun Aug 23 11:10:40 2009 +0200
     1.3 @@ -1311,6 +1311,26 @@
     1.4        Parent::clear();
     1.5      }
     1.6  
     1.7 +    /// Reserve memory for nodes.
     1.8 +
     1.9 +    /// Using this function, it is possible to avoid superfluous memory
    1.10 +    /// allocation: if you know that the graph you want to build will
    1.11 +    /// be large (e.g. it will contain millions of nodes and/or edges),
    1.12 +    /// then it is worth reserving space for this amount before starting
    1.13 +    /// to build the graph.
    1.14 +    /// \sa reserveEdge()
    1.15 +    void reserveNode(int n) { nodes.reserve(n); };
    1.16 +
    1.17 +    /// Reserve memory for edges.
    1.18 +
    1.19 +    /// Using this function, it is possible to avoid superfluous memory
    1.20 +    /// allocation: if you know that the graph you want to build will
    1.21 +    /// be large (e.g. it will contain millions of nodes and/or edges),
    1.22 +    /// then it is worth reserving space for this amount before starting
    1.23 +    /// to build the graph.
    1.24 +    /// \sa reserveNode()
    1.25 +    void reserveEdge(int m) { arcs.reserve(2 * m); };
    1.26 +
    1.27      /// \brief Class to make a snapshot of the graph and restore
    1.28      /// it later.
    1.29      ///