Debian Codegraph @

lib/mlrisc-lib/MLRISC/graphs/test1.sml

raw
1 CM.make "../cm/Graphs.cm";
2 structure TestMaxFlow =
3 struct
4 val G as Graph.GRAPH g = DirectedGraph.graph("foo",(),10) :
5 (string,int,unit) Graph.graph
6 structure MaxFlow = MaxFlow(struct type elem = int open Int
7 val zero = 0
8 val == : int * int -> bool = op =
9 end)
10 val _ = app (#add_node g)
11 [(0,"s"),
12 (1,"v1"),
13 (2,"v2"),
14 (3,"v3"),
15 (4,"v4"),
16 (5,"t")
17 ]
18 val _ = app (#add_edge g)
19 [(0,1,16),
20 (0,2,13),
21 (1,2,10),
22 (2,1,4),
23 (1,3,12),
24 (2,4,14),
25 (3,2,9),
26 (4,3,7),
27 (3,5,20),
28 (4,5,4)
29 ]
30 fun flows((i,j,c),f) =
31 print(Int.toString i ^ " -> " ^ Int.toString j ^ " flow="^Int.toString f^
32 " cap="^Int.toString c^"\n")
33 fun cap(i,j,c) = c
34
35 fun test() =
36 let val flow = MaxFlow.max_flow{graph=G,s=0,t=5,capacity=cap,flows=flows}
37 in if flow <> 23 then raise Match else flow
38 end
39
40 end