Open In App

Difference between Minimum Spanning Tree and Shortest Path

Spanning tree: A spanning tree (T) of an undirected graph(G) is a subgraph which is a tree that includes all the vertices of a graph (G) and the minimum number of edges required to connect the graph (G). And it is a known maximal set of edges with no cycles.

Properties:



Possible spanning trees in K3 graph

The Shortest path:

Shortest path(A, B, D, E) between vertices A and E in the weighted directed graph

The followings are the difference between the Minimum spanning tree(MST) and the Shortest path:



Minimum spanning tree(MST) The Shortest path
In MST there is no source and no destination, but it is the subset (tree) of the graph(G) which connects all the vertices of the graph G without any cycles and the minimum possible total edge weight. There is a source and destination, and one need to find out the shortest path between them
Graph (G) should be connected, undirected, edge-weighted, labeled. It is not necessary for the Graph (G) to be connected, undirected, edge-weighted, labeled.

Here relaxation of edges is not performed but here the minimum edge weight is chosen one by one from the set of all edge weights (sorted according to min weight) and the tree is formed by them (i.e. there should not be any cycle).

Here the relaxation of edges is performed.

  • Here d(U) means the distance of source vertex S to vertex where C(U, V) is the distance between U and V.
  • If d(U) > d(V) + C(U, V) then d(U) = d(V) + C(U, V).
  • For example, 20>10+5, d(U) = 15, is the minimum distance from source vertex S to vertex U.
  • Therefore, relaxation is performed.
In this case, a minimum spanning tree can be formed but negative weights edge cycles are not generally used. Using the cycle property of MST, the minimum edge weight among all the edge weights in the negative edge cycle can be selected. If the graph is connected, and if a negative weight edge cycle present in the graph. Then the shortest path can not be computed, but the negative edge cycle can be detected using the Bellman-Ford algorithm.
In the case of a disconnected graph, the minimum spanning tree can not be formed but many spanning-tree forests can be formed. In the case of a disconnected graph, the distance between two vertices present in two different components is infinity.

Here the Greedy approach is used for finding MST for a graph, For example, Prim’s algorithm and Kruskal’s algorithm.

If there are N vertices are present inside graph G then the minimum spanning tree of the graph will contain N-1 edges and N vertices. If there are N vertices present inside graph G, then in the shortest path between two vertices there can be at most N-1 edges, and at most N vertices can be present in the shortest path.
It is used in network design (computer networks, telecommunication networks, water supply networks) and in circuit design applications, and many more. It is used to find out direction between physical locations like in Google Maps.
Article Tags :