lemon/hypercube_graph.h
changeset 803 1b89e29c9fc7
parent 787 c2230649a493
parent 786 e20173729589
     1.1 --- a/lemon/hypercube_graph.h	Thu Dec 10 17:05:35 2009 +0100
     1.2 +++ b/lemon/hypercube_graph.h	Thu Dec 10 17:18:25 2009 +0100
     1.3 @@ -262,7 +262,7 @@
     1.4        return arc._id >> _dim;
     1.5      }
     1.6  
     1.7 -    int index(Node node) const {
     1.8 +    static int index(Node node) {
     1.9        return node._id;
    1.10      }
    1.11  
    1.12 @@ -282,17 +282,23 @@
    1.13    ///
    1.14    /// \brief Hypercube graph class
    1.15    ///
    1.16 -  /// This class implements a special graph type. The nodes of the graph
    1.17 -  /// are indiced with integers with at most \c dim binary digits.
    1.18 +  /// HypercubeGraph implements a special graph type. The nodes of the
    1.19 +  /// graph are indexed with integers having at most \c dim binary digits.
    1.20    /// Two nodes are connected in the graph if and only if their indices
    1.21    /// differ only on one position in the binary form.
    1.22 +  /// This class is completely static and it needs constant memory space.
    1.23 +  /// Thus you can neither add nor delete nodes or edges, however,
    1.24 +  /// the structure can be resized using resize().
    1.25 +  ///
    1.26 +  /// This type fully conforms to the \ref concepts::Graph "Graph concept".
    1.27 +  /// Most of its member functions and nested classes are documented
    1.28 +  /// only in the concept class.
    1.29 +  ///
    1.30 +  /// This class provides constant time counting for nodes, edges and arcs.
    1.31    ///
    1.32    /// \note The type of the indices is chosen to \c int for efficiency
    1.33    /// reasons. Thus the maximum dimension of this implementation is 26
    1.34    /// (assuming that the size of \c int is 32 bit).
    1.35 -  ///
    1.36 -  /// This graph type fully conforms to the \ref concepts::Graph
    1.37 -  /// "Graph concept".
    1.38    class HypercubeGraph : public ExtendedHypercubeGraphBase {
    1.39      typedef ExtendedHypercubeGraphBase Parent;
    1.40  
    1.41 @@ -303,6 +309,21 @@
    1.42      /// Constructs a hypercube graph with \c dim dimensions.
    1.43      HypercubeGraph(int dim) { construct(dim); }
    1.44  
    1.45 +    /// \brief Resizes the graph
    1.46 +    ///
    1.47 +    /// This function resizes the graph. It fully destroys and
    1.48 +    /// rebuilds the structure, therefore the maps of the graph will be
    1.49 +    /// reallocated automatically and the previous values will be lost.
    1.50 +    void resize(int dim) {
    1.51 +      Parent::notifier(Arc()).clear();
    1.52 +      Parent::notifier(Edge()).clear();
    1.53 +      Parent::notifier(Node()).clear();
    1.54 +      construct(dim);
    1.55 +      Parent::notifier(Node()).build();
    1.56 +      Parent::notifier(Edge()).build();
    1.57 +      Parent::notifier(Arc()).build();
    1.58 +    }
    1.59 +
    1.60      /// \brief The number of dimensions.
    1.61      ///
    1.62      /// Gives back the number of dimensions.
    1.63 @@ -320,7 +341,7 @@
    1.64      /// \brief The dimension id of an edge.
    1.65      ///
    1.66      /// Gives back the dimension id of the given edge.
    1.67 -    /// It is in the [0..dim-1] range.
    1.68 +    /// It is in the range <tt>[0..dim-1]</tt>.
    1.69      int dimension(Edge edge) const {
    1.70        return Parent::dimension(edge);
    1.71      }
    1.72 @@ -328,7 +349,7 @@
    1.73      /// \brief The dimension id of an arc.
    1.74      ///
    1.75      /// Gives back the dimension id of the given arc.
    1.76 -    /// It is in the [0..dim-1] range.
    1.77 +    /// It is in the range <tt>[0..dim-1]</tt>.
    1.78      int dimension(Arc arc) const {
    1.79        return Parent::dimension(arc);
    1.80      }
    1.81 @@ -337,7 +358,7 @@
    1.82      ///
    1.83      /// Gives back the index of the given node.
    1.84      /// The lower bits of the integer describes the node.
    1.85 -    int index(Node node) const {
    1.86 +    static int index(Node node) {
    1.87        return Parent::index(node);
    1.88      }
    1.89