iota-0.1.0.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Graph.MinCostFlow

Synopsis

Documentation

type Cost = Int Source #

minCostFlow Source #

Arguments

:: Int

number of vertices

-> Vertex

source

-> Vertex

sink

-> Capacity

flow

-> (forall s. MinCostFlowBuilder s -> ST s ()) 
-> (Cost, Capacity) 

Primal Dual O(FElog V)

>>> :{
minCostFlow 2 0 1 2 (\builder -> do
    addEdgeMCFB builder 0 1 123 2
    )
:}
(246,2)
>>> :{
minCostFlow 2 0 1 123456789 (\builder -> do
    addEdgeMCFB builder 0 1 123 2
    )
:}
(246,2)

data MinCostFlow s Source #

Constructors

MinCostFlow 

Fields

runMinCostFlow :: PrimMonad m => Vertex -> Vertex -> Capacity -> MinCostFlow (PrimState m) -> m (Cost, Capacity) Source #

encodeMCF :: Cost -> Vertex -> Word64 Source #

cost 48bit / vertex 16bit

dijkstraMCF :: PrimMonad m => Vertex -> Vertex -> MinCostFlow (PrimState m) -> m Bool Source #

updateResidualMCF :: PrimMonad m => Vertex -> Capacity -> MinCostFlow (PrimState m) -> m Capacity Source #

data MinCostFlowBuilder s Source #

Constructors

MinCostFlowBuilder 

Fields

newMinCostFlowBuilder :: PrimMonad m => Int -> m (MinCostFlowBuilder (PrimState m)) Source #

addEdgeMCFB :: PrimMonad m => MinCostFlowBuilder (PrimState m) -> Vertex -> Vertex -> Cost -> Capacity -> m () Source #

cost >= 0

buildMinCostFlow :: PrimMonad m => MinCostFlowBuilder (PrimState m) -> m (MinCostFlow (PrimState m)) Source #