This is my dfs code, it is running infinitely.
Please help.
void dfsHelper(int src,map<int,string> &visited)
{
cout<<src<<" ";
visited[src]==“gray”;
for(auto nbr:l[src])
{
if(visited[nbr]=="white")
{
dfsHelper(nbr,visited);
}
}
visited[src]="black";
}
void dfs(int src)
{
map<int,string> visited;
for(auto p:l)
{
visited[p.first]="white";
}
dfsHelper(src,visited);
}