Can you confirm if I have understood this right.
- We used the condition of parent[node]!=nbr because the graph was undirected. In case of directed graph we would not require this condition.
- 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?