Book
Advanced Engineering Mathematics
Author
Erwin Kreyszig
Edition
8th Edition
M = Graph({1:{2:' 6 ',3:' 1 ',5:' 15 '}, 2:{3:' 3 ',4:' 14 ',5:' 9 '}, 3:{4: '14'},4:{5:' 2 '}}) M.plot(edge_labels=True).show() weight = lambda e: 1/( (e[0]+1)*(e[1]+1) ) lst=M.min_spanning_tree(algorithm='Prim edge',weight_function=weight,starting_vertex=1) l=range(1,6) 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 grp={} for i in l: grp[i]=adj(i) T=Graph(grp) T.plot(edge_labels=True)
Solution by:
<Archana>, <Student>, <SNIST>