/**
* Initializes the algorithm. Set up all local instance variables
* and initialize all of the default values for the decorations.
* Dijkstra's is also initialized.
*
* @param g a Graph
* @param source of the flow
* @param dest for the flow */
public void init(InspectableGraph g, Vertex source, Vertex dest)
throws InvalidVertexException {
if( !g.contains( source ) )
throw new InvalidVertexException( source + " not contained in " + g );
if( !g.contains( dest ) )
throw new InvalidVertexException( dest + " not contained in " + g );
graph_ = g;
source_ = source;
dest_ = dest;
finished_ = false;
maximumFlow_ = ZERO;
targetFlow_ = INFINITY;
// init dijkstra's
dijkstra_ = new MinCostFlowDijkstra();
dijkstra_.init(g, source);
// initialize all the default values
VertexIterator vertexIter = vertices();
while (vertexIter.hasNext()) {
Vertex u = vertexIter.nextVertex();
setDistance(u, ZERO);
}
EdgeIterator edgeIter = edges();
while (edgeIter.hasNext()) {
Edge e = edgeIter.nextEdge();
setFlow(e, ZERO);
}
}