-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaxflow.ex
More file actions
29 lines (23 loc) · 722 Bytes
/
maxflow.ex
File metadata and controls
29 lines (23 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
defmodule MaxFlow do
@spec max_flow(graph :: [tuple()], source :: term(), sink :: term(), strategy :: module()) :: integer()
def max_flow(graph, source, sink, strategy) do
strategy.max_flow(graph, source, sink)
end
end
defmodule FordFulkersonStrategy do
@behaviour MaxFlowStrategy
@impl MaxFlowStrategy
def max_flow(graph, source, sink) do
FordFulkerson.max_flow(graph, source, sink)
end
end
defmodule PreflowPushStrategy do
@behaviour MaxFlowStrategy
@impl MaxFlowStrategy
def max_flow(graph, source, sink) do
PreflowPush.max_flow(graph, source, sink)
end
end
defmodule MaxFlowStrategy do
@callback max_flow(graph :: [tuple()], source :: term(), sink :: term()) :: integer()
end