Depth First Search Depth First Search Assume unweighted
- Slides: 106
Depth First Search
Depth First Search • Assume unweighted directed graph (allow self loops)
Proof: It corresponds to the structure of the recursive calls to DFS-Visit
1 2 3 4 5 6 7 8 9 10 11 u w v z y x 12
Proof: It corresponds to the structure of the recursive calls to DFS-Visit
Proof: It corresponds to the structure of the recursive calls to DFS-Visit
Edge classification • Tree edges: (u, v), DFS-Visit(v) was called from DFS-visit(u) • Back edges: (u, v) such that v is an ancestor of u in the DFS-forest
1 2 3 4 5 6 7 8 9 10 11 u w v z y x 12
Edge classification • Tree edges: (u, v), DFS-Visit(v) was called from DFS-visit(u) • Back edges: (u, v) such that v is an ancestor of u in the DFS-forest • Forward edges: nontree edges (u, v) such that v is a descendant of u
1 2 3 4 5 6 7 8 9 10 11 u w v z y x 12
Edge classification • Tree edges: (u, v), DFS-Visit(v) was called from DFS-visit(u) • Back edges: (u, v) such that v is an ancestor of u in the DFS-forest • Forward edges: nontree edges (u, v) such that v is a descendant of u • Cross edges: all other edges
1 2 3 4 5 6 7 8 9 10 11 u w v z y x 12
Edge classification • Tree edges: (u, v), DFS-Visit(v) was called from DFS-visit(u) • Back edges: (u, v) such that v is an ancestor of u in the DFS-forest • Forward edges: nontree edges (u, v) such that v is a descendant of u • Cross edges: all other edges v u
Classify as we go. . •
Topological sort • Input: G=(V, E) a directed, acyclic graph
Topological sort • 1 3 2 0 4 6 5 0 1 2 3 4 5 6
Topological sort • Lets run DFS 1/
Topological sort • Lets run DFS 2/ 1/
Topological sort • Lets run DFS 2/ 1/ 3/
Topological sort • Lets run DFS 2/ 1/ 3/ 4/
Topological sort • Lets run DFS 2/ 1/ 3/ 4/5
Topological sort • Lets run DFS 2/ 1/ 3/6 4/5
Topological sort • Lets run DFS 2/7 1/ 3/6 4/5
Topological sort • Lets run DFS 2/7 1/ 3/6 4/5
Topological sort • Lets run DFS 2/7 1/8 3/6 4/5
Topological sort • Lets run DFS 9/14 2/7 10/13 1/8 11/12 3/6 4/5
Topological sort • Order the vertices by reverse finishing times 9/14 2/7 10/13 1/8 11/12 3/6 4/5
Topological sort • Order the vertices by reverse finishing times 9/14 2/7 10/13 1/8 11/12 3/6 4/5 9/14 10/13 11/12 1/8 2/7 3/6 4/5
Topological sort (correctness) Thm 6: DFS on DAG does not produce back edges
Strongly connected components (SCC) •
Computing strongly connected components
Lets make a DFS
Reverse the graph
An algorithm to compute SCC’s
Remove parallel edges using an array. .
Tarjan’s algorithm • We will find SCCs using only one DFS Proof: … Corr: Each SC form a (connected) subtree of the DFS-forest
Identify the roots of these subtrees 6 1/ 2/ 7 4 10 15 3 8 5 11 16 9 14 12 17 13 18 19
Identify the roots of these subtrees 6 1 2 3 7 4 10 15 8 5 11 16 9 14 12 17 13 18 19
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 14 12 17 13 18 19 1
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 14 12 17 13 18 2 19 1
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 14 12 3 17 13 18 2 19 1
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 14 12 3 17 13 18 2 19 1
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 14 12 17 13 18 19 1
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 14 12 17 13 18 19 1
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 14 12 17 13 18 4 19 1
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 14 5 12 17 13 18 4 19 1
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 14 5 12 17 13 18 4 19 1
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 14 5 12 17 13 18 4 19 1
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 14 12 17 13 18 19
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 14 12 17 13 18 19 6
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 9 14 8 12 17 13 7 18 19 6
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 9 14 8 12 17 13 7 18 19 6
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 14 12 17 13 7 18 19 6
Use an additional stack 6 1 2 3 7 4 10 13 15 12 8 5 11 16 9 11 14 12 10 17 13 18 7 19 6
Use an additional stack 6 1 2 3 7 4 10 15 12 8 5 11 16 9 11 14 12 10 17 13 18 7 19 6
19 Use an additional stack 18 17 6 1 2 3 16 7 4 10 15 15 8 5 14 11 16 9 12 14 12 11 17 13 10 18 19 7 6
Use an additional stack 6 1 2 3 16 7 4 10 15 15 8 5 14 11 16 9 12 14 12 11 17 13 10 18 19 7 6
Use an additional stack 6 1 2 3 16 7 4 10 15 15 8 5 14 11 16 9 12 14 12 11 17 13 10 18 19 7 6
Use an additional stack 6 1 2 3 7 4 10 15 8 5 11 16 9 14 12 17 13 18 19
Characterize these roots ?
a d b c c d b a
How do we identify roots ? .
Identify the roots of these subtrees 6 1 2 3 7 4 10 15 8 5 11 16 9 14 12 17 13 18 19
Compute SCs using low values 1 6 1 2 3 7 4 10 15 8 5 11 16 9 14 12 17 13 18 19 1
Compute SCs using low values 1 6 1 2 3 2 7 4 10 15 8 5 11 16 9 14 12 17 13 18 2 19 1
1 6 1 2 3 3 2 7 4 10 15 8 5 11 16 9 14 12 3 17 13 18 2 19 1
1 6 1 2 3 2 2 7 4 10 15 8 5 11 16 9 14 12 3 17 13 18 2 19 1
1 6 1 2 3 2 2 7 4 10 15 8 5 11 16 9 14 12 3 17 13 18 2 19 1
1 6 1 2 3 2 2 7 4 10 15 8 5 11 16 9 14 12 17 13 18 19 1
1 6 1 2 3 2 2 7 4 10 15 8 5 11 16 9 14 12 17 13 18 19 1
1 1 2 3 2 2 6 4 7 4 10 15 8 5 11 16 9 14 12 17 13 18 4 19 1
1 1 2 3 2 2 6 4 7 4 10 15 5 8 5 11 16 9 14 5 12 17 13 18 4 19 1
1 1 2 3 2 2 6 4 7 4 10 15 4 8 5 11 16 9 14 5 12 17 13 18 4 19 1
1 1 2 3 2 2 6 4 7 4 10 15 1 8 5 11 16 9 14 5 12 17 13 18 4 19 1
1 1 2 3 2 2 6 1 7 4 10 15 1 8 5 11 16 9 14 5 12 17 13 18 4 19 1
1 1 2 3 2 2 6 1 7 4 10 15 1 8 5 11 16 9 14 5 12 17 13 18 4 19 1
1 1 2 3 2 2 6 1 7 4 10 15 1 8 5 11 16 9 14 12 17 13 18 19
6 1 1 2 3 2 2 6 1 7 4 10 15 1 8 5 11 16 9 14 12 17 13 18 19 6
6 1 1 2 3 2 2 6 7 1 7 4 10 8 1 5 15 8 9 11 16 9 9 14 8 12 17 13 7 18 19 6
6 1 1 2 3 2 2 6 7 1 7 4 10 8 1 5 15 8 8 11 16 9 9 14 8 12 17 13 7 18 19 6
6 1 1 2 3 2 2 6 7 1 7 4 10 8 1 5 15 8 8 11 16 9 9 14 8 12 17 13 7 18 19 6
6 1 1 2 3 2 2 6 7 1 7 4 10 8 1 5 15 8 8 11 16 9 14 12 17 13 7 18 19 6
6 1 1 2 3 2 2 6 6 1 7 4 10 8 1 5 15 8 8 11 16 9 14 12 17 13 7 18 19 6
6 1 1 2 3 2 2 6 6 1 7 4 10 8 1 10 5 15 11 8 8 12 11 12 9 16 11 14 12 10 17 13 18 7 19 6
6 1 1 2 3 2 2 6 6 1 7 4 10 8 1 10 5 15 11 8 8 6 9 12 11 16 11 14 12 10 17 13 18 7 19 6
6 1 1 2 3 2 2 6 6 1 7 4 10 13 8 1 10 5 15 11 8 8 9 6 12 11 16 11 14 12 13 10 17 13 18 7 19 6
6 1 1 2 3 2 2 6 6 1 7 4 10 8 1 10 5 15 11 8 8 9 6 12 11 16 11 14 12 13 10 17 13 18 7 19 6
6 1 1 2 3 2 2 6 6 1 7 4 10 8 1 10 5 15 6 8 8 9 6 12 11 16 11 14 12 13 10 17 13 18 7 19 6
6 1 1 2 3 2 2 6 6 1 7 4 10 14 8 1 10 5 15 6 8 8 9 6 12 11 14 16 11 14 12 13 10 17 13 18 7 19 6
6 1 1 2 3 2 2 6 6 1 7 4 10 14 8 1 10 5 15 6 8 8 9 6 12 11 6 16 11 14 12 13 10 17 13 18 7 19 6
6 1 1 2 3 2 2 6 6 1 7 4 10 14 8 1 6 5 15 6 8 8 9 6 12 11 6 16 11 14 12 13 10 17 13 18 7 19 6
6 1 1 2 3 2 2 6 6 1 7 4 5 15 9 14 15 6 8 8 15 10 8 1 6 6 12 11 6 16 11 14 12 13 10 17 13 18 7 19 6
19 18 6 1 1 2 3 2 2 6 6 1 6 7 4 5 15 9 15 15 6 8 8 16 10 8 1 17 14 11 6 6 16 16 12 14 12 17 13 11 17 13 10 17 18 19 17 7 6
6 1 1 2 3 2 2 6 6 1 7 4 5 15 9 15 15 6 8 8 16 10 8 1 6 14 11 6 6 16 16 12 14 12 17 13 11 17 13 10 17 18 19 17 7 6
SCs using low values 6 1 1 2 3 2 2 6 6 1 7 4 10 6 8 1 6 5 15 6 8 8 9 11 6 6 6 16 14 12 17 13 17 18 19 17
Tarjan’s algorithm
- Breadth first and depth first search
- Hbcig
- Depth first search lifo
- Iterative deepening search
- Depth first search algorithm complexity
- Which search method takes less memory?
- Depth first search inventor
- Water jug problem production rules
- Chronological backtracking in depth first search involves
- Depth first
- Pvif table
- Unweighted 0-1 factor model
- Weighted vs unweighted gpa
- Unweighted area sampling
- Unweighted area sampling
- What is a weighted gpa
- Unweighted gpa
- Non weighted codes examples
- Unweighted 0-1 factor model
- Total internal reflection in a semicircular glass block
- Assume that the weight loss for the first month
- Best first search in ai
- Depth limited search
- Depth first traversals
- Xkcd depth first
- Always assume positive intent
- Assume shape
- Difference between entrepreneur and manager
- Inurl:/origami/ .php?year= site:com
- Never assume always ask
- Assume that a firm produces output using one fixed input
- Lsaiso
- Assume the economy of andersonland
- Assume breach
- Assume
- Many people assume that
- Half range fourier cosine series is
- Electrons in an atom tend to assume the arrangement
- Generic knowledge meaning
- The given signs signify
- Which russian leader does napoleon most resemble?
- Assume that oil spilled from a ruptured tanker
- Dont assume quotes
- Contoh soal pohon semantik
- Assume knowledge
- Assume sysdate =25 jul 95
- Assume sysdate =25 jul 95
- Risk and return
- Un paramorfismo e' un vizio del portamento
- Assume -r? [n]
- Rosso di metile indicatore
- Economists assume that firms seek to
- Assume that an aqueous solution of a cation
- Uninformed search algorithm
- Federated discovery
- Local search vs global search
- Federated search vs distributed search
- Informed and uninformed search
- Images.search.yahoo.com
- Blind search dan heuristic search
- Video.search.yahoo.com
- Tw yahoo mail
- Limitation of binary search
- Search by image
- Httptw
- Multilingual semantical markup
- Comparison of uninformed search strategies
- Http://search.yahoo.com/search?ei=utf-8
- Whats a search engine
- State space representation in ai
- Consistent heuristic
- Greedy best first search
- Metode breadth first search
- Properties of breadth first search
- Rule of thumb heuristic
- Best first search algoritması
- Xkcd breadth first search
- Greedy best first search example
- Best first search in ai
- Aebcd
- Breadth first traversal binary tree
- Best first search in ai
- Best first search in ai
- Bredth first search
- Breadth first search animation
- Breadth first search
- Breadth first search
- Cs101-8
- Maturity continuum victories
- Sdl first vs code first
- Put first things first activities
- Habit 3
- Difference between code first and database first approach
- First to invent or first to file
- Data structure stack
- Dilakukan perintah top(push(b,s))
- First in first out
- First come first serve
- Put first things first definition
- Fcfs gantt chart
- See do get model 7 habits
- Habit 3 put first things first
- Put first things first video
- Put first things first activities
- First aid merit badge first aid kit
- Objective of first aid
- Put first things first