Implement Kruskal's algorithm in python to find a minimum spanning tree. Input and output should be in
Fantastic news! We've Found the answer you've been seeking!
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):
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]]
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date: