NgLib::MSTGraph(T)
Inherits Reference < Object
$n$ 頂点の重み付きグラフについて、最小/最大全域木を構築します。
Kruskal 法による実装です。
Constructors
new(n)
Sourcenew(n, &cmp : T, T -> Int32)
SourceClass methods
Instance methods
グラフに辺 $(u, v, w)$ を追加します。
graph = MSTGraph(Int64).new(n) { |a, b| a < b }
m.times { graph.add_edge(u, v, w) }
size
Sourcesum
最小全域木を構成したときの辺の重みの総和求めます。
graph = MSTGraph(Int64).new(n) { |a, b| a < b }
m.times { graph.add_edge(u, v, w) }
graph.sum