rec13 - 6.006 Intro to Algorithms Recitation 12 March 16,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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 depth-first 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.

Page1 / 3

rec13 - 6.006 Intro to Algorithms Recitation 12 March 16,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online