CM::make "graphs.lib";
package test_min_cut {
my G as graph::GRAPH g = digraph_by_adjacency_list::graph("foo", (), 10) : graph::graph( String, Int, Void )
my _ = apply g.add_node
[(0, "s"),
(1, "v1"),
(2, "v2"),
(3, "v3"),
(4, "v4"),
(5, "t")
]
E = [(0, 1, 16),
(0, 2, 13),
(1, 2, 10),
(2, 1, 4),
(1, 3, 12),
(2, 4, 14),
# (3, 2, 9),
(4, 3, 7),
(3, 5, 20),
(4, 5, 4)
]
my _ = apply g.add_edge E
# my _ = apply (\\ (i, j, w) => g.add_edge (j, i, w)) E
package min_cut = stoer_wagners_minimal_undirected_cut_g (pkg type Element = Int
use Int
zero = 0
my ==== : Int * Int -> Bool = op =
end)
fun test () =
let fun weight (_, _, w) = w
my (cut, w) = min_cut::min_cut { graph=G, weight=weight }
in if w != 23 then raise exception MATCH
(cut, w)
end
}