Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samuelschlesinger/union-find
https://github.com/samuelschlesinger/union-find
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/samuelschlesinger/union-find
- Owner: SamuelSchlesinger
- Created: 2022-03-22T20:57:50.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-22T23:52:51.000Z (almost 3 years ago)
- Last Synced: 2024-10-27T19:10:35.101Z (2 months ago)
- Language: Rust
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Union Find
`union-find` is an implementation of the [disjoint-set
data structure](https://en.wikipedia.org/wiki/Disjoint-set_data_structure)
of the same name.The interface to this data structure is composed of two functions. `UnionFind::find`
allows you to compute a canonical representative for a set, given an element
of it. `UnionFind::union` allows you to combine two sets, given an arbitrary representative
from each. In the future, if you were to `UnionFind::find` a canonical representative
from any member of either set, you will find them equal, indicating they are in
the same set according to the data structure.The interface can be used like this:
```rust
let mut uf = UnionFind::new(10);assert_eq!(uf.find(0).unwrap(), 0);
assert_eq!(uf.find(0).unwrap(), uf.find(1).unwrap());
```