joshita / dev

Published

- 1 min read

Breath first search algorithm to list all paths from source to destination

img of Breath first search algorithm to list all paths from source to destination

Given a graph find paths print all paths from source to destination using breath first traversal

Breath first search alogrithm is used for traversing the graph, its is a also known as level order traversal because it finishes one level if nodes and then moves on to the second level of nodes Most advantageous use of breath first search algorithm is to efficiently find the shortest path b/w two vertices.

In Graph theory, the primary use cases of the “breadth-first search” (“BFS”) algorithm are: Traversing all vertices in the “graph”;

   graph TD;
	0-->1;
	0-->2;
    1-->3;
	2-->3;
	3-->;

The snippet shows backtracking traversal of all paths from source to destination

TotalValue TotalValue