Allocation-free UnionFind library for bare metal environments
The library provides the following algorithms that is used with UnionFind
.
- QuickFind
- QuickUnion
- Weighted QuickUnion
- Weighted QuickUnion With Path Compression (Default)
| Algorithm | Struct | Init | Union | Find | Connected |
| :----------------------------------------------- | :-----------------------------: | :----: | ------------------: | ------------------: | ------------------: |
| QuickFind | QuickFind
| O(N)
| O(N)
| O(1)
| O(1)
|
| QuickUnion | QuickUnion<UnWeighted, false>
| O(N)
| O(N)
| O(N)
| O(N)
|
| Weighted (Rank) QuickUnion With Path Compression | QuickUnion<ByRank, true>
| O(N)
| Amortized O(α(N))
| Amortized O(α(N))
| Amortized O(α(N))
|
| Weighted (Size) QuickUnion With Path Compression | QuickUnion<BySize, true>
| O(N)
| Amortized O(α(N))
| Amortized O(α(N))
| Amortized O(α(N))
|
*Where α
is the inverse Ackermann function
```rust
use pulaurs::{UnionFind, QuickFind, QuickUnion, BySize};
fn makeuf_quickfind() {
// construct with quickfind algorithm with fixed size 10
let mut uf = UnionFind::
fn makeufquickunion() {
// construct weighted quickunion with path compression algorithm with fixed size 10
let mut uf = UnionFind::
pulau-rs is licensed under MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)