Loading...
Searching...
No Matches
ListGraph::Snapshot Class Reference

## Detailed Description

Class to make a snapshot of the graph and restore it later.

The newly added nodes and edges can be removed using the restore() function.

Note
  After a state is restored, you cannot restore a later state, i.e. you cannot add the removed nodes and edges again using another Snapshot instance.

Warning
  Node and edge deletions and other modifications (e.g. changing the end-nodes of edges or contracting nodes) cannot be restored. These events invalidate the snapshot. However, the edges and nodes that were added to the graph after making the current snapshot can be removed without invalidating it.

`#include <lemon/list_graph.h>`

## Public Member Functions

| Snapshot ()
| Default constructor.
| Snapshot (ListGraph &gr)
| Constructor that immediately makes a snapshot.
void | save (ListGraph &gr)
| Make a snapshot.
void | restore ()
| Undo the changes until the last snapshot.
bool | valid () const
| Returns `true` if the snapshot is valid.

## Constructor & Destructor Documentation

## Snapshot() [1/2]

Snapshot | ( |  | ) |

inline

Default constructor. You have to call save() to actually make a snapshot.

## Snapshot() [2/2]

Snapshot | ( | ListGraph & | gr | ) |

inline

This constructor immediately makes a snapshot of the given graph.

## Member Function Documentation

## save()

void save | ( | ListGraph & | gr | ) |

inline

This function makes a snapshot of the given graph. It can be called more than once. In case of a repeated call, the previous snapshot gets lost.

## restore()

void restore | ( |  | ) |

inline

This function undos the changes until the last snapshot created by save() or Snapshot(ListGraph&).

Warning
  This method invalidates the snapshot, i.e. repeated restoring is not supported unless you call save() again.

## valid()

bool valid | ( |  | ) | const

inline

This function returns `true` if the snapshot is valid.