org.jgrapht.alg.flow

## Class EdmondsKarpMaximumFlow<V,E>

- java.lang.Object
- - org.jgrapht.alg.flow.MaximumFlowAlgorithmBase<V,E>
  - - org.jgrapht.alg.flow.EdmondsKarpMaximumFlow<V,E>

- All Implemented Interfaces:
    MaximumFlowAlgorithm<V,E>

      public final class EdmondsKarpMaximumFlow<V,E>
      extends MaximumFlowAlgorithmBase<V,E>

  A flow network is a directed graph where each edge has a capacity and each edge receives a flow. The amount of flow on an edge can not exceed the capacity of the edge (note, that all capacities must be non-negative). A flow must satisfy the restriction that the amount of flow into a vertex equals the amount of flow out of it, except when it is a source, which "produces" flow, or sink, which "consumes" flow.

  This class computes maximum flow in a network using Edmonds-Karp algorithm. Be careful: for large networks this algorithm may consume significant amount of time (its upper-bound complexity is O(VE^2), where V - amount of vertices, E - amount of edges in the network).

  For more details see Andrew V. Goldberg's Combinatorial Optimization (Lecture Notes).

  Author:
    Ilya Razensteyn

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.jgrapht.alg.interfaces.MaximumFlowAlgorithm

      `MaximumFlowAlgorithm.MaximumFlow<V,E>, MaximumFlowAlgorithm.MaximumFlowImpl<V,E>`

  - ### Field Summary

    - ### Fields inherited from class org.jgrapht.alg.flow.MaximumFlowAlgorithmBase

      `DEFAULT_EPSILON`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `EdmondsKarpMaximumFlow(DirectedGraph<V,E> network)` Constructs `MaximumFlow` instance to work with a copy of `network`.
    `EdmondsKarpMaximumFlow(DirectedGraph<V,E> network, double epsilon)` Constructs `MaximumFlow` instance to work with a copy of `network`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `MaximumFlowAlgorithm.MaximumFlow<V,E>` | `buildMaximumFlow(V source, V sink)` Sets current source to `source`, current sink to `sink`, then calculates maximum flow from `source` to `sink`.
    `protected org.jgrapht.alg.flow.EdmondsKarpMaximumFlow.EdgeExtension` | `extendedEdge(E e)`
    `protected org.jgrapht.alg.flow.EdmondsKarpMaximumFlow.VertexExtension` | `extendedVertex(V v)`
    `V` | `getCurrentSink()` Returns current sink vertex, or `null` if there was no `calculateMaximumFlow` calls.
    `V` | `getCurrentSource()` Returns current source vertex, or `null` if there was no `calculateMaximumFlow` calls.

    - ### Methods inherited from class org.jgrapht.alg.flow.MaximumFlowAlgorithmBase

      `compareFlowTo, composeFlow, edgeExtended, pushFlowThrough, vertexExtended`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### EdmondsKarpMaximumFlow

          public EdmondsKarpMaximumFlow(DirectedGraph<V,E> network)

      Constructs `MaximumFlow` instance to work with a copy of `network`. Current source and sink are set to `null`. If `network` is weighted, then capacities are weights, otherwise all capacities are equal to one. Doubles are compared using `DEFAULT_EPSILON` tolerance.
      Parameters:
        `network` - network, where maximum flow will be calculated

    - #### EdmondsKarpMaximumFlow

          public EdmondsKarpMaximumFlow(DirectedGraph<V,E> network,
                                double epsilon)

      Constructs `MaximumFlow` instance to work with a copy of `network`. Current source and sink are set to `null`. If `network` is weighted, then capacities are weights, otherwise all capacities are equal to one.
      Parameters:
        `network` - network, where maximum flow will be calculated
        `epsilon` - tolerance for comparing doubles

  - ### Method Detail

    - #### buildMaximumFlow

          public MaximumFlowAlgorithm.MaximumFlow<V,E> buildMaximumFlow(V source,
                                                               V sink)

      Sets current source to `source`, current sink to `sink`, then calculates maximum flow from `source` to `sink`. Note, that `source` and `sink` must be vertices of the `network` passed to the constructor, and they must be different.
      Parameters:
        `source` - source vertex
        `sink` - sink vertex
      Returns:
        maximum flow

    - #### extendedVertex

          protected org.jgrapht.alg.flow.EdmondsKarpMaximumFlow.VertexExtension extendedVertex(V v)

    - #### extendedEdge

          protected org.jgrapht.alg.flow.EdmondsKarpMaximumFlow.EdgeExtension extendedEdge(E e)

    - #### getCurrentSource

          public V getCurrentSource()

      Returns current source vertex, or `null` if there was no `calculateMaximumFlow` calls.
      Returns:
        current source

    - #### getCurrentSink

          public V getCurrentSink()

      Returns current sink vertex, or `null` if there was no `calculateMaximumFlow` calls.
      Returns:
        current sink

Copyright © 2016. All rights reserved.