Topological sort using BFS

When we are creating in degree array we are assuming that we are getting nodes from 0-v-1 right??

But what if we get arbitrary nodes in that case we can use map??

NO ,there is no such assumption

if we get elements in random order then this algorithm also work

we are just taking all element and increasing the indegree of those node which are connected to them

But when we are creating array dynamically it’s size will be of v right. Suppose V is 4 then our array index will be 0,1,2,3 and if we have a node like 15 thend indegree[15] ++ isn’t possible??

the code written is for the situation
when we have nodes from 1 to n-1

but you can also create map<int,int>indegree
and set indegree of 15 to 0
algorithm still works only the implementation changes a little bit

That is what I was referring to

okay
I interpret your question differently
sorry

i hope now it’s clear