Shortest path-doubt

how can we add a vertex to adjacency list
by vertex i mean a node which is not connected to any other node

Hello @aganunay

It depends on how you are creating the adjacency list.
I declare a map, which maps a node with list of nodes it can reach.
map<int,list> m;

To insert in that map.

void add(int u,int v){
m[u].push_back(v);
m[v].push_back(u);
}

For an isolated node n, pass u and v both as n. Kind of self looping.

Hope, this would help.
Give a like if you are satisfied.