This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Look at path from u to w. U -> z ->w Z is at distance k. therefore z is visited, and during explore(G,Z) w will be noticed 2. Depth-first search a. Def: u, w are connected if there is a path from u to w. A,F are connected Def: A connected component is the set of all nodes reachable from a particular starting point. Ex. The example graph has three connected components b. Explore(G,u) identifies the connected component containing u. To see more o the graph, restart explore at a node that hasn’t been visited. Procedure dfs(G) For all u in V: Visited[u] = false; For all u in V: If not visited[u]: Explore (G,u); c. Ex: run DFS in reverse alphabetical order of nodes Explore(I): I->N Explore(h): h->g->c Explore(f): f->e->a->b d. Time analysis of DFS d.i. Explore(G,u) is called exactly once for each node u. d.ii. The time it takes ignoring recursion is O(degree(u)) + O(1) Total time: sigma from u to V, degree(u) + abs(v) d.iii....
View Full Document
This note was uploaded on 01/09/2012 for the course CSE 101 taught by Professor Staff during the Spring '08 term at UCSD.
- Spring '08