Kruskal's Algorithm
Kruskal's Algorithm
Group 4
Ron Andrei Fontanilla
Searching Algorithm:
Kehn Adolf Valle
Marvin Jose Hibid
Emelito Lavapie
Table of contents:
Greedy Algorithm
Efficiency: Greedy algorithms often have low time complexity and can run efficiently even for
large input sizes. The greedy approach typically involves making local optimal choices, which
can lead to faster execution times compared to exhaustive search or dynamic programming
techniques.
Memory efficiency: Greedy algorithms often require minimal memory usage. They usually
don't need to store the entire problem space or maintain an extensive set of intermediate
solutions. Instead, they only need to store the current best solution and update it as they
progress.
Disadvantages:
Lack of global optimization: Greedy algorithms make locally optimal choices at each step
without considering the overall solution. As a result, they may not always lead to the globally
optimal solution. The greedy approach may overlook future consequences and make choices
that seem optimal at the moment but turn out to be suboptimal in the long run.
Kruskal
Prim
Prim - It starts to build the Minimum Spanning Tree from any vertex in the graph and
traverses one node more than one time to get the minimum distance.
Kruskal - It starts to build the Minimum Spanning Tree from the vertex carrying minimum
weight in the graph and traverses one node only once.
Prim
Kruskal
Creating a Minimum Spanning Tree
Using Kruskal’s Algorithm
You will first look into the steps involved in Kruskal’s Algorithm to generate a minimum spanning
tree:
Step 3: Check if the new edge creates a cycle or loop in a spanning tree.
Step 4: If it doesn’t form the cycle, then include that edge in MST. Otherwise, discard it.
Using the steps mentioned above, you will generate a minimum spanning tree structure. So,
now have a look at an example to understand this process better.
The Graph
The graph G(V, E) given below contains 6 vertices and 12 edges. And
you will create a minimum spanning tree T(V’, E’) for G(V, E) such that
the number of vertices in T will be 6 and edges will be 5 (6-1)
Removing Elements from the Graph
If you observe this graph, you’ll find two looping edges connecting the same
node to itself again. And you know that the tree structure can never include a
loop or parallel edge. Hence, primarily you will need to remove these edges
from the graph structure.
Creating a Sorted list - Step 1
Source Vertex & Graph Edges Edge Weight & Destination Vertex
E F2
F D2
B C3
C F3
C D4
B F5
B D6
A B7
A C8
The next step that you will proceed with is arranging all edges in a sorted list by their edge weights.
After this step, you will include edges in the MST such that the included edge would not form a cycle in your
tree structure.
Picking the Smallest Edge - Step 2
The first edge that you will pick is edge EF, as it has a
minimum edge weight that is 2.
Continuation - Step 2
Thank You