Week 12 - Monday.  What did we talk about last time?  Topological sort and cycle detection in directed graphs  Connectivity  Strong connectivity.

Slides:



Advertisements
Similar presentations
1 Dijkstra’s Minimum-Path Algorithm Minimum Spanning Tree CSE Lectures 20 – Intro to Graphs.
Advertisements

1 Graphs: Traversal Searching/Traversing a graph = visiting the vertices of a graph by following the edges in a systematic way Example: Given a highway.
1 Greedy 2 Jose Rolim University of Geneva. Algorithmique Greedy 2Jose Rolim2 Examples Greedy  Minimum Spanning Trees  Shortest Paths Dijkstra.
CPSC 411, Fall 2008: Set 9 1 CPSC 411 Design and Analysis of Algorithms Set 9: More Graph Algorithms Prof. Jennifer Welch Fall 2008.
Minimum Spanning Tree Algorithms
Lecture 19: Shortest Paths Shang-Hua Teng. Weighted Directed Graphs Weight on edges for distance
Minimum Spanning Trees Definition Algorithms –Prim –Kruskal Proofs of correctness.
Data Structures Heaps and Graphs i206 Fall 2010 John Chuang Some slides adapted from Marti Hearst, Brian Hayes, or Glenn Brookshear.
Shortest Paths Definitions Single Source Algorithms –Bellman Ford –DAG shortest path algorithm –Dijkstra All Pairs Algorithms –Using Single Source Algorithms.
Graph Algorithms: Shortest Path We are given a weighted, directed graph G = (V, E), with weight function w: E R mapping.
Shortest Paths Definitions Single Source Algorithms
CSE 780 Algorithms Advanced Algorithms SSSP Dijkstra’s algorithm SSSP in DAGs.
Nondecreasing Paths in Weighted Graphs Or: How to optimally read a train schedule Virginia Vassilevska.
All-Pairs Shortest Paths
More Graph Algorithms Weiss ch Exercise: MST idea from yesterday Alternative minimum spanning tree algorithm idea Idea: Look at smallest edge not.
Dijkstra’s Algorithm Slide Courtesy: Uwash, UT 1.
Graphs & Graph Algorithms 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Minimum Spanning Trees Longin Jan Latecki Temple University based on slides by David Matuszek, UPenn, Rose Hoberman, CMU, Bing Liu, U. of Illinois, Boting.
1 Minimum Spanning Trees Longin Jan Latecki Temple University based on slides by David Matuszek, UPenn, Rose Hoberman, CMU, Bing Liu, U. of Illinois, Boting.
Dijkstra's algorithm.
Week 11 - Friday.  What did we talk about last time?  Exam 2 post mortem  Cycle detection  Connectivity.
Shortest Path Algorithms. Kruskal’s Algorithm We construct a set of edges A satisfying the following invariant:  A is a subset of some MST We start with.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
CS112A1 Spring 2008 Practice Final. ASYMPTOTIC NOTATION: a)Show that log(n) and ln(n) are the same in terms of Big-Theta notation b)Show that log(n+1)
Graphs CS 400/600 – Data Structures. Graphs2 Graphs  Used to represent all kinds of problems Networks and routing State diagrams Flow and capacity.
1 GRAPHS - ADVANCED APPLICATIONS Minimim Spanning Trees Shortest Path Transitive Closure.
1 Shortest Path Algorithms Andreas Klappenecker [based on slides by Prof. Welch]
Week -7-8 Topic - Graph Algorithms CSE – 5311 Prepared by:- Sushruth Puttaswamy Lekhendro Lisham.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Dijkstras Algorithm Named after its discoverer, Dutch computer scientist Edsger Dijkstra, is an algorithm that solves the single-source shortest path problem.
Graph (II) Shortest path, Minimum spanning tree GGuy
0 Course Outline n Introduction and Algorithm Analysis (Ch. 2) n Hash Tables: dictionary data structure (Ch. 5) n Heaps: priority queue data structures.
Algorithm Course Dr. Aref Rashad February Algorithms Course..... Dr. Aref Rashad Part: 5 Graph Algorithms.
Dijkstra’s Algorithm Supervisor: Dr.Franek Ritu Kamboj
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Most of contents are provided by the website Graph Essentials TJTSD66: Advanced Topics in Social Media.
CSC 213 – Large Scale Programming. Today’s Goals  Discuss what is meant by weighted graphs  Where weights placed within Graph  How to use Graph ’s.
Week 12 - Wednesday.  What did we talk about last time?  Matching  Stable marriage  Started Euler paths.
Data Structures & Algorithms Shortest Paths Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
Runtime O(VE), for +/- edges, Detects existence of neg. loops
Week 15 – Friday.  What did we talk about last time?  Student questions  Review up to Exam 2  Recursion  Binary trees  Heaps  Tries  B-trees.
Week 11 - Friday.  What did we talk about last time?  Exam 2 post mortem  Cycle detection in undirected graphs  Topological sort and cycle detection.
CSCE 411 Design and Analysis of Algorithms Set 9: More Graph Algorithms Prof. Jennifer Welch Spring 2012 CSCE 411, Spring 2012: Set 9 1.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
Week 11 - Wednesday.  What did we talk about last time?  Exam 2  And before that:  Graph representations  Depth first search.
CSE 326: Data Structures Lecture #23 Dijkstra and Kruskal (sittin’ in a graph) Steve Wolfman Winter Quarter 2000.
CSE 373: Data Structures and Algorithms Lecture 21: Graphs V 1.
Shortest Path -Prim’s -Djikstra’s. PRIM’s - Minimum Spanning Tree -A spanning tree of a graph is a tree that has all the vertices of the graph connected.
Week 7 - Monday CS 113.
Chapter 9 : Graphs Part II (Minimum Spanning Trees)
Algorithms and Data Structures Lecture XIII
Minimum Spanning Tree Shortest Paths
Comp 245 Data Structures Graphs.
i206: Lecture 14: Heaps, Graphs intro.
Minimum Spanning Tree.
Graphs & Graph Algorithms 2
CSE373: Data Structures & Algorithms Lecture 12: Minimum Spanning Trees Catie Baker Spring 2015.
CSE373: Data Structures & Algorithms Lecture 20: Minimum Spanning Trees Linda Shapiro Spring 2016.
Minimum Spanning Trees
Algorithms (2IL15) – Lecture 5 SINGLE-SOURCE SHORTEST PATHS
Outline This topic covers Prim’s algorithm:
Algorithms and Data Structures Lecture XIII
Yan Shi CS/SE 2630 Lecture Notes
Minimum Spanning Tree Algorithms
CSE332: Data Abstractions Lecture 18: Minimum Spanning Trees
Minimum Spanning Trees
Minimum spanning tree Shortest path algorithms
CSE 417: Algorithms and Computational Complexity
Implementation of Dijkstra’s Algorithm
Topological Sorting Minimum Spanning Trees Shortest Path
Presentation transcript:

