Explore
ProGrad Programs
Placement Prep
TCS Codevita
Live Placement Training
Live Aptitude Training
Live Programming Training
Webinars
About Us

Edit
Reply




Edit

Program to trace all the paths of a directed graph from source to destination

Published on 11 Mar 2020

Program to trace all the paths of a directed graph from the given source node to the destination node is discussed here. Given the adjacency representation of a directed graph, find all the paths of the graph from source to destination.

paths of a directed graph from source to destination

Algorithm to trace all the paths of a directed graph from source to destination


  • Input the adjacency list representation of the directed graph.
  • Start the traversal from the given source node.
  • Store the visited vertices in a temporary array and mark the vertices 'visited'.
  • On reaching the destination vertex, print the temporary array.


Program to trace all the paths of a directed graph from source to destination


C++

Output
Input - Enter the connections of nodes in the graph 0 1 y 0 2 y 0 3 y 2 0 y 2 1 y 1 3 n Enter the source node : 0 Enter the destination node : 3 Output - Different paths from 0 to 3 0 1 3 0 2 1 3 0 3


Recommended Programs





If you have any feedback about this article and want to improve this, please write to enquiry@faceprep.in
Explore 'c plus plus'
Articles Practice Exercises