Upload
avice-lamb
View
216
Download
1
Tags:
Embed Size (px)
Citation preview
CS 312: Algorithm Design & Analysis
Lecture #17: Connectedness in Graphs
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
Slides by: Eric Ringger, adapting figures from Dasgupta et al.
Announcements
Due now: HW #13
Project #4 Wednesday: Whiteboard Experience Friday: Early Day Virtual Monday = Tuesday: Due
Technical Career Fair: Thursday 9am-3pm in Wilkinson Student Center Preview: Wednesday 4:00pm in 1170 TMCB
This Week According to schedule!
Objectives
Wrap up connectedness in Undirected Graphs
DFS on Directed Graphs
Understand how to linearize a DAG
Many Kinds of Connectedness
DFS Analysis
“Non-committal Case”:Our generic analysis
covers best and worstcases.
DFS Yields a Forest
Directed Graphs
Let’s switch gears to directed graphs now
DFS on Directed Graphs
DFS on Directed Graphs
Edge Types Tree edges: part of the DFS
forest
Forward edges: lead to a non-child descendant in the DFS tree.
Back edges: lead to an ancestor in the DFS tree.
Cross edges: lead to a node that has already been completely explored (that is, already post-visited) lead to neither descendant nor
ancestor
Classifying Edge Types
Pre Pre Post Post
?
Classifying Edge Types
Pre Pre Post Post
Classifying Edge Types
Pre Pre Post Post
?
Classifying Edge Types
Pre Pre Post Post
Classifying Edge Types
Pre Pre Post Post
< ?
Classifying Edge Types
Pre Pre Post Post
<
Classify Edge
Cycles
How do you detect a cycle in a directed graph?
Property: A directed graph has a cycle if and only if its depth-first search reveals a back edge.
Otherwise: a Directed Acyclic Graph (DAG)
Sources, Sinks, LinearizationDFS Search Forest:
Linearization of the DAG == Topological Ordering of the DAG:
0. Define order; 1. DFS; 2. Read off post-order values in reverse order
Analysis:
Input DAG:
Sources, Sinks, Linearization
In our DAG, what do you notice about sources, sinks and post-order numbers?
Assignment
HW 13.5
Whiteboard Experience for Project #4