Find if there is a path between two vertices in a directed graphGiven a Directed Graph and two vertices src and dest, check whether there is a path from src to dest.Example: Consider the following Graph: adj[][] = [ [], [0, 2], [0, 3], [], [2] ]Input : src = 1, dest = 3Output: YesExplanation: There is a path from 1 to 3, 1 -> 2 -> 3Input : src = 0, dest =
11 min read
Find all reachable nodes from every node present in a given setGiven an undirected graph and a set of vertices, find all reachable nodes from every vertex present in the given set.Consider below undirected graph with 2 disconnected components.  arr[] = {1 , 2 , 5}Reachable nodes from 1 are 1, 2, 3, 4Reachable nodes from 2 are 1, 2, 3, 4Reachable nodes from 5 ar
12 min read
Print all paths from a given source to a destination using BFSGiven a directed graph, a source vertex âsrcâ and a destination vertex âdstâ, print all paths from given âsrcâ to âdstâ. Please note that in the cases, we have cycles in the graph, we need not to consider paths have cycles as in case of cycles, there can by infinitely many by doing multiple iteratio
9 min read