
@Reference(authors="R. Sedgewick", title="1.3 Union-Find Algorithms", booktitle="Algorithms in C, Parts 1-4") public class WeightedQuickUnionInteger extends Object
R. Sedgewick
1.3 Union-Find Algorithms
Algorithms in C, Parts 1-4
| Modifier and Type | Field and Description |
|---|---|
private static int |
INITIAL_SIZE
Initial size.
|
private int[] |
parent
Parent element
|
private int |
used
Number of used indexes.
|
private int[] |
weight
Weight, for optimization.
|
| Constructor and Description |
|---|
WeightedQuickUnionInteger()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
find(int cur)
Find the parent of an object.
|
TIntList |
getRoots()
Collect all component root elements.
|
boolean |
isConnected(int first,
int second)
Test if two components are connected.
|
int |
nextIndex(int weight)
Occupy the next unused index.
|
int |
size()
Number of allocated indexes.
|
int |
union(int first,
int second)
Join the components of elements p and q.
|
private int used
private int[] parent
private int[] weight
private static final int INITIAL_SIZE
public int nextIndex(int weight)
weight - Initial weight.public int find(int cur)
cur - Current entrypublic int union(int first,
int second)
first - First elementsecond - Second elementpublic boolean isConnected(int first,
int second)
first - First elementsecond - Second elementtrue if they are in the same component.public TIntList getRoots()
public int size()
Copyright © 2015 ELKI Development Team, Lehr- und Forschungseinheit für Datenbanksysteme, Ludwig-Maximilians-Universität München. License information.