Package com.jgalgo

Interface FlowNetwork.Int

  • All Superinterfaces:
    FlowNetwork
    Enclosing interface:
    FlowNetwork

    public static interface FlowNetwork.Int
    extends FlowNetwork
    Flow on graph edges, with integer capacities and flows values.

    Similar to the regular FlowNetwork interface, but with integer capacities and flows. Some algorithms that work on flow networks are specifically for integers networks, or may performed faster if the capacities and flows are integers.

    Author:
    Barak Ugav
    • Method Detail

      • getCapacityInt

        int getCapacityInt​(int edge)
        Get the integer capacity of an edge.
        Parameters:
        edge - an edge identifier in the graph
        Returns:
        the capacity of the edge
        Throws:
        IndexOutOfBoundsException - if edge is not a valid edge identifier
      • getCapacity

        @Deprecated
        default double getCapacity​(int edge)
        Deprecated.
        Description copied from interface: FlowNetwork
        Get the capacity of an edge.
        Specified by:
        getCapacity in interface FlowNetwork
        Parameters:
        edge - an edge identifier in the graph
        Returns:
        the capacity of the edge
      • setCapacity

        void setCapacity​(int edge,
                         int capacity)
        Set the integer capacity of an edge.
        Parameters:
        edge - an edge identifier in the graph
        capacity - the new capacity of the edge
        Throws:
        IndexOutOfBoundsException - if edge is not a valid edge identifier
        IllegalArgumentException - if capacity is negative
      • setCapacity

        @Deprecated
        default void setCapacity​(int edge,
                                 double capacity)
        Deprecated.
        Description copied from interface: FlowNetwork
        Set the capacity of an edge.
        Specified by:
        setCapacity in interface FlowNetwork
        Parameters:
        edge - an edge identifier in the graph
        capacity - the new capacity of the edge
      • getFlowInt

        int getFlowInt​(int edge)
        Get the integer amount of flow units going along an edge.

        If the graph is directed, a flow of \(f\) units on e, for \(0 \leq f \leq cap(e)\), means a flow of \(f\) units of flow from edgeSource(e) to edgeTarget(e).

        If the graph is undirected, a flow of \(+f\) units on e, for \(0 \leq f \leq cap(e)\), means a flow of \(f\) units of flow from edgeSource(e) to edgeTarget(e), while a flow of \(-f\) units on e, for \(-cap(e) \leq -f < 0\), means a flow of \(|-f|\) units of flow from edgeTarget(e) to edgeSource(e) (opposite direction).

        Parameters:
        edge - an edge identifier in the graph
        Returns:
        the amount of flow units going along an edge
        Throws:
        IndexOutOfBoundsException - if edge is not a valid edge identifier
      • getFlow

        @Deprecated
        default double getFlow​(int edge)
        Deprecated.
        Description copied from interface: FlowNetwork
        Get the amount of flow units going along an edge.

        If the graph is directed, a flow of \(f\) units on e, for \(0 \leq f \leq cap(e)\), means a flow of \(f\) units of flow from edgeSource(e) to edgeTarget(e).

        If the graph is undirected, a flow of \(+f\) units on e, for \(0 \leq f \leq cap(e)\), means a flow of \(f\) units of flow from edgeSource(e) to edgeTarget(e), while a flow of \(-f\) units on e, for \(-cap(e) \leq -f < 0\), means a flow of \(|-f|\) units of flow from edgeTarget(e) to edgeSource(e) (opposite direction).

        Specified by:
        getFlow in interface FlowNetwork
        Parameters:
        edge - an edge identifier in the graph
        Returns:
        the amount of flow units going along an edge
      • setFlow

        void setFlow​(int edge,
                     int flow)
        Set the integer amount of flow units going along an edge.
        Parameters:
        edge - an edge identifier in the graph
        flow - the new flow of the edge
        Throws:
        IndexOutOfBoundsException - if edge is not a valid edge identifier
      • setFlow

        @Deprecated
        default void setFlow​(int edge,
                             double flow)
        Deprecated.
        Description copied from interface: FlowNetwork
        Set the amount of flow units going along an edge.
        Specified by:
        setFlow in interface FlowNetwork
        Parameters:
        edge - an edge identifier in the graph
        flow - the new flow of the edge
      • getCostSum

        default double getCostSum​(IntCollection edges,
                                  WeightFunction cost)
        Description copied from interface: FlowNetwork
        Get the cost of the flow along a set of edges.

        The cost function define the cost per unit of flow on each edge of the network. The cost of an edge in the network is defined as the flow on the edge multiplied by the cost per unit of flow on the edge.

        Specified by:
        getCostSum in interface FlowNetwork
        Parameters:
        edges - the set of edges to sum their cost
        cost - a edge weight cost function
        Returns:
        the sum of the cost of the flow along the edges
      • createFromEdgeWeights

        static FlowNetwork.Int createFromEdgeWeights​(Weights.Int capacities,
                                                     Weights.Int flows)
        Create a flow network by using existing edge weights.

        This method can be used together with Weights.createExternalEdgesWeights(com.jgalgo.graph.Graph, java.lang.Class<? super E>), creating a flow network for a graph without adding any new containers to it. This is useful in scenarios in which we are not allowed to modify the graph.

        Parameters:
        capacities - a weight container containing the capacities of the edges
        flows - a weight container that will contain the flow values of the edges
        Returns:
        a flow network implemented as external edge weights containers