/**
* Helper method to copy all of the vertex distances from an
* execution of Dijkstra's algorithm into local decorations so they
* can be used in computing the residual network for the next
* execution of Dijkstra's. */
protected void updateDistances() {
// copy distances from residual network to our network
VertexIterator vertexIter = vertices();
while (vertexIter.hasNext()) {
Vertex v = vertexIter.nextVertex();
try {
setDistance(v, dijkstra_.distance(v));
} catch (InvalidQueryException iqe) {
// vertex is unreachable; set distance to INFINITY
setDistance(v, INFINITY);
}
}
}
/**
* Helper method to execute Dijkstra's on the residual network. We
* are sure to cleanup all past executions by first calling the
* cleanup() method. */
protected void runDijkstraOnResidualNetwork() {
dijkstra_.cleanup();
dijkstra_.execute(graph_, source_, dest_);
}
/**
* Helper method that is called exactly once when the algorithm is
* finished executing. */
protected void finished() {
finished_ = true;
}