Book
Advanced Engineering Mathematics
Author
Erwin Kreyszig
Edition
8th Edition
M = Graph({1:{2:' 5 ',3:' 3 ',4:' 6 '}, 2:{3:' 1 ',4:' 4 ',5:' 2 '}, 4:{5:' 5 '}})
M.plot(edge_labels=True).show()
weight = lambda e: 1/( (e[0]+1)*(e[1]+1) )
lst=M.min_spanning_tree(algorithm='Kruskal',weight_function=weight,starting_vertex=1)
l=range(1,7)
def adj(x):
l1={}
for i in lst:
if i[0]==x:
l1[i[1]]=i[2]
elif i[1]==x:
l1[i[0]]=i[2]
return l1
adj(1)
grp={}
for i in l:
grp[i]=adj(i)
G=Graph(grp)
G.plot(edge_labels=True).show()
Solution by:
<K.Swetha>, <Student>, <Snist>
<Your Name>, <Profession>, <Organization>
