com.mhhe.clrs2e
Class FlowNetwork.EdgeIterator

java.lang.Object
  |
  +--com.mhhe.clrs2e.AdjacencyListGraph.EdgeIterator
        |
        +--com.mhhe.clrs2e.FlowNetwork.EdgeIterator
All Implemented Interfaces:
FlowNetworkEdgeIterator, java.util.Iterator
Enclosing class:
FlowNetwork

public class FlowNetwork.EdgeIterator
extends AdjacencyListGraph.EdgeIterator
implements FlowNetworkEdgeIterator

Inner class that overrides AdjacencyListGraph.EdgeIterator to implement FlowNetworkEdgeIterator.


Field Summary
private  boolean residualOnly
          true if this iterator is to return only edges in the residual network, false if it is to return all edges (even those whose residual capacity is not positive.
 
Fields inherited from class com.mhhe.clrs2e.AdjacencyListGraph.EdgeIterator
current, index
 
Constructor Summary
FlowNetwork.EdgeIterator(int v, boolean residual)
          Starts an iteration through the edges incident on a given vertex in a flow network.
 
Method Summary
 double getCapacity()
          Returns the capacity of the edge returned by the most recent call to next.
 java.lang.Object getEdge()
          Returns the edge found by the most recent call to next.
 double getNetFlow()
          Returns the net flow of the edge returned by the most recent call to next.
 double getResidualCapacity()
          Returns the residual capacity of the edge returned by the most recent call to next.
 boolean hasNext()
          Returns true if this edge iterator has more edges, false otherwise.
 void increaseNetFlow(double amount)
          Increases the net flow of the edge returned by the most recent call to next.
 java.lang.Object next()
          Returns the next edge in the iteration.
 void zeroNetFlow()
          Zeros out the net flow of the edge returned by the most recent call to next.
 
Methods inherited from class com.mhhe.clrs2e.AdjacencyListGraph.EdgeIterator
remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Iterator
remove
 

Field Detail

residualOnly

private boolean residualOnly
true if this iterator is to return only edges in the residual network, false if it is to return all edges (even those whose residual capacity is not positive.

Constructor Detail

FlowNetwork.EdgeIterator

public FlowNetwork.EdgeIterator(int v,
                                boolean residual)
Starts an iteration through the edges incident on a given vertex in a flow network.

Parameters:
v - The index of the vertex.
residual - true if this iterator is to return only edges in the residual network, false if it is to return all edges.
Method Detail

hasNext

public boolean hasNext()
Returns true if this edge iterator has more edges, false otherwise. Depending on the instance variable residualOnly, this method may consider only edges that are present in the residual network.

Specified by:
hasNext in interface java.util.Iterator
Overrides:
hasNext in class AdjacencyListGraph.EdgeIterator

next

public java.lang.Object next()
Returns the next edge in the iteration. Depending on the instance variable residualOnly, this method may consider only edges that are present in the residual network.

Specified by:
next in interface java.util.Iterator
Overrides:
next in class AdjacencyListGraph.EdgeIterator

getEdge

public java.lang.Object getEdge()
Returns the edge found by the most recent call to next. Unlike next, this method returns an object corresponding to the edge itself rather than just the adjacent vertex.

Specified by:
getEdge in interface FlowNetworkEdgeIterator

getCapacity

public double getCapacity()
Returns the capacity of the edge returned by the most recent call to next.

Specified by:
getCapacity in interface FlowNetworkEdgeIterator

getNetFlow

public double getNetFlow()
Returns the net flow of the edge returned by the most recent call to next.

Specified by:
getNetFlow in interface FlowNetworkEdgeIterator

getResidualCapacity

public double getResidualCapacity()
Returns the residual capacity of the edge returned by the most recent call to next.

Specified by:
getResidualCapacity in interface FlowNetworkEdgeIterator

zeroNetFlow

public void zeroNetFlow()
Zeros out the net flow of the edge returned by the most recent call to next.

Specified by:
zeroNetFlow in interface FlowNetworkEdgeIterator

increaseNetFlow

public void increaseNetFlow(double amount)
Increases the net flow of the edge returned by the most recent call to next.

Specified by:
increaseNetFlow in interface FlowNetworkEdgeIterator
Parameters:
amount - The amount by which this edge's flow is increased.