Draw your graph:
()
function dfs(graph, v)
visited[v] =
true
neighbours = graph.getNeighboursOf(v)
for(i in
neighbours)
if(!visited[i])
dfs(graph, i)
SHORT EXPLANATION
---------------------
1. Visit the first vertex
2. Find the first unvisited vertex this vertex has a
connection to.
3. Recursively visit this vertex and repeat step 2 until
there are no more unvisited vertices.
4. Repeat steps 2 and 3 for each step of the
recurison.