![Page 1: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/1.jpg)
Graphs
![Page 2: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/2.jpg)
Announcements() {
![Page 3: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/3.jpg)
Change in Schedule● I'm changing the schedule around a bit...
● Today: Graphs● Tuesday: Shortest Path Algorithms● Wednesday: Minimum Spanning Trees● Tursday: Review Session for Midterm II
![Page 4: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/4.jpg)
Final
● Final: Monday, August 12th, 7-10pm
● Location: Cubberly Auditorium● Cumulative (but weighted towards post midterm
material)● Covers material up through Tuesday
– SCPD students and students who require special arrangements should email me in the next couple days
● We do the final “early” so we have time to grade it, get it back to you and resolve any grading issues.
![Page 5: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/5.jpg)
} //Announcements
![Page 6: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/6.jpg)
Data Structures Cheat Sheet
● Vector, Stack: dynamic array
● Queue: linked list or dynamic array
● Set, Map: Binary Search Tree
● HashSet, HashMap: Hash Table
● Lexicon: Trie
![Page 7: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/7.jpg)
Graphs
![Page 8: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/8.jpg)
A Social Network
![Page 9: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/9.jpg)
http://strangemaps.files.wordpress.com/2007/02/fullinterstatemap-web.jpg
![Page 10: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/10.jpg)
http://www.toothpastefordinner.com/
![Page 11: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/11.jpg)
A graph is a mathematical structurefor representing relationships.
![Page 12: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/12.jpg)
A graph is a mathematical structurefor representing relationships.
A graph consists of a set of nodes connected by edges.
![Page 13: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/13.jpg)
A graph is a mathematical structurefor representing relationships.
A graph consists of a set of nodes connected by edges.
![Page 14: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/14.jpg)
A graph is a mathematical structurefor representing relationships.
A graph consists of a set of nodes connected by edges.
![Page 15: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/15.jpg)
A graph is a mathematical structurefor representing relationships.
A graph consists of a set of nodes connected by edges.
Nodes
![Page 16: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/16.jpg)
A graph is a mathematical structurefor representing relationships.
A graph consists of a set of nodes connected by edges.
Edges
![Page 17: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/17.jpg)
Some graphs are directed.
![Page 18: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/18.jpg)
CAT SAT RAT
RANMAN
MAT
CAN
Some graphs are undirected.
![Page 19: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/19.jpg)
CAT SAT RAT
RANMAN
MAT
CAN
Some graphs are undirected.
You can think of them as directedgraphs with edges both ways.
![Page 20: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/20.jpg)
Graphs● “Yo Teach, why are we studying graphs?”
● We study graphs because a lot of problems can be modeled in terms of graphs
● Also, there are many off-the-shelf graph algorithms that we apply if we're able to formulate a problem as a graph problem.
![Page 21: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/21.jpg)
Pathfinding
● Each intersection is a node
● Each street connecting intersections is an edge
● Find paths between intersections that minimize distance or travel time
![Page 22: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/22.jpg)
Content-Aware Resizing
![Page 23: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/23.jpg)
Content-Aware Resizing
● Each pixel is a node in a graph
● Each pixel is connected to adjacent pixels
● Find paths from the top of the image to the bottom that minimize the “energy function”
![Page 24: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/24.jpg)
The Wikipedia Graph
● Wikipedia (and the web in general) is a graph!
● Each page is a node.
● There is an edge from one page to another if the first page links to the second.
![Page 25: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/25.jpg)
Social Networks and Epidemics
http://3278as3udzze1hdk0f2th5nf18c1.wpengine.netdna-cdn.com/wp-content/uploads/2010/09/social-networks-new-science1.jpg
https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&docid=MPB6JuYe9sdbDM&tbnid=VWbN0BtTG7-ZWM:&ved=0CAUQjRw&url=http%3A%2F%2Fblogs.cornell.edu%2Finfo2040%2F2011%2F09%2F17%2Fhow-network-structure-can-provide-advanced-warning-about-epidemics%2F&ei=rrP9Ufa8G6n0iwK9q4CoBQ&bvm=bv.50165853,d.cGE&psig=AFQjCNHljXC1ZggH6hQDrKxPM1CV7ocVXQ&ust=1375667391653650
![Page 26: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/26.jpg)
How can we represent graphs in C++?
![Page 27: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/27.jpg)
Representing Graphs
Node Connected To
Vector<Node*> Node*
Map<Node*, Vector<Node*>> We can represent a graph as a map from nodes to the list
of nodes each node is connected to.
We can represent a graph as a map from nodes to the list
of nodes each node is connected to.
![Page 28: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/28.jpg)
What interesting things can we do with graphs?
![Page 29: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/29.jpg)
Connected Components
● A connected component is a subset of the nodes in a graph such that:
● For every pair of nodes in the subset there exists a path between them
● No node in the subset is not connected any node not in the subset
![Page 30: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/30.jpg)
Connected Components
1 Connected Component
![Page 31: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/31.jpg)
Connected Components
2 Connected Components
![Page 32: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/32.jpg)
Connected Components
3 Connected Components
![Page 33: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/33.jpg)
Connected Components
6 Connected Components
![Page 34: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/34.jpg)
Connected Components
● Detecting connected components in a graph is important because it can provide useful insights into the structure of graph
● e.g. How do people in a community separate themselves into separate groups.
● In order to detect connected components we first need to be able to iterate over nodes in a graph.
● We'll come back to connected components later.
![Page 35: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/35.jpg)
Iterating over a Graph
● Given a linked list, there was just one way to traverse the list.● Keep going forward.
● In a binary search tree, there are many traversal strategies:
● An inorder traversal that produces all the elements in sorted order.
● A postorder traversal used to delete all the nodes in the BST.
● There are many ways to iterate over a graph.
![Page 36: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/36.jpg)
Iterating over a Graph
● All methods of iterating over a graph involve keeping track of 3 sets of nodes:
Set of Nodes already visited
Set of Nodes to look at next
Everything else
![Page 37: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/37.jpg)
Iterating over a Graph
![Page 38: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/38.jpg)
Iterating over a Graph
![Page 39: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/39.jpg)
Iterating over a Graph
![Page 40: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/40.jpg)
Iterating over a Graph
![Page 41: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/41.jpg)
Iterating over a Graph
![Page 42: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/42.jpg)
Iterating over a Graph
![Page 43: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/43.jpg)
Iterating over a Graph
![Page 44: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/44.jpg)
Iterating over a Graph
![Page 45: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/45.jpg)
Iterating over a Graph
![Page 46: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/46.jpg)
Iterating over a Graph
![Page 47: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/47.jpg)
Iterating over a Graph
![Page 48: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/48.jpg)
Iterating over a Graph
![Page 49: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/49.jpg)
Iterating over a Graph
![Page 50: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/50.jpg)
Iterating over a Graph
![Page 51: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/51.jpg)
Iterating over a Graph
![Page 52: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/52.jpg)
Iterating over a Graph
![Page 53: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/53.jpg)
Iterating over a Graph
![Page 54: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/54.jpg)
Iterating over a Graph
![Page 55: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/55.jpg)
Iterating over a Graph
![Page 56: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/56.jpg)
Iterating over a Graph
![Page 57: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/57.jpg)
Iterating over a Graph
![Page 58: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/58.jpg)
Iterating over a Graph
![Page 59: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/59.jpg)
Iterating over a Graph
![Page 60: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/60.jpg)
Iterating over a Graph
![Page 61: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/61.jpg)
Iterating over a Graph
![Page 62: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/62.jpg)
Iterating over a Graph
![Page 63: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/63.jpg)
Iterating over a Graph
![Page 64: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/64.jpg)
Iterating over a Graph
![Page 65: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/65.jpg)
Iterating over a Graph
![Page 66: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/66.jpg)
Iterating over a Graph
![Page 67: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/67.jpg)
Iterating over a Graph
![Page 68: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/68.jpg)
Iterating over a Graph
![Page 69: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/69.jpg)
Iterating over a Graph
![Page 70: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/70.jpg)
Iterating over a Graph
![Page 71: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/71.jpg)
Iterating over a Graph
● All methods of iterating over a graph involve keeping track of 3 sets of nodes:
Set of Nodes already visited
Set of Nodes to look at next
Everything else
● Methods of iterating over nodes differ in how they choose which node to look at next
![Page 72: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/72.jpg)
Recursive Depth First Search● To detect connected components we just
want to see whether or not some path exists between them (we don't care about finding the “shortest” path).
● One way to detect connectivity would be to just pick an arbitrary direction and keep following it.● When you run out of room to go in one
direction, just go back and look in a different direction
![Page 73: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/73.jpg)
Recursive Depth-First Search
![Page 74: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/74.jpg)
Recursive Depth-First Search
![Page 75: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/75.jpg)
Recursive Depth-First Search
![Page 76: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/76.jpg)
Recursive Depth-First Search
![Page 77: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/77.jpg)
Recursive Depth-First Search
![Page 78: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/78.jpg)
Recursive Depth-First Search
![Page 79: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/79.jpg)
Recursive Depth-First Search
![Page 80: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/80.jpg)
Recursive Depth-First Search
![Page 81: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/81.jpg)
Recursive Depth-First Search
![Page 82: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/82.jpg)
Recursive Depth-First Search
![Page 83: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/83.jpg)
Recursive Depth-First Search
![Page 84: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/84.jpg)
Recursive Depth-First Search
![Page 85: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/85.jpg)
Recursive Depth-First Search
![Page 86: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/86.jpg)
Recursive Depth-First Search
![Page 87: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/87.jpg)
Recursive Depth-First Search
![Page 88: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/88.jpg)
Recursive Depth-First Search
![Page 89: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/89.jpg)
Recursive Depth-First Search
![Page 90: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/90.jpg)
Recursive Depth-First Search
![Page 91: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/91.jpg)
Recursive Depth-First Search
![Page 92: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/92.jpg)
Recursive Depth-First Search
![Page 93: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/93.jpg)
Recursive Depth-First Search
![Page 94: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/94.jpg)
Recursive Depth-First Search
![Page 95: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/95.jpg)
Recursive Depth-First Search
![Page 96: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/96.jpg)
Recursive Depth-First Search
![Page 97: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/97.jpg)
Recursive Depth-First Search
![Page 98: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/98.jpg)
Recursive Depth-First Search
![Page 99: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/99.jpg)
Recursive Depth-First Search
![Page 100: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/100.jpg)
Recursive Depth-First Search
![Page 101: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/101.jpg)
Recursive Depth-First Search
![Page 102: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/102.jpg)
Recursive Depth-First Search
![Page 103: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/103.jpg)
Recursive Depth-First Search
![Page 104: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/104.jpg)
Recursive Depth-First Search
![Page 105: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/105.jpg)
Recursive Depth-First Search
![Page 106: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/106.jpg)
Recursive Depth-First Search
![Page 107: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/107.jpg)
Recursive Depth-First Search
![Page 108: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/108.jpg)
Recursive Depth-First Search
![Page 109: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/109.jpg)
Recursive Depth-First Search
![Page 110: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/110.jpg)
Recursive Depth-First Search
![Page 111: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/111.jpg)
Recursive Depth-First Search
![Page 112: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/112.jpg)
Recursive Depth-First Search
![Page 113: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/113.jpg)
Recursive Depth-First Search
![Page 114: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/114.jpg)
Recursive Depth-First Search
![Page 115: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/115.jpg)
Recursive Depth-First Search
![Page 116: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/116.jpg)
Recursive Depth-First Search
● To do a depth-first search (DFS) from a node u, do the following:● If u is already marked, stop.● Mark u.● For each neighbor v of u:
– Recursively run DFS from v.
● The backtracking here is similar to the backtracking done in standard recursion.
![Page 117: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/117.jpg)
Iterative Depth-First Search
● DFS is most commonly implemented iteratively using a Stack
![Page 118: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/118.jpg)
Depth-first search
A B
D E
C
F
![Page 119: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/119.jpg)
Depth-first search
A B
D E
C
F
StackSet
![Page 120: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/120.jpg)
Depth-first search
A B
D E
C
F
Stack
A
Set
![Page 121: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/121.jpg)
Depth-first search
A B
D E
C
F
StackSet
![Page 122: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/122.jpg)
Depth-first search
A B
D E
C
F
StackSet
A
![Page 123: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/123.jpg)
Depth-first search
A B
D E
C
F
Stack
B
E
Set
A
![Page 124: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/124.jpg)
Depth-first search
A B
D E
C
F
Stack
B
E
Set
A
![Page 125: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/125.jpg)
Depth-first search
A B
D E
C
F
Stack
B
Set
A
![Page 126: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/126.jpg)
Depth-first search
A B
D E
C
F
Stack
B
Set
A
E
![Page 127: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/127.jpg)
Depth-first search
A B
D E
C
F
Stack
B
D
F
C
Set
A
E
![Page 128: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/128.jpg)
Depth-first search
A B
D E
C
F
Stack
B
D
F
C
Set
A
E
![Page 129: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/129.jpg)
Depth-first search
A B
D E
C
F
Stack
B
D
F
Set
A
E
![Page 130: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/130.jpg)
Depth-first search
A B
D E
C
F
Stack
B
D
F
Set
A
E
C
![Page 131: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/131.jpg)
Depth-first search
A B
D E
C
F
Stack
B
D
F
Set
A C
E
B
![Page 132: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/132.jpg)
Depth-first search
A B
D E
C
F
Stack
B
D
F
Set
A C
E
B
![Page 133: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/133.jpg)
Depth-first search
A B
D E
C
F
Stack
B
D
F
Set
A C
E
B
![Page 134: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/134.jpg)
Depth-first search
A B
D E
C
F
Stack
B
D
F
Set
A C
E
![Page 135: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/135.jpg)
Depth-first search
A B
D E
C
F
Stack
B
D
F
Set
A C
E
B
![Page 136: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/136.jpg)
Depth-first search
A B
D E
C
F
Stack
B
D
F
Set
A C
E
B
![Page 137: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/137.jpg)
Depth-first search
A B
D E
C
F
Stack
B
D
Set
A C
E
B
![Page 138: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/138.jpg)
Depth-first search
A B
D E
C
F
Stack
B
D
Set
A C
E
B
F
![Page 139: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/139.jpg)
Depth-first search
A B
D E
C
F
Stack
B
D
Set
A C
E
B
F
![Page 140: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/140.jpg)
Depth-first search
A B
D E
C
F
Stack
B
Set
A C
E
B
F
![Page 141: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/141.jpg)
Depth-first search
A B
D E
C
F
Stack
B
Set
A C
E
B
FD
![Page 142: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/142.jpg)
Depth-first search
A B
D E
C
F
Stack
B
Set
A C
E
B
FD
![Page 143: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/143.jpg)
Depth-first search
A B
D E
C
F
StackSet
A C
E
B
FD
![Page 144: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/144.jpg)
Coding Depth-First Search
![Page 145: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/145.jpg)
DFS and Connected Components
● Detecting connected components becomes relatively straightforward once we have Depth First Search.
● Not going to code it up, but I encourage you to!
![Page 146: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/146.jpg)
Problems with DFS
● Useful when trying to explore everything.● Not good at finding shortest paths.
![Page 147: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/147.jpg)
Problems with DFS
● Useful when trying to explore everything.● Not good at finding shortest paths.
Stack
![Page 148: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/148.jpg)
Problems with DFS
● Useful when trying to explore everything.● Not good at finding shortest paths.
A B
Stack
![Page 149: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/149.jpg)
Problems with DFS
● Useful when trying to explore everything.● Not good at finding shortest paths.
A B
Stack
B
A
![Page 150: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/150.jpg)
Breadth-First Search
![Page 151: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/151.jpg)
![Page 152: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/152.jpg)
![Page 153: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/153.jpg)
![Page 154: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/154.jpg)
![Page 155: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/155.jpg)
1
1
11
![Page 156: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/156.jpg)
2
1
1
2
2
12
1
2
2
![Page 157: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/157.jpg)
2
1
1
2
2
12
1
2
2
![Page 158: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/158.jpg)
![Page 159: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/159.jpg)
Breadth-First Search
● Specialization of the general search algorithm where nodes to visit are put into a queue.
● Explores nodes one hop away, then two hops away, etc.
● Finds path with fewest edges from start node to all other nodes.
![Page 160: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/160.jpg)
Note: The following animation has been simplified for pedagogic purposes. In
reality there would be a Set keeping track of visited nodes and redundant adds to the
Queue
![Page 161: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/161.jpg)
Breadth-first search
A B
D E
C
F
![Page 162: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/162.jpg)
Breadth-first search
A B
D E
C
F
Queue
![Page 163: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/163.jpg)
Breadth-first search
A B
D E
C
F
Queue A
![Page 164: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/164.jpg)
Breadth-first search
A B
D E
C
F
Queue
![Page 165: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/165.jpg)
Breadth-first search
A B
D E
C
F
Queue B E
![Page 166: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/166.jpg)
Breadth-first search
A B
D E
C
F
Queue B E
![Page 167: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/167.jpg)
Breadth-first search
A B
D E
C
F
Queue E
![Page 168: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/168.jpg)
Breadth-first search
A B
D E
C
F
Queue E C
![Page 169: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/169.jpg)
Breadth-first search
A B
D E
C
F
Queue E C
![Page 170: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/170.jpg)
Breadth-first search
A B
D E
C
F
Queue C
B
![Page 171: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/171.jpg)
Breadth-first search
A B
D E
C
F
Queue C D F
B
![Page 172: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/172.jpg)
Breadth-first search
A B
D E
C
F
Queue C D F
B
![Page 173: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/173.jpg)
Breadth-first search
A B
D E
C
F
Queue D F
B
E
![Page 174: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/174.jpg)
Breadth-first search
A B
D E
C
F
Queue D F
B
E
![Page 175: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/175.jpg)
Breadth-first search
A B
D E
C
F
Queue F
B
E
C
![Page 176: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/176.jpg)
Breadth-first search
A B
D E
C
F
Queue F
B
E
C
![Page 177: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/177.jpg)
Breadth-first search
A B
D E
C
F
Queue
B
E
C
D
![Page 178: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/178.jpg)
Breadth-first search
A B
D E
C
F
Queue
B
E
C
D
![Page 179: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/179.jpg)
Coding Breadth-First Search
![Page 180: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/180.jpg)
CAT SAT RAT
RANMAN
MAT
CAN
![Page 181: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/181.jpg)
CAT SAT RAT
RANMAN
MAT
CAN
![Page 182: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/182.jpg)
CAT SAT RAT
RANMAN
MAT
CAN
![Page 183: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/183.jpg)
CAT SAT RAT
RANMAN
MAT
CAN
![Page 184: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/184.jpg)
CAT SAT RAT
RANMAN
MAT
CAN
![Page 185: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/185.jpg)
CAT
RANCAN
![Page 186: Graphs - Stanford University · 2013-08-06 · Final Final: Monday, August 12th, 7-10pm Location: Cubberly Auditorium Cumulative (but weighted towards post midterm material) Covers](https://reader030.vdocuments.mx/reader030/viewer/2022041119/5f320bc547e87c0cc854edc9/html5/thumbnails/186.jpg)
Next Time
● Shortest Paths● Dijkstra's Algorithm.● A* Search.