python implementation code fragment presents python implementation of kruskal' algorithm as with our implementation of the prim-jarnik algorithmthe minimum spanning tree is returned in the form of list of edges as consequence of kruskal' algorithmthose edges will be reported in nondecreasing order of their weights our implementation assumes use of partition class for managing the cluster partition an implementation of the partition class is presented in section def mst kruskal( ) """compute minimum spanning tree of graph using kruskal algorithm return list of edges that comprise the mst the elements of the graph edges are assumed to be weights "" tree list of edges in spanning tree pq heappriorityqueueentries are edges in gwith weights as key forest partitionkeeps track of forest clusters position map each node to its partition entry for in vertices) position[vforest make group( for in edges) pq add( element)eedge' element is assumed to be its weight size vertex count while len(tree!size and not pq is empty) tree not spanning and unprocessed edges remain weight,edge pq remove min , edge endpoints forest find(position[ ] forest find(position[ ] if ! tree append(edge forest union( , return tree code fragment python implementation of kruskal' algorithm for the minimum spanning tree problem