类 FordFulkerson


  • public class FordFulkerson
    extends java.lang.Object
    The FordFulkerson class represents a data type for computing a maximum st-flow and minimum st-cut in a flow network.

    This implementation uses the Ford-Fulkerson algorithm with the shortest augmenting path heuristic. The constructor takes time proportional to E V (E + V) in the worst case and extra space (not including the network) proportional to V, where V is the number of vertices and E is the number of edges. In practice, the algorithm will run much faster. Afterwards, the inCut() and value() methods take constant time.

    If the capacities and initial flow values are all integers, then this implementation guarantees to compute an integer-valued maximum flow. If the capacities and floating-point numbers, then floating-point roundoff error can accumulate.

    For additional documentation, see Section 6.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

    • 构造器概要

      构造器 
      构造器 说明
      FordFulkerson​(FlowNetwork G, int s, int t)
      Compute a maximum flow and minimum cut in the network G from vertex s to vertex t.
    • 方法概要

      修饰符和类型 方法 说明
      boolean inCut​(int v)
      Returns true if the specified vertex is on the s side of the mincut.
      static void main​(java.lang.String[] args)
      Unit tests the FordFulkerson data type.
      double value()
      Returns the value of the maximum flow.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • FordFulkerson

        public FordFulkerson​(FlowNetwork G,
                             int s,
                             int t)
        Compute a maximum flow and minimum cut in the network G from vertex s to vertex t.
        参数:
        G - the flow network
        s - the source vertex
        t - the sink vertex
        抛出:
        java.lang.IllegalArgumentException - unless 0 <= s < V
        java.lang.IllegalArgumentException - unless 0 <= t < V
        java.lang.IllegalArgumentException - if s == t
        java.lang.IllegalArgumentException - if initial flow is infeasible
    • 方法详细资料

      • value

        public double value()
        Returns the value of the maximum flow.
        返回:
        the value of the maximum flow
      • inCut

        public boolean inCut​(int v)
        Returns true if the specified vertex is on the s side of the mincut.
        参数:
        v - vertex
        返回:
        true if vertex v is on the s side of the micut; false otherwise
        抛出:
        java.lang.IllegalArgumentException - unless 0 <= v < V
      • main

        public static void main​(java.lang.String[] args)
        Unit tests the FordFulkerson data type.
        参数:
        args - the command-line arguments