UnionFind/Disjoint Set
Title: Union Find Directory: Graph Name: Daniel Yu-cua
Define You:
- [x] Hacktoberfest2022 Participant
- [x] Contributor
Problem
Write to program in Python to implement a Disjoint set also known as Union Find. A disjoint set is a data structure that stores a collection of "disjoint" (non-overlapping) sets. This data structure is useful to determine whether two vertices of a graph belong to the same component, or whether an edge between them would result in a cycle. It is a key component in implementing Kruskal's algorithm to find the minimum spanning tree.
Type of change
What sort of change have you made:
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Code style update (formatting, local variables)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
Input:
UnionFind(5)
union(1,2)
union(4,5)
isConnected(1,2)
isConnected(3,4)
Output:
1 2 3 4 5
1-2 3 4 5
1-2 3 4-5
True
False
@prathimacode-hub Please assign me this issue, I'll be contributing as a Hacktoberfest 2022 participant.
Hello there! ππ» Welcome to the PyAlgo-Tree! πβ‘οΈ Thank you and congrats π for opening your very first issue in this project. Please adhere to our Code of Conduct. ππ» You may submit a PR if you like, make sure to follow our Pull Request Template. Feel free to get in touch with me through social media handles. Hope to see you there!π
Issue assigned to @TheDoctor561