Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FEATURE REQUEST] Add Implementation of Kruskal's Algorithm with Union-Find Optimization #7125

Open
@RamsaiPolisetti

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:

  1. Sorting all edges by weight
  2. Selecting edges in increasing order
  3. Using Union–Find to avoid cycles
  4. 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 Edge class 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /