Question: Implement Kruskal's algorithm in python to find a minimum spanning tree. Input and output should be in the form of an adjacency matrix. Example, kruskal(G):
Implement Kruskal's algorithm in python to find a minimum spanning tree. Input and output should be in the form of an adjacency matrix.
Example, kruskal(G):
Input in Matrix representation:
G = [[0, 9, 75, 0, 0],
[9, 0, 95, 19, 42],
[75, 95, 0, 51, 66],
[0, 19, 51, 0, 31],
[0, 42, 66, 31, 0]]
Sample Output in matrix representation:
G = [[0, 9, 0, 0, 0],
[9, 0, 0, 19, 0],
[0, 0, 0, 51, 0],
[0, 19, 51, 0, 31],
[0, 0, 0, 31, 0]]
Step by Step Solution
There are 3 Steps involved in it
def findparent i if parenti i return i return findparent parenti def unionparent rank x y xroot find... View full answer
Get step-by-step solutions from verified subject matter experts
