Kruskal Algorithm

Sanskar Paul
3 min readApr 9, 2022

--

What is Kruskal algorithm?

The Kruskal algorithm is used to find the minimum tree divider with the weight of the connected graph. The main goal of the algorithm is to find a small set of edges through which we can cross the entire vertex of the graph. It follows a selfish approach that finds the best solution at all levels instead of focusing on the positive in a global way.

How does kruskal algorithm works?

In the Kruskal algorithm, we start at the edges with the lowest weight and continue to add edges until the goal is achieved. The steps for using the Kruskal algorithm are as follows -

First, trim all the edges from the bottom to the top.
Now, take a very lightweight edge and add it to the stretchable tree. If the edge to be added creates a circle, then reject the edge.
Continue to add edges until it reaches all the vertices, and a small stretchable tree is formed.
The uses of the Kruskal algorithm are -

The Kruskal algorithm can be used to arrange power lines between cities.
It can be used to set down LAN connections.

The following code is implemented with a disjoint-set data structure. Here, we represent our forest F as a set of edges, and use the disjoint-set data structure to efficiently determine whether two vertices are part of the same tree.

Pseudo code of Kruskal Algorithm

The subsequent code is integrated with a disjoint-set data structure. Below, we represent each of our forest F while a pair of corners, and utilize disjoint-set data structure to be able to proficiently evaluate in the event that two vertices will be part of typically the same tree.
criteria Kruskal(G) is definitely
N: = ∅
intended for each v ∈ G. V carry out
MAKE-SET(v)
for every single (u, v) throughout G. E bought by weight(u, v), increasing do
in the event that FIND-SET(u) ≠ FIND-SET(v) next
F: sama dengan F ∪ ∪
UNION(FIND-SET(u), FIND-SET(v))
returning F

Example of Kruskal’s algorithm

Solution for this example is:

Complexity of Kruskal’s algorithm

Today, let’s see the particular time complexity regarding Kruskal’s algorithm.
Period Intricacy
The period complexity of Kruskal’s algorithm is O(E logE) or O(V logV), where At the is the amount of edges, in addition to V is the particular number of vertices.

Applications where Kruskal’s algorithm is typically used:
one Obtaining cables
2 . not TV SET Network
3. Visit Operations
4. LOCAL AREA NETWORK Networks
5. A new network of water lines for liquids or perhaps natural gas.
6th. An electric main grid
7. Single-link Group
Which can be false concerning Kruskal algorithm?
Kruskal’s algorithm is some sort of greedy algorithm to be able to construct the mst of the granted graph. it constructs the mst by simply selecting edges throughout increasing order involving their weights together with rejects an border whether it may variety the cycle. consequently, using kruskal’s modus operandi is never made.

--

--

Sanskar Paul
Sanskar Paul

No responses yet