1.1 --- a/lemon/hypercube_graph.h Sun Aug 23 11:10:40 2009 +0200
1.2 +++ b/lemon/hypercube_graph.h Sun Aug 23 11:11:49 2009 +0200
1.3 @@ -287,7 +287,8 @@
1.4 /// Two nodes are connected in the graph if and only if their indices
1.5 /// differ only on one position in the binary form.
1.6 /// This class is completely static and it needs constant memory space.
1.7 - /// Thus you can neither add nor delete nodes or edges.
1.8 + /// Thus you can neither add nor delete nodes or edges, however
1.9 + /// the structure can be resized using resize().
1.10 ///
1.11 /// This type fully conforms to the \ref concepts::Graph "Graph concept".
1.12 /// Most of its member functions and nested classes are documented
1.13 @@ -306,6 +307,21 @@
1.14 /// Constructs a hypercube graph with \c dim dimensions.
1.15 HypercubeGraph(int dim) { construct(dim); }
1.16
1.17 + /// \brief Resizes the graph
1.18 + ///
1.19 + /// This function resizes the graph. It fully destroys and
1.20 + /// rebuilds the structure, therefore the maps of the graph will be
1.21 + /// reallocated automatically and the previous values will be lost.
1.22 + void resize(int dim) {
1.23 + Parent::notifier(Arc()).clear();
1.24 + Parent::notifier(Edge()).clear();
1.25 + Parent::notifier(Node()).clear();
1.26 + construct(dim);
1.27 + Parent::notifier(Node()).build();
1.28 + Parent::notifier(Edge()).build();
1.29 + Parent::notifier(Arc()).build();
1.30 + }
1.31 +
1.32 /// \brief The number of dimensions.
1.33 ///
1.34 /// Gives back the number of dimensions.
2.1 --- a/test/digraph_test.cc Sun Aug 23 11:10:40 2009 +0200
2.2 +++ b/test/digraph_test.cc Sun Aug 23 11:11:49 2009 +0200
2.3 @@ -378,7 +378,12 @@
2.4 void checkFullDigraph(int num) {
2.5 typedef FullDigraph Digraph;
2.6 DIGRAPH_TYPEDEFS(Digraph);
2.7 +
2.8 Digraph G(num);
2.9 + check(G.nodeNum() == num && G.arcNum() == num * num, "Wrong size");
2.10 +
2.11 + G.resize(num);
2.12 + check(G.nodeNum() == num && G.arcNum() == num * num, "Wrong size");
2.13
2.14 checkGraphNodeList(G, num);
2.15 checkGraphArcList(G, num * num);
3.1 --- a/test/graph_test.cc Sun Aug 23 11:10:40 2009 +0200
3.2 +++ b/test/graph_test.cc Sun Aug 23 11:11:49 2009 +0200
3.3 @@ -270,6 +270,13 @@
3.4 GRAPH_TYPEDEFS(Graph);
3.5
3.6 Graph G(num);
3.7 + check(G.nodeNum() == num && G.edgeNum() == num * (num - 1) / 2,
3.8 + "Wrong size");
3.9 +
3.10 + G.resize(num);
3.11 + check(G.nodeNum() == num && G.edgeNum() == num * (num - 1) / 2,
3.12 + "Wrong size");
3.13 +
3.14 checkGraphNodeList(G, num);
3.15 checkGraphEdgeList(G, num * (num - 1) / 2);
3.16
3.17 @@ -414,6 +421,10 @@
3.18 check(G.width() == width, "Wrong column number");
3.19 check(G.height() == height, "Wrong row number");
3.20
3.21 + G.resize(width, height);
3.22 + check(G.width() == width, "Wrong column number");
3.23 + check(G.height() == height, "Wrong row number");
3.24 +
3.25 for (int i = 0; i < width; ++i) {
3.26 for (int j = 0; j < height; ++j) {
3.27 check(G.col(G(i, j)) == i, "Wrong column");
3.28 @@ -489,6 +500,11 @@
3.29 GRAPH_TYPEDEFS(HypercubeGraph);
3.30
3.31 HypercubeGraph G(dim);
3.32 + check(G.dimension() == dim, "Wrong dimension");
3.33 +
3.34 + G.resize(dim);
3.35 + check(G.dimension() == dim, "Wrong dimension");
3.36 +
3.37 checkGraphNodeList(G, 1 << dim);
3.38 checkGraphEdgeList(G, dim * (1 << (dim-1)));
3.39 checkGraphArcList(G, dim * (1 << dim));