how to print all paths in a directed graph” is famous question asked in programming interview. Given a directed graph write a c program to find all paths between two given nodes of a directed graph. For example what are the paths between vertex 0 to vertex 3.

how to print all paths in a directed graph

The paths from source node or vertex 0 to destination node or vertex 3 are

  1. 0 – 4 – 3
  2. 0 – 2 – 3
  3. 0 – 4 – 2 – 3

Learn how to print all paths in a directed graph step by step

 Represent the above graph as adjacency matrix ( Read more at http://wikistack.com/graph-and-its-representationtutorial/ )

After representing the graph as adjacency matrix we run DFS like recursive function from the source node. Here is c implementation.

Ref:
http://stackoverflow.com/questions/9535819/find-all-paths-between-two-graph-nodes

https://www.quora.com/What-are-good-ways-to-find-all-the-possible-paths-between-two-nodes-in-a-directed-graph