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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.jgalgo.FlowNetwork
FlowNetwork.Int
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description static FlowNetwork.Int
createFromEdgeWeights(Graph g)
Create an integer flow network by adding edge weights usingGraph.addEdgesWeights(java.lang.Object, java.lang.Class<? super E>)
.static FlowNetwork.Int
createFromEdgeWeights(Weights.Int capacities, Weights.Int flows)
Create a flow network by using existing edge weights.default double
getCapacity(int edge)
Deprecated.int
getCapacityInt(int edge)
Get the integer capacity of an edge.default double
getCostSum(IntCollection edges, WeightFunction cost)
Get the cost of the flow along a set of edges.default double
getFlow(int edge)
Deprecated.int
getFlowInt(int edge)
Get the integer amount of flow units going along an edge.default void
setCapacity(int edge, double capacity)
Deprecated.void
setCapacity(int edge, int capacity)
Set the integer capacity of an edge.default void
setFlow(int edge, double flow)
Deprecated.void
setFlow(int edge, int flow)
Set the integer amount of flow units going along an edge.-
Methods inherited from interface com.jgalgo.FlowNetwork
getFlowSum, getFlowSum
-
-
-
-
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
- ifedge
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 interfaceFlowNetwork
- 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 graphcapacity
- the new capacity of the edge- Throws:
IndexOutOfBoundsException
- ifedge
is not a valid edge identifierIllegalArgumentException
- ifcapacity
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 interfaceFlowNetwork
- Parameters:
edge
- an edge identifier in the graphcapacity
- 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 fromedgeSource(e)
toedgeTarget(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 fromedgeSource(e)
toedgeTarget(e)
, while a flow of \(-f\) units one
, for \(-cap(e) \leq -f < 0\), means a flow of \(|-f|\) units of flow fromedgeTarget(e)
toedgeSource(e)
(opposite direction).- Parameters:
edge
- an edge identifier in the graph- Returns:
- the amount of flow units going along an edge
- Throws:
IndexOutOfBoundsException
- ifedge
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 fromedgeSource(e)
toedgeTarget(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 fromedgeSource(e)
toedgeTarget(e)
, while a flow of \(-f\) units one
, for \(-cap(e) \leq -f < 0\), means a flow of \(|-f|\) units of flow fromedgeTarget(e)
toedgeSource(e)
(opposite direction).- Specified by:
getFlow
in interfaceFlowNetwork
- 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 graphflow
- the new flow of the edge- Throws:
IndexOutOfBoundsException
- ifedge
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 interfaceFlowNetwork
- Parameters:
edge
- an edge identifier in the graphflow
- 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 interfaceFlowNetwork
- Parameters:
edges
- the set of edges to sum their costcost
- a edge weight cost function- Returns:
- the sum of the cost of the flow along the edges
-
createFromEdgeWeights
static FlowNetwork.Int createFromEdgeWeights(Graph g)
Create an integer flow network by adding edge weights usingGraph.addEdgesWeights(java.lang.Object, java.lang.Class<? super E>)
.Unless
setCapacity(int, int)
orsetFlow(int, int)
are used, the capacity and flow of each edge will be zero.By using
Graph.addEdgesWeights(java.lang.Object, java.lang.Class<? super E>)
, the weights containers (and the flow network) remains valid in case the graph is modified, as they are added to the graph. This is a key difference between this function andFlowNetwork.createFromEdgeWeights(Weights.Double, Weights.Double)
, which if provided with weights containers created withWeights.createExternalEdgesWeights(com.jgalgo.graph.Graph, java.lang.Class<? super E>)
. doesn't remain valid if the graph is modified, but may suite in scenarios in which we are not allowed to add weights to the graph.- Parameters:
g
- a graph- Returns:
- a flow network implemented as edge weights containers added to the graph
-
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 edgesflows
- a weight container that will contain the flow values of the edges- Returns:
- a flow network implemented as external edge weights containers
-
-