dfs

fun dfs(startNode: T, reset: Boolean = true)

Performs a Depth-First Search on the graph which finds all nodes that's reachable from the starting node it. It stores results that can be retrieved with the following functions:

  • depth()

  • currentVisitedNodes()

  • visitedNodes()

Parameters

startNode

The starting node for the DFS traversal.

reset

A boolean indicating whether to reset the previous search results. If set to false, previously visited nodes will not be visited again.

Throws

IllegalStateException

If the starting node is not found in the graph.