Kruskal'S Algorithm: Name: Alina Basharat ROLL NO: 1921110004

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

KRUSKAL’S ALGORITHM

NAME: ALINA BASHARAT


ROLL NO: 1921110004
SPANNING TREES:

Definition:
A spanning tree is a subset of graph G, which has all the vertices covered
with minimum possible number of edges. Hence, a spanning tree does not
have cycles and it can not be disconnected.
Spanning tree:
• Example:
A
Graph G

C B

Spanning trees

A A A

C B C B C B
Spanning tree:
Properties of spanning tree:
• A connected graph G can have more than one spanning trees.
• All possible spanning trees of graph G, have same number of edges and vertices.
• Spanning tree does not have any cycle loops.
• Removing one edge from spanning tree will make the graph disconnected i.e .
spanning tree is minimally connected.
• Adding one edge to a spanning tree will create a circuit or loop i.e. spanning tree is
maximally acyclic.
KRUSKAL’S ALGORITHM:

DEFINITION:
• Kruskal’s algorithm is a famous greedy algorithm.
• It is used for finding the Minimum Spanning Tree(MST) of a given graph.
• To apply Kruskal’s algorithm, the given graph must be weighted,
connected and undirected.
KRUSKAL’S ALGORITHM:

Implementation:
The implementation of Kruskal’s Algorithm is explained in the following
steps:
Step 1:
• Sort all the edges from low weight to high weight.
KRUSKAL’S ALGORITHM:
Step 2:
• Take the edge with the lowest weight and use it to connect the vertices of
graph.
• If adding an edge creates a cycle, then reject that edge and go for the next
least weight edge.
KRUSKAL’S ALGORITHM:

Step 3:
• Keep adding edges until all the vertices are connected and a Minimum
Spanning Tree (MST) is obtained.
THANKX

You might also like