lemon/hypercube_graph.h
changeset 782 ceb2756dea2a
parent 778 a143f19f465b
parent 737 9d6c3e8b2421
child 787 c2230649a493
     1.1 --- a/lemon/hypercube_graph.h	Mon Sep 28 15:53:20 2009 +0200
     1.2 +++ b/lemon/hypercube_graph.h	Thu Nov 05 10:27:17 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,21 @@
    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    /// \note The type of the indices is chosen to \c int for efficiency
    1.31    /// reasons. Thus the maximum dimension of this implementation is 26
    1.32    /// (assuming that the size of \c int is 32 bit).
    1.33 -  ///
    1.34 -  /// This graph type fully conforms to the \ref concepts::Graph
    1.35 -  /// "Graph concept".
    1.36    class HypercubeGraph : public ExtendedHypercubeGraphBase {
    1.37      typedef ExtendedHypercubeGraphBase Parent;
    1.38  
    1.39 @@ -303,6 +307,21 @@
    1.40      /// Constructs a hypercube graph with \c dim dimensions.
    1.41      HypercubeGraph(int dim) { construct(dim); }
    1.42  
    1.43 +    /// \brief Resizes the graph
    1.44 +    ///
    1.45 +    /// This function resizes the graph. It fully destroys and
    1.46 +    /// rebuilds the structure, therefore the maps of the graph will be
    1.47 +    /// reallocated automatically and the previous values will be lost.
    1.48 +    void resize(int dim) {
    1.49 +      Parent::notifier(Arc()).clear();
    1.50 +      Parent::notifier(Edge()).clear();
    1.51 +      Parent::notifier(Node()).clear();
    1.52 +      construct(dim);
    1.53 +      Parent::notifier(Node()).build();
    1.54 +      Parent::notifier(Edge()).build();
    1.55 +      Parent::notifier(Arc()).build();
    1.56 +    }
    1.57 +
    1.58      /// \brief The number of dimensions.
    1.59      ///
    1.60      /// Gives back the number of dimensions.
    1.61 @@ -320,7 +339,7 @@
    1.62      /// \brief The dimension id of an edge.
    1.63      ///
    1.64      /// Gives back the dimension id of the given edge.
    1.65 -    /// It is in the [0..dim-1] range.
    1.66 +    /// It is in the range <tt>[0..dim-1]</tt>.
    1.67      int dimension(Edge edge) const {
    1.68        return Parent::dimension(edge);
    1.69      }
    1.70 @@ -328,7 +347,7 @@
    1.71      /// \brief The dimension id of an arc.
    1.72      ///
    1.73      /// Gives back the dimension id of the given arc.
    1.74 -    /// It is in the [0..dim-1] range.
    1.75 +    /// It is in the range <tt>[0..dim-1]</tt>.
    1.76      int dimension(Arc arc) const {
    1.77        return Parent::dimension(arc);
    1.78      }
    1.79 @@ -337,7 +356,7 @@
    1.80      ///
    1.81      /// Gives back the index of the given node.
    1.82      /// The lower bits of the integer describes the node.
    1.83 -    int index(Node node) const {
    1.84 +    static int index(Node node) {
    1.85        return Parent::index(node);
    1.86      }
    1.87