Notes

Search

Search IconIcon to open search

S-T Connectivity

Last updated Dec 30, 2022

See Also: Graph Problems

Let’s solve a classic graph problem called s-t connectivity problem.

Recursive Solution

One possible recursive solution goes as follows:

Each vertex is visited at most once.

Depth First Traversal

The idea of exploring a neighbor’s entire subgraph before moving on to the next neighbor is known as Depth First Traversal.

Depth First Paths

Find a path from $s$ to every reachable vertex, visiting each vertex at most once. dfs(v) is as follows: