I have a graph that is implemented as a list of edges connecting arbitrary nodes, with the data types defined below.
type edge = int * int;;
type graph = edge list;;
How would I perform a purely functional depth-first search while avoiding getting stuck on a cycle? I am not quite sure of how to keep track of all the nodes visited while remaining purely functional. The answer is probably something trivial that I am not conceptually grasping for some reason.