Connected (reachable)
Connected Component: maximal set of vertices that are connected (connected individual graph)

Search Problem: finding a witness (more complex, for cryptography)
Verification Problem: checking a witness

Depth First Search with Adjacency List

Fixing DFS using mark array

alloc costs O(v)

dfs_helper costs O(e)

free costs O(1)

together O(v+e)

but if you use hashset or with sparse graph, they cost O(e)

(only use when graph is small)

Implementation with Adjacency Matrix

Costs: O(v^2)

Breath First Search

remember to free queue, mark array

If we use queue: breath first
If we use stack or other: depth first
If we use priority: A* heuristic (but insertion and removal from priority queue is not O(1))