NAME:

PRECEPT:

LOGIN:

COS 226 Exercises on Undirected Graphs


1. Give the order in which the vertices are visited (for the first time) in DFS for the following undirected graph using a standard adjacency-matrix representation.
0-1 1-2 1-7 2-0 2-4 3-2 3-4 4-5 4-6 4-7 5-3 5-6 7-8 8-6

























2. Repeat question 1 for BFS. Also give the length of the shortest path (number of arcs) from vertex 0 to each other vertex.