Depth-First Search (DFS)#

The depth-first search (DFS) algorithm is implemented to traverse the graph and explore vertices by going as deep as possible before backtracking.

The DFS algorithm can be used on both directed and undirected graphs.

For unweighted graphs, DFS is not used to compute shortest paths, but rather for: connected components, reachability, and graph traversal structures.

All DFS functions are convenience wrappers built on top of pygraphs.dfs().

dfs(graph, start, *[, stop_encounter, ...])

[core function] Perform a depth-first search (DFS) traversal of a unweighted graph starting from a given vertex.

dfs_is_reachable(graph, start, end, *[, ...])

Check if a vertex is reachable from a starting vertex.

dfs_reachable(graph, start, *[, _skip_check])

Extract the vertices that are reachable from a starting vertex.

dfs_components(graph, *[, ...])

Extract the connected components (or strongly connected components if strongly_connected=True) of the graph.