Skip to content
FutureBlitz

    Install

    Import std.algo.union_find

    std.algo.union_find

    UnionFind: the Ints from 0 to Count - 1 in sets that start one to each and only ever join, for what's connected to what, as Kruskal's spanning tree and a map's regions ask. Each set has a root that Find gives, and a Find halves its path to the root as it goes, while Union hangs the smaller set under the larger, so either takes nearly constant time.

    std/algo/union_find.fb

    Types

    UnionFind class

    Public Class UnionFind

    The Ints from 0 to Count - 1 in sets that only ever join, for what's connected to what.

    std/algo/union_find.fb, line 10

    • @PanicsAtCaller Public New(count: Int) constructor #

      count values, each in a set of its own. A negative count panics.

    • Public Property Count: Int property #

      How many values there are, from 0 to Count - 1.

    • Public Property SetCount: Int property #

      How many sets the values are in.

    • Public Method Add(): Int method #

      Adds a value in a set of its own, and gives it: the Count before.

    • @PanicsAtCaller Public Method Find(value: Int): Int method #

      The root of the value's set, which every value in it has. A value outside 0 to Count - 1 panics.

    • @PanicsAtCaller Public Method Union(a: Int, b: Int): Bool method #

      Joins the two values' sets, and tells whether they were apart. A value outside 0 to Count - 1 panics.

    • @PanicsAtCaller Public Method Connected(a: Int, b: Int): Bool method #

      Whether the two values are in one set. A value outside 0 to Count - 1 panics.

    • @PanicsAtCaller Public Method SizeOf(value: Int): Int method #

      How many values are in the value's set, the value too. A value outside 0 to Count - 1 panics.

    • Public Method Groups(): Int[][] method #

      The sets, each its values from the least up, in the order of their least values.

    Report an issue with this page or with FutureBlitz on GitHub.