According to Wikipedia, "There are many variations of this basic idea"; but your adjacency list appears to be one of them, and perhaps done correctly.
Similarly, your depth-first search is valid depending on whether you have a rule for which direction to search first. You have not been consistent about that.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.