SignedUnionFind

org.appliedtopology.tda4j.SignedUnionFind
open class SignedUnionFind[C](size: Int)(using fr: is[C, Field])

Union-find over 0 until size in which every element carries an orientation, a unit of the field C, relative to the root of its component. It is the bookkeeping behind the representatives of the dual union-find engines (FastCubicalHomologyEngine, FastAlphaHomologyEngine): an element is a top cell, a component a region of top cells, and the region's coherently oriented sum is sum of orientation(c) * c over its members.

  • find compresses paths and composes orientations along them, so orientation(i) is amortised near-constant.
  • union(young, old, flip) hangs root young under root old, multiplying the whole young component's orientations by flip (a unit, ±1 in practice). It never touches the members.
  • The merges also form a forest that path compression does not change: members(root) walks the subtree of a root, which is frozen once that root has been merged away, and returns every member with its orientation relative to that root.

A merge therefore costs nearly constant time, and a representative costs time proportional to its region, paid only for the bars that are reported.

Attributes

Experimental
true
Source
SignedUnionFind.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def find(i: Int): Int

The root of i's component. Compresses the path, composing orientations so they stay relative to the root.

The root of i's component. Compresses the path, composing orientations so they stay relative to the root.

Attributes

Source
SignedUnionFind.scala
def members(root: Int): Iterator[(Int, C)]

Every element merged (directly or not) into root, root included, with its orientation relative to root. Exact for a root that is still a root, or was merged away (its subtree no longer changes).

Every element merged (directly or not) into root, root included, with its orientation relative to root. Exact for a root that is still a root, or was merged away (its subtree no longer changes).

Attributes

Source
SignedUnionFind.scala
def orientation(i: Int): C

The orientation of i relative to the root of its component (one for the root itself).

The orientation of i relative to the root of its component (one for the root itself).

Attributes

Source
SignedUnionFind.scala
def union(young: Int, old: Int, flip: C): Unit

Merges root young into root old, multiplying every orientation in young's component by flip.

Merges root young into root old, multiplying every orientation in young's component by flip.

Attributes

Source
SignedUnionFind.scala