Week 12 - Monday

 What did we talk about last time?  Topological sort and cycle detection in directed graphs  Connectivity  Strong connectivity

Student Lecture

 An airline has to stop running direct flights between some cities  But, it still wants to be able to reach all the cities that it can now  What’s the set of flights with the lowest total cost that will keep all cities connected?  Essentially, what’s the lowest cost tree that keeps the graph connected?

 This tree is called the minimum spanning tree or MST  It has countless applications in graph problems  How do we find such a thing?

1. Start with two sets, S and V:  S has the starting node in it  V has everything else 2. Find the node u in V that is closest to any node in S 3. Put the edge to u into the MST 4. Move u from V to S 5. If V is not empty, go back to Step 2

A C G E B F D

 Naïve implementation with an adjacency matrix  O(|V| 2 )  Adjacency lists with binary heap  O(|E| log |V|)  Adjacency lists with Fibonacci heap  O(|E| + |V| log |V|)

A L I F B E G C J H K D

 How does Google Maps find the shortest route from California to Elizabethtown?  Graph theory, of course!  It stores a very large graph where locations are nodes and streets (well, parts of streets) are edges

 We use a weighted graph  Weight can represent time, distance, cost: anything, really  The shortest path (lowest total weight) is not always obvious

 Take a moment and try to find the shortest path from A to E.  The shortest path has cost A A B B D D C C E E A B C D E

 On a graph of that size, it isn’t hard to find the shortest path  A Google Maps graph has millions and millions of nodes  How can we come up with an algorithm that will always find the shortest path from one node to another?

 In 1959, Edsger Dijkstra invented an algorithm to find shortest paths  First, a little notation: NotationMeaning sStarting node d(v)d(v) The best distance from s to v found so far d(u, v) The direct distance between nodes u and v S A set which contains the nodes for which we know the shortest path from s V A set which contains the nodes for which we do not yet know the shortest path from s

1. Start with two sets, S and V:  S is empty  V has all the nodes in it 2. Set the distance to all nodes in V to ∞ 3. Set the distance to the starting node s to 0 4. Find the node u in V that is closest to s 5. For every neighbor v of u in V ▪ If d(v) > d(u) + d(u,v) ▪ Set d(v) = d(u) + d(u,v) 6. Move u from V to S 7. If V is not empty, go back to Step 4

Noded(u)d(u) A0 B5 C8 D∞ E16 Noded(u)d(u) A0 B5 C7 D11 E16 Noded(u)d(u) A0 B5 C7 D10 E16 Noded(u)d(u) A0 B5 C7 D10 E14 Noded(u)d(u) A0 B5 C7 D10 E14 Noded(u)d(u) A0 B∞ C∞ D∞ E∞ A A B B D D C C E E Sets SV AB, C, D, E Sets SV A, BC, D, E Sets SV A, B, CD, E Sets SV A, B, C, DE Sets SV A, B, C, D, E Finding the shortest distance from A to all other nodes Sets SV A, B, C, D, E A A

 Always gets the next closest node, so we know there isn’t a better way to get there  Finds the shortest path from a starting node to all other nodes  Works even for directed graphs

 The normal running time for Dijkstra's is O(|V| 2 )  At worst, we may have to update each node in V for each node V that we find the shortest path to  A special data structure called a min-priority queue can implement the process of updating priorities faster  Total running time of O(|E| + |V| log |V|)  Technically faster for sparse graphs  Algorithm wizards Fredman and Tarjan created an implementation called a Fibonacci Heap ▪ Actually slow in practice

A L I F B E G C J H K D

 The algorithms have very similar forms  Here is a graph for which the shortest path tree from A to all other nodes is not an MST A B C D

 Matching on bipartite graphs  Stable marriage  Euler tours

 Start on Project 4  Form teams by Friday  Start on Assignment 6