Class MinimumCostFlowAbstract
- All Implemented Interfaces:
MinimumCostFlow
- Direct Known Subclasses:
MinimumCostFlowAbstractBasedSourceSink,MinimumCostFlowAbstractBasedSupply
The class implements the interface by solving the problem on the index graph and then maps the results back to the original graph. The implementation for index graphs is abstract and left to the subclasses.
- Author:
- Barak Ugav
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.jgalgo.alg.flow.MinimumCostFlow
MinimumCostFlow.Builder -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<V,E> Flow<V, E> computeMinCostFlow(Graph<V, E> g, WeightFunction<E> capacity, WeightFunction<E> cost, WeightFunction<E> lowerBound, WeightFunction<V> supply) Compute the min-cost (not maximum!)<V,E> Flow<V, E> computeMinCostFlow(Graph<V, E> g, WeightFunction<E> capacity, WeightFunction<E> cost, WeightFunction<V> supply) Compute the min-cost (not maximum!)<V,E> Flow<V, E> computeMinCostMaxFlow(Graph<V, E> g, WeightFunction<E> capacity, WeightFunction<E> cost, WeightFunction<E> lowerBound, Collection<V> sources, Collection<V> sinks) Compute the min-cost max-flow in a network between a set of sources and a set of sinks given a lower bound for the edges flows.<V,E> Flow<V, E> computeMinCostMaxFlow(Graph<V, E> g, WeightFunction<E> capacity, WeightFunction<E> cost, WeightFunction<E> lowerBound, V source, V sink) Compute the min-cost max-flow in a network between a source and a sink given a lower bound for the edges flows.<V,E> Flow<V, E> computeMinCostMaxFlow(Graph<V, E> g, WeightFunction<E> capacity, WeightFunction<E> cost, Collection<V> sources, Collection<V> sinks) Compute the min-cost max-flow in a network between a set of sources and a set of sinks.<V,E> Flow<V, E> computeMinCostMaxFlow(Graph<V, E> g, WeightFunction<E> capacity, WeightFunction<E> cost, V source, V sink) Compute the min-cost max-flow in a network between a source and a sink.
-
Constructor Details
-
MinimumCostFlowAbstract
public MinimumCostFlowAbstract()Default constructor.
-
-
Method Details
-
computeMinCostMaxFlow
public <V,E> Flow<V,E> computeMinCostMaxFlow(Graph<V, E> g, WeightFunction<E> capacity, WeightFunction<E> cost, V source, V sink) Description copied from interface:MinimumCostFlowCompute the min-cost max-flow in a network between a source and a sink.Some algorithm might run faster for integer networks, and
WeightFunctionIntcan be passed as argument ascapacityandcost.If
gis anIntGraph, its better to pass aIWeightFunctionascapacityandcostto avoid boxing/unboxing. Ifgis anIntGraph, the returned object isIFlow.- Specified by:
computeMinCostMaxFlowin interfaceMinimumCostFlow- Type Parameters:
V- the vertices typeE- the edges type- Parameters:
g- the graphcapacity- a capacity edge weight functioncost- an edge weight function representing the cost of each unit of flow along the edgesource- a source vertexsink- a sink vertex- Returns:
- the flows computed for each edge
-
computeMinCostMaxFlow
public <V,E> Flow<V,E> computeMinCostMaxFlow(Graph<V, E> g, WeightFunction<E> capacity, WeightFunction<E> cost, WeightFunction<E> lowerBound, V source, V sink) Description copied from interface:MinimumCostFlowCompute the min-cost max-flow in a network between a source and a sink given a lower bound for the edges flows.If
gis anIntGraph, its better to pass aIWeightFunctionascapacity,costandlowerBoundto avoid boxing/unboxing. Ifgis anIntGraph, the returned object isIFlow.- Specified by:
computeMinCostMaxFlowin interfaceMinimumCostFlow- Type Parameters:
V- the vertices typeE- the edges type- Parameters:
g- the graphcapacity- a capacity edge weight functioncost- an edge weight function representing the cost of each unit of flow along the edgelowerBound- an edge weight function representing a lower bound for the flow along each edgesource- a source vertexsink- a sink vertex- Returns:
- the flows computed for each edge
-
computeMinCostMaxFlow
public <V,E> Flow<V,E> computeMinCostMaxFlow(Graph<V, E> g, WeightFunction<E> capacity, WeightFunction<E> cost, Collection<V> sources, Collection<V> sinks) Description copied from interface:MinimumCostFlowCompute the min-cost max-flow in a network between a set of sources and a set of sinks.Some algorithm might run faster for integer networks, and
WeightFunctionIntcan be passed as argument ascapacityandcost.If
gis anIntGraph, its better to pass aIWeightFunctionascapacityandcost, andIntCollectionassourcesandsinksto avoid boxing/unboxing. Ifgis anIntGraph, the returned object isIFlow.- Specified by:
computeMinCostMaxFlowin interfaceMinimumCostFlow- Type Parameters:
V- the vertices typeE- the edges type- Parameters:
g- the graphcapacity- a capacity edge weight functioncost- an edge weight function representing the cost of each unit of flow along the edgesources- a set of source verticessinks- a set of sinks vertices- Returns:
- the flows computed for each edge
-
computeMinCostMaxFlow
public <V,E> Flow<V,E> computeMinCostMaxFlow(Graph<V, E> g, WeightFunction<E> capacity, WeightFunction<E> cost, WeightFunction<E> lowerBound, Collection<V> sources, Collection<V> sinks) Description copied from interface:MinimumCostFlowCompute the min-cost max-flow in a network between a set of sources and a set of sinks given a lower bound for the edges flows.Some algorithm might run faster for integer networks, and
WeightFunctionIntcan be passed as argument ascapacity,costandlowerBound.If
gis anIntGraph, its better to pass aIWeightFunctionascapacity,costandlowerBound, andIntCollectionassourcesandsinksto avoid boxing/unboxing. Ifgis anIntGraph, the returned object isIFlow.- Specified by:
computeMinCostMaxFlowin interfaceMinimumCostFlow- Type Parameters:
V- the vertices typeE- the edges type- Parameters:
g- the graphcapacity- a capacity edge weight functioncost- an edge weight function representing the cost of each unit of flow along the edgelowerBound- an edge weight function representing a lower bound for the flow along each edgesources- a set of source verticessinks- a set of sinks vertices- Returns:
- the flows computed for each edge
-
computeMinCostFlow
public <V,E> Flow<V,E> computeMinCostFlow(Graph<V, E> g, WeightFunction<E> capacity, WeightFunction<E> cost, WeightFunction<V> supply) Description copied from interface:MinimumCostFlowCompute the min-cost (not maximum!) flow in a network given a supply for each vertex.The supply is a scalar for each vertex, and the objective is to find a minimum-cost flow satisfying the supply, namely that for each vertex the sum of flow units going out of the vertex minus the sum of flow units going into it is equal to its supply.
Some algorithm might run faster for integer networks, and
WeightFunctionIntcan be passed as argument ascapacity,costandsupply.If
gis anIntGraph, its better to pass aIWeightFunctionascapacity,costandsupplyto avoid boxing/unboxing. Ifgis anIntGraph, the returned object isIFlow.- Specified by:
computeMinCostFlowin interfaceMinimumCostFlow- Type Parameters:
V- the vertices typeE- the edges type- Parameters:
g- the graphcapacity- a capacity edge weight functioncost- an edge weight function representing the cost of each unit of flow along the edgesupply- a vertex weight function representing the supply for each vertex- Returns:
- the flows computed for each edge
-
computeMinCostFlow
public <V,E> Flow<V,E> computeMinCostFlow(Graph<V, E> g, WeightFunction<E> capacity, WeightFunction<E> cost, WeightFunction<E> lowerBound, WeightFunction<V> supply) Description copied from interface:MinimumCostFlowCompute the min-cost (not maximum!) flow in a network given a supply for each vertex and a lower bound for the edges flows.The supply is a scalar for each vertex, and the objective is to find a minimum-cost flow satisfying the supply, namely that for each vertex the sum of flow units going out of the vertex minus the sum of flow units going into it is equal to its supply.
Some algorithm might run faster for integer networks, and
WeightFunctionIntcan be passed as argument ascapacity,cost,lowerBoundandsupply.If
gis anIntGraph, its better to pass aIWeightFunctionascapacity,cost,lowerBoundandsupplyto avoid boxing/unboxing. Ifgis anIntGraph, the returned object isIFlow.- Specified by:
computeMinCostFlowin interfaceMinimumCostFlow- Type Parameters:
V- the vertices typeE- the edges type- Parameters:
g- the graphcapacity- a capacity edge weight functioncost- an edge weight function representing the cost of each unit of flow along the edgelowerBound- an edge weight function representing a lower bound for the flow along each edgesupply- a vertex weight function representing the supply for each vertex- Returns:
- the flows computed for each edge
-