iota-0.1.0.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Graph.MaxFlow

Synopsis

Documentation

maxFlow Source #

Arguments

:: (Unbox cap, Num cap, Ord cap, Bounded cap) 
=> Int

number of vertices

-> Vertex

source

-> Vertex

sink

-> (forall s. MaxFlowBuilder s cap -> ST s ()) 
-> cap 

Dinic O(V^2E)

>>> :{
maxFlow @Int 5 0 4 $ \builder -> do
    addEdgeMFB builder (0, 1, 10)
    addEdgeMFB builder (0, 2, 2)
    addEdgeMFB builder (1, 2, 6)
    addEdgeMFB builder (1, 3, 6)
    addEdgeMFB builder (3, 2, 2)
    addEdgeMFB builder (2, 4, 5)
    addEdgeMFB builder (3, 4, 8)
:}
11
>>> maxFlow @Int 2 0 1 $ const (return ())
0

data MaxFlow s cap Source #

Constructors

MaxFlow 

Fields

runMaxFlow :: (Unbox cap, Num cap, Ord cap, Bounded cap, PrimMonad m) => Vertex -> Vertex -> MaxFlow (PrimState m) cap -> m cap Source #

bfsMF :: (Num cap, Ord cap, Unbox cap, PrimMonad m) => Vertex -> Vertex -> MaxFlow (PrimState m) cap -> m () Source #

dfsMF :: (Unbox cap, Num cap, Ord cap, Bounded cap, PrimMonad m) => Vertex -> Vertex -> cap -> MaxFlow (PrimState m) cap -> m cap Source #

data MaxFlowBuilder s cap Source #

Constructors

MaxFlowBuilder 

Fields

newMaxFlowBuilder :: (Unbox cap, PrimMonad m) => Int -> m (MaxFlowBuilder (PrimState m) cap) Source #

buildMaxFlow :: (Num cap, Unbox cap, PrimMonad m) => MaxFlowBuilder (PrimState m) cap -> m (MaxFlow (PrimState m) cap) Source #

addEdgeMFB :: (Unbox cap, PrimMonad m) => MaxFlowBuilder (PrimState m) cap -> (Vertex, Vertex, cap) -> m () Source #