-
Notifications
You must be signed in to change notification settings - Fork 20.8k
Open
Labels
Description
What would you like to Propose?
I propose adding a clean and optimized implementation of Kruskal’s Minimum Spanning Tree (MST) algorithm using Union–Find (Disjoint Set Union - DSU) data structure to the Graphs section of the repository.
Although MST algorithms like Prim’s exist, Kruskal’s Algorithm is missing in the main repo and will enhance the completeness of graph algorithms.
Issue details
Algorithm Name:
Kruskal’s Algorithm (Minimum Spanning Tree)
Problem Statement:
Given a connected, undirected, weighted graph, Kruskal’s Algorithm finds the Minimum Spanning Tree (MST) by:
- Sorting all edges by weight
- Selecting edges in increasing order
- Using Union–Find to avoid cycles
- Stopping when (V – 1) edges are selected
Proposal:
- Implement Kruskal's Algorithm using an efficient Union-Find (DSU) structure with:
- Path Compression
- Union by Rank/Size
- Add a separate
Edgeclass for clean structure. - Provide a well-documented implementation under:
Additional Information
- I can contribute the implementation and corresponding test cases.
- Code will follow repository conventions:
- Proper package structure
- Clear comments and JavaDocs
- JUnit 5 test coverage
- A sample input-output example will be included in tests.