Algorithm
Algorithm
Searching
Searching is a process of finding a particular element among several given
elements.
The search is successful if the required element is found.
Otherwise, the search is unsuccessful.
Linear Search-
We found three spanning trees off one complete graph. A complete undirected
graph can have maximum nn-2 number of spanning trees, where n is the number of
nodes. In the above addressed example, n is 3, hence 33−2 = 3 spanning trees are
possible.
Spanning tree is basically used to find a minimum path to connect all nodes in a
graph. Common application of spanning trees are −
Civil Network Planning
Computer Network Routing Protocol
Cluster Analysis
Minimum Spanning Tree (MST)
In a weighted graph, a minimum spanning tree is a spanning tree that has minimum
weight than all other spanning trees of the same graph.
The minimum spanning tree from the above spanning trees is:
Remove all loops and parallel edges from the given graph. In case of parallel
edges, keep the one which has the least cost associated and remove all others.
Step 2 - Choose any arbitrary node as root node
In this case, we choose S node as the root node of Prim's spanning tree. This node
is arbitrarily chosen, so any node can be the root node.
Step 3 - Check outgoing edges and select the one with less cost
Step-01:
Step-02:
Step-03:
Step-04:
Step-05:
Step-06:
Step-01:
Step-02:
Step-03:
Step-04:
Step-05:
Step-06:
Step-07:
Since all the vertices have been connected / included in the MST, so we stop.
Weight of the MST
= Sum of all edge weights
= 10 + 25 + 22 + 12 + 16 + 14
= 99 units
Using Kruskal’s Algorithm, find the cost of minimum spanning tree (MST) of the given
graph-