com.mxgraph.analysis.mxUnionFind Maven / Gradle / Ivy
/**
* Copyright (c) 2007, Gaudenz Alder
*/
package com.mxgraph.analysis;
import java.util.Hashtable;
import java.util.Map;
/**
* Implements a union find structure that uses union by rank and path
* compression. The union by rank guarantees worst case find time of O(log N),
* while Tarjan shows that in combination with path compression (halving) the
* average time for an arbitrary sequence of m >= n operations is
* O(m*alpha(m,n)), where alpha is the inverse of the Ackermann function,
* defined as follows:
* alpha(m,n) = min{i >= 1 | A(i, floor(m/n)) > log n} for m >= n >= 1
* Which yields almost constant time for each individual operation.
*/
public class mxUnionFind
{
/**
* Maps from elements to nodes
*/
protected Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy