**Pre-requisites:**

- Graph and its representations
- Greedy Algorithms | Set 5 (Prim’s Minimum Spanning Tree (MST))
- Kruskal’s Minimum Spanning Tree Algorithm | Greedy Algo-2

Given a directed graph **D = < V, E >**, the task is to find the minimum spanning tree for the given directed graph

But the Prim’s Minimum Spanning Tree and Kruskal’s algorithm fails for directed graphs. Let us see why

**Why Prim’s Algorithm Fails for Directed Graph ?**

Prim’s algorithm assumes that all vertices are connected. But in a directed graph, every node is not reachable from every other node. So, Prim’s algorithm fails due to this reason.

**For Example:**

As it is visible in the graph, no node is reachable from node 4. Directed graphs fail the requirement that all vertices are connected.

**Why Kruskal’s Algorithm fails for directed graph ?**

In Kruskal’s algorithm, In each step, it is checked that if the edges form a cycle with the spanning-tree formed so far. But Kruskal’s algorithm fails to detect the cycles in a directed graph as there are cases when there is no cycle between the vertices but Kruskal’s Algorithm assumes it to cycle and don’t take consider some edges due to which Kruskal’s Algorithm fails for directed graph.

**For example:**

This graph will be reported to contain a cycle with the Union-Find method, but this graph has no cycle.

The equivalent of minimum spanning tree in directed graphs is, “Minimum Spanning Arborescence”(also known as optimum branching) can be solved by Edmonds’ algorithm with a running time of O(EV). This algorithm is directed analog of the minimum spanning tree problem.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Difference between Prim's and Kruskal's algorithm for MST
- Find weight of MST in a complete graph with edge-weights either 0 or 1
- Hierholzer's Algorithm for directed graph
- Shortest path in a directed graph by Dijkstra’s algorithm
- Convert the undirected graph into directed graph such that there is no path of length greater than 1
- Convert undirected connected graph to strongly connected directed graph
- Prim’s Minimum Spanning Tree (MST) | Greedy Algo-5
- Prim’s MST for Adjacency List Representation | Greedy Algo-6
- Travelling Salesman Problem | Set 2 (Approximate using MST)
- Shortest path with exactly k edges in a directed and weighted graph
- Number of shortest paths in an unweighted and directed graph
- Shortest path with exactly k edges in a directed and weighted graph | Set 2
- Minimum Cost of Simple Path between two nodes in a Directed and Weighted Graph
- Find if there is a path between two vertices in a directed graph
- Detect Cycle in a Directed Graph
- Shortest Path in Directed Acyclic Graph
- Longest Path in a Directed Acyclic Graph
- Euler Circuit in a Directed Graph
- Assign directions to edges so that the directed graph remains acyclic
- Detect Cycle in a directed graph using colors

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.