Cpt S 223. School of EECS, WSU



Similar documents
Problem Set 7 Solutions

Social Media Mining. Graph Essentials

A Review And Evaluations Of Shortest Path Algorithms

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) Total 92.

Data Structures and Algorithms Written Examination

Load balancing Static Load Balancing

Load Balancing and Termination Detection

Approximation Algorithms

Analysis of Algorithms, I

2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]

Load Balancing and Termination Detection

WAN Wide Area Networks. Packet Switch Operation. Packet Switches. COMP476 Networked Computer Systems. WANs are made of store and forward switches.

Load Balancing and Termination Detection

Lecture 8: Routing I Distance-vector Algorithms. CSE 123: Computer Networks Stefan Savage

Chapter 7 Load Balancing and Termination Detection

Home Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit

Exam study sheet for CS2711. List of topics

Part 2: Community Detection

Minimum cost maximum flow, Minimum cost circulation, Cost/Capacity scaling

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

CS Computer Networks 1: Routing Algorithms

Applied Algorithm Design Lecture 5

Chapter 6: Graph Theory

Why? A central concept in Computer Science. Algorithms are ubiquitous.

6 March Array Implementation of Binary Trees

International Journal of Software and Web Sciences (IJSWS)

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

Routing in packet-switching networks

Incremental Routing Algorithms For Dynamic Transportation Networks

2.8 An application of Dynamic Programming to machine renewal

B AB 5 C AC 3 D ABGED 9 E ABGE 7 F ABGEF 8 G ABG 6 A BEDA 3 C BC 1 D BCD 2 E BE 1 F BEF 2 G BG 1

Graph Theory Problems and Solutions

A New Approach to Dynamic All Pairs Shortest Paths

Warshall s Algorithm: Transitive Closure

CMPSCI611: Approximating MAX-CUT Lecture 20

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm.

CAB TRAVEL TIME PREDICTI - BASED ON HISTORICAL TRIP OBSERVATION

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. !-approximation algorithm.

Internet Firewall CSIS Packet Filtering. Internet Firewall. Examples. Spring 2011 CSIS net15 1. Routers can implement packet filtering

Network Design with Coverage Costs

CS311H. Prof: Peter Stone. Department of Computer Science The University of Texas at Austin

Bicolored Shortest Paths in Graphs with Applications to Network Overlay Design

AI: A Modern Approach, Chpts. 3-4 Russell and Norvig

Cpt S 223. School of EECS, WSU

Network (Tree) Topology Inference Based on Prüfer Sequence

Introduction to LAN/WAN. Network Layer

International Journal of Advanced Research in Computer Science and Software Engineering

Lecture 12: Link-state Routing"

1. Write the number of the left-hand item next to the item on the right that corresponds to it.

Linear Programming. March 14, 2014

Graph Theory Algorithms for Mobile Ad Hoc Networks

Any two nodes which are connected by an edge in a graph are called adjacent node.

Data Structures. Chapter 8

6.02 Practice Problems: Routing

A Practical Scheme for Wireless Network Operation

Dynamic programming. Doctoral course Optimization on graphs - Lecture 4.1. Giovanni Righini. January 17 th, 2013

Lecture 2.1 : The Distributed Bellman-Ford Algorithm. Lecture 2.2 : The Destination Sequenced Distance Vector (DSDV) protocol

Introduction to Metropolitan Area Networks and Wide Area Networks

Graph Theory Topics in Computer Networking

Dynamic programming. Chapter Shortest paths in dags, revisited S C A B D E

Near Optimal Solutions

Systems and Algorithms for Big Data Analytics

Strong and Weak Ties

An Efficient Primary-Segmented Backup Scheme for Dependable Real-Time Communication in Multihop Networks

Midterm Practice Problems

IE 680 Special Topics in Production Systems: Networks, Routing and Logistics*

Linear Programming. April 12, 2005

Chapter Load Balancing. Approximation Algorithms. Load Balancing. Load Balancing on 2 Machines. Load Balancing: Greedy Scheduling

Dynamic Programming 11.1 AN ELEMENTARY EXAMPLE

5.1 Midsegment Theorem and Coordinate Proof

Closest Pair Problem

3 Distance in Graphs. Brief outline of this lecture

The Goldberg Rao Algorithm for the Maximum Flow Problem

The number of marks is given in brackets [ ] at the end of each question or part question. The total number of marks for this paper is 72.

Cloud Enabled Emergency Navigation Using Faster-than-real-time Simulation

SCAN: A Structural Clustering Algorithm for Networks

Binary Heaps. CSE 373 Data Structures

Algorithm Design and Analysis

COMBINATORIAL PROPERTIES OF THE HIGMAN-SIMS GRAPH. 1. Introduction

Internet Control Message Protocol (ICMP)

Seminar. Path planning using Voronoi diagrams and B-Splines. Stefano Martina

CS335 Sample Questions for Exam #2

CSE 4351/5351 Notes 7: Task Scheduling & Load Balancing

DATA ANALYSIS II. Matrix Algorithms

8.1 Min Degree Spanning Tree

Discrete Mathematics & Mathematical Reasoning Chapter 10: Graphs

B490 Mining the Big Data. 2 Clustering

Simple Graphs Degrees, Isomorphism, Paths

Analysis of Micromouse Maze Solving Algorithms

