On finding and updating spanning trees and shortest paths dating service and utah

PRIM'S MINIMUM SPANNING TREE ALGORITHM Kruskal's minimum spanning tree algorithm built the final tree by adding edges (in increasing order of weights) to a growing forest of trees, until one finally arrives at a spanning tree when the (n-1)st edge is added.If the graph G has m edges, and we sort the edges in increasing order, then Kruskal's algorithm has complexity O(mlog m), since we can sort the edges using an optimal algorithm such as Mergesort having O(mlog m) complexity, and we can check for cycles with complexity O(mlog m) if we use the union and find algorithms discussed earlier.Some improvement on average results by using a (min) heap to store the edges (since the tree might be constructed long before all the m edges are considered), but the worst case remains mlog m.PRIM'S ALGORITHM FOR A MINIMUM COST SPANNING TREE We now consider another greedy algorithm for constructing a minimum cost spanning tree due to Prim.Prim's algorithm grows a spanning tree starting from a given root vertex r (any vertex will do), and adds edges in such a way as to maintain a growing tree at each stage (as opposed to a forest as grown by Kruskal's algorithm).In order to give a high-level description of Prim's algorithm, we need to define Cut(T) where T is any tree in G.Cut(T) is the collection of all edges in G which have exactly one endpoint in T.

The proof is fairly typical of proofs involving the greedy stategy.

We assume that the spanning tree grown by Kruskal's algorithm does not have minimum cost, and then we reach a contradiction.

Proof of Kruskal's algorithm Let K be the tree grown by Kruskal's algorithm, and suppose there are spanning trees having smaller cost than K.

Let e'), so that the cost of T' is no more than the cost of T (since we have replaced an edge of T with an edge of no more cost).

Hence, the cost of T' is also less than the cost of K.

Search for on finding and updating spanning trees and shortest paths:

on finding and updating spanning trees and shortest paths-4

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “on finding and updating spanning trees and shortest paths”