cse101_10_31_11

cse101_10_31_11 - DFS in directed graphs 1 From last time a...

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

View Full Document Right Arrow Icon
DFS in directed graphs 1. From last time a. A back edge is an edge that leads to an ancestor in the DFS tree. b. Fact (u,w) is a back edge post[u] < post[w] c. Fact: A directed graph is acyclic there are no back edges 2. Directed acyclic graphs (DAGs) a. Ex. Scheduling problem Wake up (1) -> dress (3) -> eat breakfast (4) -> shower (2) -> get kids ready (5) -> get in car (6) Wake up points to all nodes Shower points to dress, dress points to get kids ready In what order to perform these tasks? b. Given a DAG, we want a topological ordering: number the nodes so that every edge goes from a smaller to a larger number. c. It is always possible to topologically order a DAG; order nodes by decreasing post number (linear time) Eat breakfast (1, 4) get in car (2, 3) Shower (5, 10), dress (6, 9) get kids ready (7,8) Wake up (11, 12) Start at highest post number Claim: In any DAG, every edge goes from a bigger post # to a smaller post #. Proof: the only type of edge (u, w) which has POST[u] > POST[u] is a back
Background image of page 1

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

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

Page1 / 2

cse101_10_31_11 - DFS in directed graphs 1 From last time a...

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