Handout #Ch7 San Skulrattanakulchai Gustavus Adolphus College Dec 6, Chapter 7: Digraphs

Transcription:

The Shortest Path Problem 1

Shortest-Path Algorithms Find the shortest path from point A to point B Shortest in time, distance, cost, Numerous applications Map navigation Flight itineraries Circuit wiring Network routing 2

Shortest Path Problems Weighted graphs: Input is a weighted graph where each edge (v i,v j ) has cost c i,j to traverse the edge N 1 c i Cost of a path v 1 v 2 v N is, i 1 i 1 Goal: to find a smallest cost path Unweighted graphs: Input is an unweighted graph i.e., all edges are of equal weight Goal: to find a path Cpt S 223. with School smallest of EECS, WSUnumber of hops 3

Shortest Path Problems Single-source shortest path problem Given a weighted graph G=(V,E), and a source vertex s, find the minimum weighted path from s to every other vertex in G Some algorithms: Weighted: Dijkstra s algo s: source Unweighted: Simple BFS 4

Point to Point SP problem Given G(V,E) and two vertices A and B, find a shortest path from A (source) to B (destination). Solution: 1) Run the code for Single Source Shortest Path using source as A. 2) Stop algorithm when B is reached. 5

All Pairs Shortest Path Problem Given G(V,E), find a shortest path between all pairs of vertices. Solutions: (brute-force) Solve Single Source Shortest Path for each vertex as source There are more efficient ways of solving this problem (e.g., Floyd-Warshall algo). 6

Negative Weights Graphs can have negative weights E.g., arbitrage Shortest positive-weight path is a net gain Path may include individual losses Problem: Negative weight cycles Allow arbitrarily-low low path costs Solution Detect presence of negative-weight g cycles 7

Unweighted Shortest Paths No weights on edges Find shortest length paths Same as weighted shortest path with all weights equal Breadth-first search 1 2 O( E + V ) source 0 2 3 1 3 8

Unweighted Shortest Paths For each vertex, keep track of Whether we have visited it (known) Its distance from the start vertex (d v ) Its predecessor vertex along the shortest path from the start vertex (p v ) 9

Unweighted Shortest Paths Solution 1: Repeatedly iterate through vertices, looking for unvisited vertices at current distance from start vertex s. Running time: O( V 2 ) 10

Unweighted Shortest Paths Solution: Ignore vertices that have already been visited by keeping only unvisited vertices (distance = ) on the queue. Running time: O( E + V ) source Queue: v 3 v 1, v 6 v 2, v 4 v 7, v 5 11

Unweighted Shortest Paths 12

Weighted Shortest Paths Dijkstra s algorithm GREEDY strategy: Always pick the next closest vertex to the source Use priority queue to store unvisited vertices by distance from s After deletemin v, update distances of remaining vertices adjacent to v using decreasekey Does not work with negative weights 13

Dijkstra s Algorithm 14

source Dijkstra 15

BuildHeap: O( V ) DeleteMin: O( V log V ) DecreaseKey: O( E log V ) Total running time: O( E log V ) 16

Why Dijkstra Works 100 A D 20 10 Hypothesis 100 100 This is called the Optimal Substructure property Aleast-cost path from X to Y contains least-cost paths from X to every city on the path to Y E.g., if X C1 C2 C3 Y is the least-cost path from X to Y, then B C 10 X C1 C2 C3 is the least-cost path from X to C3 X C1 C2 is the least-cost path from X to C2 X C1 is the least-cost path from X to C1 17

Why Dijkstra Works PROOF BY CONTRADICTION: Assume hypothesis is false I.e., Given a least-cost path P from X to Y that goes through C, there is a better path P from X to C than the one in P Show a contradiction adcto But we could replace the subpath from X to C in P with this lesser-cost path P The path cost from C to Y is the same Thus we now have a better path from X to Y But this violates the assumption that P is the least-cost path from X to Y Therefore, the original hypothesis must be true X P C Y 18

Printing Shortest Paths 19

What about graphs with negative edges? Will the O( E log V ) Dijkstra s algorithm work as is? deletemin Updates to dist source 3 v 2 v 1 1 2 V 1 V 2.dist = 3 V 2 V 4.dist = 4, V 3.dist = 5 V 4 No change V No change and so v dist will remain 4. V 3 No change and so v 4. dist will v 4 v -10 3 Solution: Do not mark any vertex as known. Instead allow multiple updates. Correct answer: v 4.dist should be updated to -5 20

Negative Edge Costs Running time: O( E V ) source v 1 3 1 v 2 2 v4-10 v 3 Queue V 1 V 2 V 4, V 3 V 3 V 4 Dequeue V 1 V 2 V 4 V 3 V 4 Updates to dist V 2.dist = 3 V 4.dist = 4, V 3.dist = 5 No updates V 4.dist = -5 No updates 21

Negative Edge Costs Running time: O( E V ) Negative weight cycles? 22

Shortest Path Problems Unweighted shortest-path problem: O( E + V ) Weighted shortest-path problem No negative edges: O( E log V ) Negative edges: O( E V ) Acyclic graphs: O( E + V ) No asymptotically faster algorithm for singlesource/single-destination shortest path problem 23

Course Evaluation Site in now Open! http://skylight.wsu.edu/s/053eadf6-6157-44ce- 92ad-cbc26bde3b53.srv 24