Interface IMaximumFlowAlgorithm<TVertex, TEdge, TWeight>
- Namespace
- Graph1x.Algorithms
- Assembly
- Graph1x.dll
A maximum-flow strategy for directed graphs with non-negative edge capacities. Implementations compute the maximum flow from a source to a sink together with a certifying minimum cut.
public interface IMaximumFlowAlgorithm<TVertex, TEdge, TWeight> where TVertex : notnull where TEdge : IEdge<TVertex> where TWeight : INumber<TWeight>
Type Parameters
TVertexThe vertex type.
TEdgeThe edge type.
TWeightThe numeric capacity type.
Methods
FindMaximumFlow(IDirectedGraph<TVertex, TEdge>, TVertex, TVertex)
Computes the maximum flow from source to sink.
MaximumFlowResult<TVertex, TEdge, TWeight> FindMaximumFlow(IDirectedGraph<TVertex, TEdge> graph, TVertex source, TVertex sink)
Parameters
graphIDirectedGraph<TVertex, TEdge>The directed flow network.
sourceTVertexThe vertex the flow originates from.
sinkTVertexThe vertex the flow drains into.
Returns
- MaximumFlowResult<TVertex, TEdge, TWeight>
The flow value, per-edge flows, and a minimum cut.
Exceptions
- ArgumentException
Either endpoint is missing, or source equals sink.
- NegativeWeightException
An edge has negative capacity.
FindMaximumFlow(IDirectedGraph<TVertex, TEdge>, TVertex, TVertex, CancellationToken)
Computes the maximum flow, observing cancellationToken
cooperatively. The default implementation forwards to the tokenless
overload and therefore ignores the token — implementations should
override it to honor cancellation.
MaximumFlowResult<TVertex, TEdge, TWeight> FindMaximumFlow(IDirectedGraph<TVertex, TEdge> graph, TVertex source, TVertex sink, CancellationToken cancellationToken)
Parameters
graphIDirectedGraph<TVertex, TEdge>The directed flow network.
sourceTVertexThe vertex the flow originates from.
sinkTVertexThe vertex the flow drains into.
cancellationTokenCancellationTokenCancels the computation cooperatively.
Returns
- MaximumFlowResult<TVertex, TEdge, TWeight>
The flow value, per-edge flows, and a minimum cut.
Exceptions
- OperationCanceledException
The token was cancelled (honored by overriding implementations).