Graph traversal code is not executing

it throws error

you have to declare the visited map first
map<T,bool> visited;

Modified Code