Doubt in the concept

Can you confirm if I have understood this right.

  1. We used the condition of parent[node]!=nbr because the graph was undirected. In case of directed graph we would not require this condition.
  2. In the question of topological sort using bfs, the nodes have values from 0 to V, that is why that is why we are directly pushing q.push(i). The condition would have been different if the nodes had random numbers like 5,7,9,and so on right?

hello @vageesha

correct.

yeah u need to iterate to set of all vertices . if they are only 5,7,9 then iterate only those part