Skip to content

Latest commit

 

History

History
118 lines (60 loc) · 1.6 KB

QuickUnion.md

File metadata and controls

118 lines (60 loc) · 1.6 KB

UnionFind.QuickUnion

connected(valueA, valueB)

Are the 2 verticies connected?

Arguments

  1. valueA (*): the first vertex to compare
  2. valueB (*): the second vertex to compare

Returns

(boolean): true if the verticies are connected, false if not


constructor([values])

Arguments

  1. [values] (*[]): an array of verticies to add to the set

count

(Number): The number of sets


find(value)

Find the id for a value

Arguments

  1. value (*): the value to lookup

Returns

(*): the identity of the set containing the item


sets()

Returns a 2D array of the unique sets and the values in those sets

Returns

(*): [][] a 2D array containing the disjoint sets


union(valueA, valueB)

Join the verticies if not alredy in the same set

Arguments

  1. valueA (*): the first vertex to connect
  2. valueB (*): the second vertex to connect