Why Prim’s and Kruskal’s MST algorithm fails for Directed Graph?


Prim's method and Kruskal's algorithm are two common approaches for locating MSTs in undirected graphs. However, these techniques cannot generate correct MSTs for directed graphs. This is due to the fact that directed graphs are not well−suited to the underlying assumptions and methods used by Prim's and Kruskal's algorithms.

Prim’s Algorithm

First, there's Prim's Algorithm, which involves adding edges to an expanding MST in a greedy fashion until all vertices are covered. A vertex inside the MST is linked to a vertex outside the MST through the edge with the lowest weight. Since all edges in an undirected graph can go in either direction, finding the shortest path from the MST to an external vertex is a breeze. Nonetheless, in a directed graph, edges always point in one direction, and there might not be a straight line connecting the MST to an external vertex. This contradicts the tenets upon which Prim's algorithm is based.

An example of this is a directed edge (u,v) that connects vertex u in the MST to vertex v in the graph outside the MST. Due to the fact that the MST in Prim's method must be connected to an external vertex by a direct edge, the edge (u, v) is ignored, leading to a potentially inaccurate or insufficient MST.

Kruskal’s Method

Kruskal's method is a weighted−edge−sorting technique that repeatedly adds the smallest−weight edges that do not generate cycles to the graph. The approach works best with undirected graphs, because cycles may be easily detected since edges point in both directions. Because the direction of the edges matters in a directed graph, the idea of cycles becomes more nuanced. This complexity is ignored by Kruskal's method.

Imagine that the MST you're building has a directed cycle in it. When applied to a directed graph, Kruskal's technique may produce trees that contain directed cycles. The approach produces an inaccurate MST because its cycle detection mechanism, which is based on undirected edges, fails to properly capture the cycles in a directed graph.

Conclusion

It may be concluded that while Prim's and Kruskal's techniques are useful for locating MSTs in undirected graphs, they are not appropriate for directed graphs. These methods produce inaccurate or insufficient MSTs because the underlying assumptions and mechanisms they rely on do not hold in the setting of directed graphs. Directed graphs have their own unique properties and complexity, hence it is important to employ directed graph−specific techniques like the Chu−Liu/Edmonds' approach to obtain a minimal spanning tree.

Updated on: 14-Jul-2023

204 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements