Serious bugfix in ListGraph::SnapShot and SmartGraph::SnapShot
authoralpar
Thu, 09 Jun 2005 09:47:51 +0000
changeset 1457be025fc1b13d
parent 1456 5289afbdb720
child 1458 7a483c1d38b5
Serious bugfix in ListGraph::SnapShot and SmartGraph::SnapShot
lemon/list_graph.h
lemon/smart_graph.h
     1.1 --- a/lemon/list_graph.h	Thu Jun 09 09:46:34 2005 +0000
     1.2 +++ b/lemon/list_graph.h	Thu Jun 09 09:47:51 2005 +0000
     1.3 @@ -457,6 +457,13 @@
     1.4  	exit(1);
     1.5        }
     1.6  
     1.7 +      ///\bug What is this used for?
     1.8 +      ///
     1.9 +      virtual void build() {}
    1.10 +      ///\bug What is this used for?
    1.11 +      ///
    1.12 +      virtual void clear() {}
    1.13 +
    1.14        void regist(ListGraph &_g) {
    1.15  	g=&_g;
    1.16  	AlterationNotifier<Node>::ObserverBase::
    1.17 @@ -517,13 +524,14 @@
    1.18      ///
    1.19      ///\todo This function might be called undo().
    1.20        void restore() {
    1.21 +	ListGraph &old_g=*g;
    1.22  	deregist();
    1.23  	while(!added_edges.empty()) {
    1.24 -	  g->erase(added_edges.front());
    1.25 +	  old_g.erase(added_edges.front());
    1.26  	  added_edges.pop_front();
    1.27  	}
    1.28   	while(!added_nodes.empty()) {
    1.29 -	  g->erase(added_nodes.front());
    1.30 +	  old_g.erase(added_nodes.front());
    1.31  	  added_nodes.pop_front();
    1.32  	}
    1.33        }
     2.1 --- a/lemon/smart_graph.h	Thu Jun 09 09:46:34 2005 +0000
     2.2 +++ b/lemon/smart_graph.h	Thu Jun 09 09:47:51 2005 +0000
     2.3 @@ -280,14 +280,14 @@
     2.4    protected:
     2.5      void restoreSnapShot(const SnapShot &s)
     2.6      {
     2.7 -      while(s.edge_num>edges.size()) {
     2.8 +      while(s.edge_num<edges.size()) {
     2.9  	Parent::getNotifier(Edge()).erase(Edge(edges.size()-1));
    2.10  	nodes[edges.back().target].first_in=edges.back().next_in;
    2.11  	nodes[edges.back().source].first_out=edges.back().next_out;
    2.12  	edges.pop_back();
    2.13        }
    2.14        //nodes.resize(s.nodes_num);
    2.15 -      while(s.node_num>nodes.size()) {
    2.16 +      while(s.node_num<nodes.size()) {
    2.17  	Parent::getNotifier(Node()).erase(Node(nodes.size()-1));
    2.18  	nodes.pop_back();
    2.19        }