Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@manubb/union-find
Advanced tools
A JS implementation of disjoint-set data structure for node and browsers.
The library is available as a npm package:
npm install @manubb/union-find
Examples directory contains implementations of:
Examples can be run with:
npm run example:components
npm run example:hk
npm run example:kruskal
The library uses trees to encode sets. It exposes three functions.
makeSet();
returns an object representing a set containing one element. It has two properties: parent
and rank
. You can then safely add other properties that suit to your needs.
Note that you can also use your own custom function that should return an object obj
with:
obj.rank === 0
obj.parent === obj
At any time, you can check if obj
is the root of a tree with:
obj.parent === obj
find(obj)
returns the root of the tree that contains obj
. Checking if two objects belong to the same set can be done with:
find(obj1) === find(obj2)
union(obj1, obj2)
merges the sets containing obj1
and obj2
and returns undefined
.
makeSet
run in constant time. If n
is the total number of elements, find
and union
run in amortized time O(α(n))
where α is the inverse Ackermann function. It is a very slowly increasing function: α(10^35164)=5
. For all practical purposes, one can consider that find
and union
run in constant amortized time.
import { makeSet, find, union } from '@manubb/union-find';
or
const { makeSet, find, union } = require('@manubb/union-find');
FAQs
a disjoint-set data structure
The npm package @manubb/union-find receives a total of 1 weekly downloads. As such, @manubb/union-find popularity was classified as not popular.
We found that @manubb/union-find demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.