Welcome Back Readers!
We hope that you understood the last problem which was Has Path. Moving further, in this article we will discuss about the next problem based on the Graph i.e.Find all Paths in a Graph.
Prerequisite for this problem is the previous problem of this module; Has Path. In case you have not gone through that problem, I suggest that you solve and understand that first.
So, talking of Find all Paths, we get a hint from its name that we need to find all possible paths between 2 given vertices of the graph.
How is it different from the Has Path problem?
In Has Path, we just check whether there exists a path between two given vertices, but in this problem we need to find and print all possible paths between two given vertices.
Before you move any further, it is advised that you give this problem a fair try.
let's jump to the problem.
Understanding the problem:
In this problem you are given a graph, a source vertex and a destination vertex.
All you have to do is find and print all paths between source and destination. Print them in lexicographical order. >
Input is managed for you.
Study the example below for better understanding.
In the above example, for the given graph, source being 0 and destination being 6, there are 4 possible paths.