Graph Search Methods
- A vertex u is reachable from vertex v iff there is a
path from v to u.
2 3 8 10 1 4 5 9 11 6 7
Graph Search Methods
- A search method starts at a given vertex v and
visits/labels/marks every vertex that is reachable from v.
2 3 8 10 1 4 5 9 11 6 7
Graph Search Methods
- Many graph problems solved using a search
method.
Path from one vertex to another. Is the graph connected? Find a spanning tree. Etc.
- Commonly used search methods:
Breadth-first search. Depth-first search.
Breadth-First Search
- Visit start vertex and put into a FIFO queue.
- Repeatedly remove a vertex from the queue, visit
its unvisited adjacent vertices, put newly visited vertices into the queue.
Breadth-First Search Example
Start search at vertex 1.
2 3 8 10 1 4 5 9 11 6 7
Breadth-First Search Example
Visit/mark/label start vertex and put in a FIFO queue.
2 3 8 10 1 4 5 9 11 6 7 1