I was wondering how to go about solving a problem with disconnected graphs and depth-first search. Here is an example of a disconnected graph.
How would I go through it in DFS?
My current reasoning is by going down the left most subtree, as you would with a BST, so assuming that the node 5 is the start, the path would be: [5, 1, 4, 13, 2, 6, 17, 9, 11, 12, 10, 18].
This link should answer your question. In fact, DFS is often used to determine whether or not a graph is disconnected or not - if we run DFS and do not reach all of the nodes in the graph, the graph must be disconnected. Hope that helps!