next up previous index
Next: Workspace Up: Other methods Previous: Other methods   Index


Version number

The on-line implementation in the DataStructures package also provides a protected instance variable
protected int version;
The reason is that some other methods, applied to weighted graphs, particularly the shortest path algorithms described below, only need to be re-run if the graph has changed in some way since the algorithm was last run. The version variable keeps track of such changes. You will see in the on-line code that this variable is initialised to 0 and is incremented each time an arc is inserted or removed. A shortest path algorithm, for example, defined in the same package, can then check whether the current version is the same as the version when the algorithm was last run. If so, there may be no need to re-run the algorithm.

The version number could also be used to protect against changes to the graph during the course of an iteration. But this has not been implemented here.



Peter Williams 2005-06-07