Print all paths from a given source to a destination using BFS

Print all paths from a given source to a destination using BFS


I was trying to understand how to print all possible path using BFS or dfs. For this I used this link code src to des path using BFS geekforgeeks
But i cant understand this code as I dont know about vector a lot. I want to rewrite this code into without using any library like queue or vector. But I dont know how i can convert it. As I really can’t understand some of the syntax here so cant figure out the logic also.
like i want to convert this without using any vector

     for (int i = 0; i < g[last].size(); i++) {
        if (isNotVisited(g[last][i], path)) {
            vector<int> newpath(path);

Can anyone help how I can do it? I dont want to use recursion as it’s quite difficult for me


If I remember correctly a vector is just an array of key value pairs for the most part.
So you could use a js object

const myVector = {
    key1: value1,
    key2: value2


Is this JavaScript? If so, I have not seen the syntax in your for loop (the int i = 0; part). Are you using some kind of JavaScript preprocessor?

for (int i = 0; i < g[last].size(); i++) {

If vector needs to be iterable, then I suggest using the Map object.


A Vector is equivalent to a JS Array, so for translation purposes, read Array. It’s a structure with items in order, that expands or contracts in size when you add or remove items from it. Arrays in JS are basically exactly the same in the way you use them.