{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# rec13 - 6.006 Intro to Algorithms Recitation 12 DFS Edge...

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

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 u

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

rec13 - 6.006 Intro to Algorithms Recitation 12 DFS Edge...

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

View Full Document
Ask a homework question - tutors are online