procedure dfs (G) for all eV: for all EV: - visited (v) = false if not visited (r): explore (r) procedure explore (G.r) Input: G=(V.E) is a graph; rel Output: visited (w) is set to true for all nodes « reachable from r visited (r) = true previsit (r) for each edge (r.v) CE: if not visited(): explore() postvisit (2)
procedure dfs (G) for all eV: for all EV: - visited (v) = false if not visited (r): explore (r) procedure explore (G.r) Input: G=(V.E) is a graph; rel Output: visited (w) is set to true for all nodes « reachable from r visited (r) = true previsit (r) for each edge (r.v) CE: if not visited(): explore() postvisit (2)
5. Perform a depth-first search (DFS) on the following graph; whenever there's a choice of vertices, pick the one that is alphabetically first (Choose A as the starting node). Please draw the DFS trees and label post and pre value for each node. (12¹) B procedure dfs (G) for all EV: for all EV: H D visited () = false if not visited (v): explore (r) procedure explore (G,F) Input: G=(V,E) is a graph; rel' Output: visited (w) is visited (r) — true previsit (r) for each edge (.wir E: if not visited (u) = postvisit (e) G set to true for all nodes reachable from e explore (a)
procedure dfs (G) for all eV: for all EV: - visited (v) = false if not visited (r): explore (r) procedure explore (G.r)
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
procedure dfs (G) for all eV: for all EV: - visited (v) = false if not visited (r): explore (r) procedure explore (G.r)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!