Skip to content

Given a disjoint set data structure, I use two strategies - union by rank and path compression - to find the connected components of the structure's graph.

Notifications You must be signed in to change notification settings

vmthanh-bi/Union-by-rank-Path-compression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Union by rank & Path compression

Given a disjoint set data structure, I use two strategies - union by rank and path compression - to find the connected components of the structure's graph.

Table of Contents
  1. About The Project
  2. Getting Started
  3. Help
  4. Contact

About the project

A graph is a data structure composed of vertices connected by edges.

A graph can consist of one or more connected components: these are sets of vertices that are connected by edges. The picture above shows a graph with three connected components.

Here is an algorithm to find all of the connected components in a graph:

  1. Make a set for each vertex in the graph, with the label of that vertex being the sole element of the set.
  2. For each edge in the set:
    • Check to see if the vertices at either end of the edge lie in different sets.
    • If they do, replace the two separate sets with a single set that is the union of the two separate sets.
  3. Once all of the edges has been processed, output the list of sets that remain. These are the connected components of the graph.

Here is a picture that illustrates how this algorithm works.

The objective of this program is to use the methods, union by rank and path compression, to create an algorithm that can efficiently connect components of such a graph.

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

Things you need to use the software.

  • MacOS
  • Xcode

Installation

Clone this repo.

git clone https://github.com/vmthanh-bi/Union-by-rank-Path-compression.git

Help

See the open issues for a list of proposed features (and known issues).

Contact

Tony Vu - @vmthanh.bi - vmthanh.bi@gmail.com

Project Link: https://github.com/vmthanh-bi/Union-by-rank-Path-compression

About

Given a disjoint set data structure, I use two strategies - union by rank and path compression - to find the connected components of the structure's graph.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages