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: 6.006 Intro to Algorithms Recitation 12 March 16, 2011 DFS Edge Classification The edges we traverse as we execute a depthfirst search can be classified into four edge types. During a DFS execution, the classification of edge ( u,v ) , the edge from vertex u to vertex v , depends on whether we have visited v before in the DFS and if so, the relationship between u and v . 1. If v is visited for the first time as we traverse the edge ( u,v ) , then the edge is a tree edge . 2. Else, v has already been visited: (a) If v is an ancestor of u , then edge ( u,v ) is a back edge . (b) Else, if v is a descendant of u , then edge ( u,v ) is a forward edge . (c) Else, if v is neither an ancestor or descendant of u , then edge ( u,v ) is a cross edge . After executing DFS on graph G , every edge in G can be classified as one of these four edge types. We can use edge type information to learn some things about G . For example, tree edges form trees containing each vertex DFS visited in G . Also, G has a cycle if and only if DFS finds at least one back edge . Note that undirected graphs cannot contain forward edges and cross edges , since in those cases, the edge ( v,u ) would have already been traversed during DFS before we reach...
View
Full
Document
This note was uploaded on 11/11/2011 for the course MATH 180 taught by Professor Byrns during the Spring '11 term at Montgomery College.
 Spring '11
 byrns
 Math

Click to edit the document details