public final class NetworkFlows extends Object
s
and a sink node t
,
find a flow of maximum value from s
to t
.
s
and a sink node t
,
find an s-t
cut of minimum capacity (i.e., a set of edges of minimum capacity whose removal would disconnect t
from s
).
s
and a sink node
t
, find a flow of maximum value from s
to t
that has the minimum total cost.
Modifier and Type | Method and Description |
---|---|
static int |
calcMaxFlow(Graph graph,
Node source,
Node sink,
IDataProvider eCapDP,
IEdgeMap flowEM)
Solves a maximum flow problem using the preflow-push method.
|
static int |
calcMaxFlowMinCut(Graph graph,
Node source,
Node sink,
IDataProvider eCapDP,
IEdgeMap flowEM,
INodeMap sourceCutNM)
Solves a maximum flow problem using the preflow-push method but additionally marks all nodes that belong to the minimum
cut set that is associated with the source of the network.
|
static int |
minCostFlow(Graph graph,
IDataProvider lCapDP,
IDataProvider uCapDP,
IDataProvider cost0DP,
IDataProvider supplyDP,
IEdgeMap flowEM,
INodeMap dualsNM)
Solves a minimum cost flow problem with a capacity scaling algorithm.
|
static int |
minCostFlow(Graph graph,
IDataProvider uCapDP,
IDataProvider cost0DP,
IDataProvider supplyDP,
IEdgeMap flowEM,
INodeMap dualsNM)
Uses method
minCostFlow(Graph, IDataProvider, IDataProvider, IDataProvider, IDataProvider, IEdgeMap, INodeMap)
to solve a minimum cost flow problem. |
static int |
minCostFlow(Graph graph,
Node s,
Node t,
IDataProvider uCapDP,
IDataProvider cost0DP,
IEdgeMap flowEM,
INodeMap dualsNM)
Solves a minimum cost maximum flow problem.
|
public static final int calcMaxFlow(Graph graph, Node source, Node sink, IDataProvider eCapDP, IEdgeMap flowEM)
The implementation is based on
The worst case running time is O(mdeg * n^2 * m^(1/2))
, where n
is the number of nodes in the network, m
the number of edges and mdeg
the maximal degree of any node.
Edges may have infinite capacity, which is denoted by the value Integer.MAX_VALUE
.
graph
- the given networksource
- the source node of the networksink
- the sink node of the networkeCapDP
- the IEdgeMap
that returns the integer capacity of each edge or null
if no bound is specifiedflowEM
- the IEdgeMap
that will be filled during the execution with an integer flow for each edgecalcMaxFlowMinCut(Graph, Node, Node, IDataProvider, IEdgeMap, INodeMap)
public static final int calcMaxFlowMinCut(Graph graph, Node source, Node sink, IDataProvider eCapDP, IEdgeMap flowEM, INodeMap sourceCutNM)
graph
- the given networksource
- the source node of the networksink
- the sink node of the networkeCapDP
- the IEdgeMap
that returns the integer capacity of each edge or null
if no bound is specifiedflowEM
- the IEdgeMap
that will be filled during the execution with an integer flow for each edgesourceCutNM
- the INodeMap
that will be filled during the execution and returns a boolean value indicating whether or not a
node belongs to the cut set associated with the source of the networkcalcMaxFlow(Graph, Node, Node, IDataProvider, IEdgeMap)
public static final int minCostFlow(Graph graph, IDataProvider lCapDP, IDataProvider uCapDP, IDataProvider cost0DP, IDataProvider supplyDP, IEdgeMap flowEM, INodeMap dualsNM)
This algorithm is a variant of the successive shortest path algorithm (see Ahuja,Magnanti,Orlin: Network flows,
Prentice Hall, 1993, pp.320-324). It has the pseudo-polynomial running time O(m*log U*(m+n log n))
where n
is the number of nodes in the network, m
the number of edges and U
the maximal edge capacity.
Edges may have infinite capacity, which is denoted by the value Integer.MAX_VALUE
.
There are no restriction for the costs. In particular, they can also be negative.
graph
- the given networklCapDP
- the IDataProvider
that returns the integer lower bound for the capacity of each edge or null
if no bound
is specifieduCapDP
- the IDataProvider
that returns the integer upper bound for the capacity of each edge or null
if no bound
is specifiedcost0DP
- the IDataProvider
that returns a double value (cost) of each edgesupplyDP
- the IDataProvider
that returns the supply/demand of each node; supply is denoted by a positive value, demand by
a negative valueflowEM
- the IEdgeMap
that will be filled during the execution with an integer flow for each edgedualsNM
- the INodeMap
that will be filled during the execution with an integer value (dual value) for each node or null
if no such values occur; dual values are also referred as potentialsminCostFlow(Graph, IDataProvider, IDataProvider, IDataProvider, IEdgeMap, INodeMap)
,
minCostFlow(Graph, Node, Node, IDataProvider, IDataProvider, IEdgeMap, INodeMap)
public static final int minCostFlow(Graph graph, IDataProvider uCapDP, IDataProvider cost0DP, IDataProvider supplyDP, IEdgeMap flowEM, INodeMap dualsNM)
minCostFlow(Graph, IDataProvider, IDataProvider, IDataProvider, IDataProvider, IEdgeMap, INodeMap)
to solve a minimum cost flow problem.graph
- the given networkuCapDP
- the IDataProvider
that returns the integer capacity of each edge or null
if no bound is specifiedcost0DP
- the IDataProvider
that returns a double value (cost) for each edgesupplyDP
- the IDataProvider
that returns the supply/demand of each node; supply is denoted by a positive value, demand by
a negative valueflowEM
- the IEdgeMap
that will be filled during the execution with an integer flow for each edgedualsNM
- the INodeMap
that will be filled during the execution with an integer value (dual value) for each node or null
if no such values occur; dual values are also referred as potentialsminCostFlow(Graph, Node, Node, IDataProvider, IDataProvider, IEdgeMap, INodeMap)
,
minCostFlow(Graph, IDataProvider, IDataProvider, IDataProvider, IDataProvider, IEdgeMap, INodeMap)
public static final int minCostFlow(Graph graph, Node s, Node t, IDataProvider uCapDP, IDataProvider cost0DP, IEdgeMap flowEM, INodeMap dualsNM)
graph
- the given networks
- the source node of the networkt
- the sink node of the networkuCapDP
- the IDataProvider
that returns the integer capacity of each edge or null
if no bound is specifiedcost0DP
- the IDataProvider
that returns a double value (cost) for each edgeflowEM
- the IEdgeMap
that will be filled during the execution with an integer flow for each edgedualsNM
- the INodeMap
that will be filled during the execution with an integer value (dual value) for each node or null
if no such values occur; dual values are also referred as potentialsminCostFlow(Graph, IDataProvider, IDataProvider, IDataProvider, IDataProvider, IEdgeMap, INodeMap)
,
minCostFlow(Graph, IDataProvider, IDataProvider, IDataProvider, IEdgeMap, INodeMap)