GRAPH ALGORITHMS 337 CHAPTER 14 LAX 4 17
- Slides: 48
GRAPH ALGORITHMS 337 CHAPTER 14 LAX 4 17 3 1233 ORD 802 SFO 1843 DFW ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN JAVA, GOODRICH, TAMASSIA AND GOLDWASSER (WILEY 2016)
A DEPTH-FIRST SEARCH B D C E
DEPTH-FIRST SEARCH • •
DFS ALGORITHM FROM A VERTEX •
EXAMPLE unexplored vertex visited vertex unexplored edge discovery edge back edge A A A B F E G C A D C D E B G F D C E G
EXAMPLE A B F A D C E B G F A B F E G C A D C D E B G F D C E G
EXAMPLE A A B D F C A B F D C E G E B G F D C E G
EXERCISE DFS ALGORITHM • Perform DFS of the following graph, start from vertex A • • • Assume adjacent edges are processed in alphabetical order Number vertices in the order they are visited Label edges as discovery or back edges A B C E D F
DFS AND MAZE TRAVERSAL • The DFS algorithm is similar to a classic strategy for exploring a maze • We mark each intersection, corner and dead end (vertex) visited • We mark each corridor (edge) traversed • We keep track of the path back to the entrance (start vertex) by means of a rope (recursion stack)
DFS ALGORITHM • •
PROPERTIES OF DFS v 1 • A B F D C E G v 2
ANALYSIS OF DFS • A B F D C E G
APPLICATION PATH FINDING • •
APPLICATION CYCLE FINDING • •
DIRECTED DFS E • D C B A
REACHABILITY • E E D C A D C F A E B D C A F B
STRONG CONNECTIVITY • Each vertex can reach all other vertices a g c d e f b
STRONG CONNECTIVITY ALGORITHM • a G: g c d e b f a G’: g c d f e b
STRONGLY CONNECTED COMPONENTS • a g c d f e b {a, c, g} {f, d, e, b}
L 0 L 1 BREADTH-FIRST SEARCH A B L 2 C E D F
BREADTH-FIRST SEARCH • •
BFS ALGORITHM • •
EXAMPLE unexplored vertex visited vertex unexplored edge discovery edge cross edge A A L 0 L 1 L 0 C E B D F C E A B A L 1 D F A B C E D F
A A EXAMPLE L 0 L 1 L 0 A B C E L 0 L 1 F L 0 C E D F L 1 unexplored edge discovery edge cross edge A B L 2 D L 1 unexplored vertex visited vertex C E F A B L 2 D C E D F
A A EXAMPLE L 0 L 1 A B L 2 C E D F L 1 unexplored edge discovery edge cross edge A B L 2 L 0 unexplored vertex visited vertex C E D F
EXERCISE BFS ALGORITHM • Perform BFS of the following graph, start from vertex A • • • Assume adjacent edges are processed in alphabetical order Number vertices in the order they are visited and note the level they are in Label edges as discovery or cross edges A B C E D F
PROPERTIES A • B C E L 0 L 1 F A B L 2 D C E D F
ANALYSIS •
APPLICATIONS •
DFS VS. BFS Applications DFS BFS Spanning forest, connected components, paths, cycles Shortest paths Biconnected components L 0 A B C E D F DFS L 1 A B L 2 C E BFS D F
DFS VS. BFS • • L 0 A B C E D F DFS L 1 A B L 2 C E BFS D F
BOS ORD JFK SFO TOPOLOGICAL ORDERING LAX DFW MIA
DAGS AND TOPOLOGICAL ORDERING D • E B C DAG G A v 2 v 1 D B C A v 4 E v 5 v 3 Topological ordering of G
APPLICATION • ics 21 ics 22 ics 23 ics 51 ics 53 ics 52 ics 161 ics 131 ics 141 ics 151 ics 121 ics 171 The good life
EXERCISE TOPOLOGICAL SORTING • A typical student day wake up study computer sci. eat nap more c. s. play write c. s. program work out bake cookies sleep dream about graphs
EXERCISE TOPOLOGICAL SORTING • wake up 1 A typical student day 2 study computer sci. eat 4 7 play nap 8 write c. s. program 9 3 5 more c. s. 6 work out bake cookies 10 sleep 11 dream about graphs
ALGORITHM FOR TOPOLOGICAL SORTING •
IMPLEMENTATION WITH DFS • •
TOPOLOGICAL SORTING EXAMPLE
TOPOLOGICAL SORTING EXAMPLE 9
TOPOLOGICAL SORTING EXAMPLE 8 9
TOPOLOGICAL SORTING EXAMPLE 7 8 9
TOPOLOGICAL SORTING EXAMPLE 6 7 8 9
TOPOLOGICAL SORTING EXAMPLE 6 5 7 8 9
TOPOLOGICAL SORTING EXAMPLE 4 6 5 7 8 9
TOPOLOGICAL SORTING EXAMPLE 3 4 6 5 7 8 9
TOPOLOGICAL SORTING EXAMPLE 2 3 4 6 5 7 8 9
TOPOLOGICAL SORTING EXAMPLE 2 1 3 4 6 5 7 8 9
- White path theorem
- Parallelizing sequential graph computations
- Elementary graph algorithms
- Undirected graph algorithms
- 337 form example
- Form 337 example
- 337 form example
- 337info
- Fritzing load cell
- Csc 337
- Csc 337
- Tense lax vowel chart
- Tesut conjunctiv adipos
- Lax front vowel phoneme
- Gemalax
- Ia sundberg lax
- Sambandsord
- Stoop sitting position
- Tense vowels english
- Fjälla gädda
- Spatial discretization
- Tesuturile animale se clasifica in
- Shaklee herb lax side effects
- What is a freedom
- Lax internship
- Bridge graph
- Wait-for graph
- Computational thinking algorithms and programming
- Types of algorithm
- Simple recursive algorithms
- Design and analysis of algorithms syllabus
- Safe patient handling algorithms
- Define recursive function
- Types of randomized algorithms
- Process mining algorithms
- Evolution of logistics ppt
- Nature-inspired learning algorithms
- Tabu search tsp
- Making good encryption algorithms
- An introduction to the analysis of algorithms
- Statistical algorithms
- Ajit diwan iit bombay
- Advantage and disadvantage of greedy algorithm
- N/a greedy
- What is global state in distributed system
- Classical algorithms for forrelation
- Aprioti
- Dsp programming tutorial
- Distributed algorithms nancy lynch