COIN-OR::LEMON - Graph Library

Ticket #311: 311-restore-alt-819ca5b50de0.patch

File 311-restore-alt-819ca5b50de0.patch, 2.0 KB (added by Peter Kovacs, 15 years ago)
  • lemon/list_graph.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1254212511 -7200
    # Node ID 819ca5b50de0c849d6097a3bf933060bbf21404d
    # Parent  456fa5bc32569263c32886a2f1ebbc62b50e2500
    Add a warning for List(Di)Graph::Snapshot (#311)
    and extend tests for snapshots
    
    diff --git a/lemon/list_graph.h b/lemon/list_graph.h
    a b  
    751751      ///
    752752      /// This function undos the changes until the last snapshot
    753753      /// created by save() or Snapshot(ListDigraph&).
     754      ///
     755      /// \warning This method invalidates the snapshot, i.e. repeated
     756      /// restoring is not supported unless you call save() again.
    754757      void restore() {
    755758        detach();
    756759        for(std::list<Arc>::iterator it = added_arcs.begin();
     
    15501553      ///
    15511554      /// This function undos the changes until the last snapshot
    15521555      /// created by save() or Snapshot(ListGraph&).
     1556      ///
     1557      /// \warning This method invalidates the snapshot, i.e. repeated
     1558      /// restoring is not supported unless you call save() again.
    15531559      void restore() {
    15541560        detach();
    15551561        for(std::list<Edge>::iterator it = added_edges.begin();
  • test/digraph_test.cc

    diff --git a/test/digraph_test.cc b/test/digraph_test.cc
    a b  
    286286  G.addArc(G.addNode(), G.addNode());
    287287
    288288  snapshot.restore();
     289  snapshot.save(G);
     290
     291  checkGraphNodeList(G, 4);
     292  checkGraphArcList(G, 4);
     293
     294  G.addArc(G.addNode(), G.addNode());
     295
     296  snapshot.restore();
    289297
    290298  checkGraphNodeList(G, 4);
    291299  checkGraphArcList(G, 4);
  • test/graph_test.cc

    diff --git a/test/graph_test.cc b/test/graph_test.cc
    a b  
    259259  G.addEdge(G.addNode(), G.addNode());
    260260
    261261  snapshot.restore();
     262  snapshot.save(G);
     263
     264  checkGraphNodeList(G, 4);
     265  checkGraphEdgeList(G, 3);
     266  checkGraphArcList(G, 6);
     267 
     268  G.addEdge(G.addNode(), G.addNode());
     269
     270  snapshot.restore();
    262271
    263272  checkGraphNodeList(G, 4);
    264273  checkGraphEdgeList(G, 3);