Class GraphMaximumFlowExtensions
- Namespace
- Graph1x.Algorithms
- Assembly
- Graph1x.dll
Convenience entry points for maximum-flow queries, defaulting to Edmonds-Karp.
public static class GraphMaximumFlowExtensions
- Inheritance
-
GraphMaximumFlowExtensions
- Inherited Members
Methods
MaximumFlow<TVertex, TWeight>(IDirectedGraph<TVertex, WeightedEdge<TVertex, TWeight>>, TVertex, TVertex)
Computes the maximum flow from source to
sink using Edmonds-Karp and the capacities carried
by the graph's WeightedEdge<TVertex, TWeight> edges.
public static MaximumFlowResult<TVertex, WeightedEdge<TVertex, TWeight>, TWeight> MaximumFlow<TVertex, TWeight>(this IDirectedGraph<TVertex, WeightedEdge<TVertex, TWeight>> graph, TVertex source, TVertex sink) where TVertex : notnull where TWeight : INumber<TWeight>
Parameters
graphIDirectedGraph<TVertex, WeightedEdge<TVertex, TWeight>>The directed flow network.
sourceTVertexThe vertex the flow originates from.
sinkTVertexThe vertex the flow drains into.
Returns
- MaximumFlowResult<TVertex, WeightedEdge<TVertex, TWeight>, TWeight>
The flow value, per-edge flows, and a minimum cut.
Type Parameters
TVertexThe vertex type.
TWeightThe numeric capacity type.
Exceptions
- NegativeWeightException
An edge has negative capacity.
MaximumFlow<TVertex, TEdge, TWeight>(IDirectedGraph<TVertex, TEdge>, TVertex, TVertex, Func<TEdge, TWeight>)
Computes the maximum flow from source to
sink using Edmonds-Karp and
capacitySelector to read edge capacities.
public static MaximumFlowResult<TVertex, TEdge, TWeight> MaximumFlow<TVertex, TEdge, TWeight>(this IDirectedGraph<TVertex, TEdge> graph, TVertex source, TVertex sink, Func<TEdge, TWeight> capacitySelector) where TVertex : notnull where TEdge : IEdge<TVertex> where TWeight : INumber<TWeight>
Parameters
graphIDirectedGraph<TVertex, TEdge>The directed flow network.
sourceTVertexThe vertex the flow originates from.
sinkTVertexThe vertex the flow drains into.
capacitySelectorFunc<TEdge, TWeight>Maps an edge to its capacity.
Returns
- MaximumFlowResult<TVertex, TEdge, TWeight>
The flow value, per-edge flows, and a minimum cut.
Type Parameters
TVertexThe vertex type.
TEdgeThe edge type.
TWeightThe numeric capacity type.
Exceptions
- NegativeWeightException
An edge has negative capacity.
MaximumFlow<TVertex, TEdge, TWeight>(IDirectedGraph<TVertex, TEdge>, TVertex, TVertex, Func<TEdge, TWeight>, CancellationToken)
Computes the maximum flow using Edmonds-Karp, observing
cancellationToken between augmenting paths.
public static MaximumFlowResult<TVertex, TEdge, TWeight> MaximumFlow<TVertex, TEdge, TWeight>(this IDirectedGraph<TVertex, TEdge> graph, TVertex source, TVertex sink, Func<TEdge, TWeight> capacitySelector, CancellationToken cancellationToken) where TVertex : notnull where TEdge : IEdge<TVertex> where TWeight : INumber<TWeight>
Parameters
graphIDirectedGraph<TVertex, TEdge>The directed flow network.
sourceTVertexThe vertex the flow originates from.
sinkTVertexThe vertex the flow drains into.
capacitySelectorFunc<TEdge, TWeight>Maps an edge to its capacity.
cancellationTokenCancellationTokenCancels the computation cooperatively.
Returns
- MaximumFlowResult<TVertex, TEdge, TWeight>
The flow value, per-edge flows, and a minimum cut.
Type Parameters
TVertexThe vertex type.
TEdgeThe edge type.
TWeightThe numeric capacity type.
Exceptions
- NegativeWeightException
An edge has negative capacity.
- OperationCanceledException
The token was cancelled.