0% found this document useful (0 votes)
15 views

Design Analysis Algorithm 5

The document discusses minimum spanning trees and Prim's algorithm. It defines a minimum spanning tree as a spanning tree with the minimum possible total edge weight. It provides an example graph and its minimum spanning tree. Prim's algorithm is then introduced as a greedy algorithm used to find the minimum spanning tree of a weighted, connected, undirected graph. The steps of Prim's algorithm are outlined.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Design Analysis Algorithm 5

The document discusses minimum spanning trees and Prim's algorithm. It defines a minimum spanning tree as a spanning tree with the minimum possible total edge weight. It provides an example graph and its minimum spanning tree. Prim's algorithm is then introduced as a greedy algorithm used to find the minimum spanning tree of a weighted, connected, undirected graph. The steps of Prim's algorithm are outlined.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Some of the possible spanning trees that can be created from the above graph are:

Minimum Spanning Tree


A minimum spanning tree is a spanning tree in which the sum of the weight of the edges is as
minimum as possible.

Example of a Spanning Tree


Let's understand the above definition with the help of the example below.
The initial graph is:

Weighted graph
The possible spanning trees from the above graph are:
The minimum spanning tree from the above spanning trees is:

Minimum spanning tree

The minimum spanning tree from a graph is found using the following algorithms:
1. Prim's Algorithm
2. Kruskal's Algorithm

Spanning Tree Applications


• Computer Network Routing Protocol
• Cluster Analysis
• Civil Network Planning

Minimum Spanning tree Applications


• To find paths in the map
• To design networks like telecommunication networks, water supply networks, and
electrical grids.

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

Prim’s Algorithm Implementation


Step-01:
• Randomly choose any vertex having least weight.
Step-02:
• Find all the edges that connect the tree to new vertices.
• Find the least weight edge among those edges and include it in the existing tree.
• If including that edge creates a cycle, then reject that edge and look for the next least
weight edge.
Step-03:
• Keep repeating step-02 until all the vertices are included and Minimum Spanning Tree
(MST) is obtained.

Prim’s Algorithm Time Complexity-


Worst case time complexity of Prim’s Algorithm is-
• O(ElogV) using binary heap
• O(E + VlogV) using Fibonacci heap

You might also like