shortest paths
play

Shortest Paths Eric Price UT Austin CS 331, Spring 2020 - PowerPoint PPT Presentation

Shortest Paths Eric Price UT Austin CS 331, Spring 2020 Coronavirus Edition CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24 Talk Outline Logistics 1 Shortest Paths: Bellman-Ford 2 Dijkstras Algorithm 3 CS 331, Spring


  1. Shortest Paths Eric Price UT Austin CS 331, Spring 2020 Coronavirus Edition CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  2. Talk Outline Logistics 1 Shortest Paths: Bellman-Ford 2 Dijkstra’s Algorithm 3 CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  3. Talk Outline Logistics 1 Shortest Paths: Bellman-Ford 2 Dijkstra’s Algorithm 3 CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  4. Welcome to 331 online! I’ll be experimenting with different teaching methods. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  5. Welcome to 331 online! I’ll be experimenting with different teaching methods. ◮ Bear with me. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  6. Welcome to 331 online! I’ll be experimenting with different teaching methods. ◮ Bear with me. ◮ Give feedback! CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  7. Welcome to 331 online! I’ll be experimenting with different teaching methods. ◮ Bear with me. ◮ Give feedback! Stay healthy CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  8. Welcome to 331 online! I’ll be experimenting with different teaching methods. ◮ Bear with me. ◮ Give feedback! Stay healthy ◮ Let me know if you’re sick & need extra time. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  9. Welcome to 331 online! I’ll be experimenting with different teaching methods. ◮ Bear with me. ◮ Give feedback! Stay healthy ◮ Let me know if you’re sick & need extra time. ◮ Please wear a mask if you interact with others. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  10. Welcome to 331 online! I’ll be experimenting with different teaching methods. ◮ Bear with me. ◮ Give feedback! Stay healthy ◮ Let me know if you’re sick & need extra time. ◮ Please wear a mask if you interact with others. Second exam will be take-home CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  11. Welcome to 331 online! I’ll be experimenting with different teaching methods. ◮ Bear with me. ◮ Give feedback! Stay healthy ◮ Let me know if you’re sick & need extra time. ◮ Please wear a mask if you interact with others. Second exam will be take-home ◮ Given out after class on April 8. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  12. Welcome to 331 online! I’ll be experimenting with different teaching methods. ◮ Bear with me. ◮ Give feedback! Stay healthy ◮ Let me know if you’re sick & need extra time. ◮ Please wear a mask if you interact with others. Second exam will be take-home ◮ Given out after class on April 8. ◮ Return before 10am on Friday, April 10. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  13. Zoom details Mute your audio unless you have a question. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  14. Zoom details Mute your audio unless you have a question. I encourage sharing your video ◮ Makes this seem more like a community CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  15. Zoom details Mute your audio unless you have a question. I encourage sharing your video ◮ Makes this seem more like a community You can “raise your hand” so I know to call on you. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  16. Zoom details Mute your audio unless you have a question. I encourage sharing your video ◮ Makes this seem more like a community You can “raise your hand” so I know to call on you. ◮ Press “View Participants”, then the little blue hand. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  17. Zoom details Mute your audio unless you have a question. I encourage sharing your video ◮ Makes this seem more like a community You can “raise your hand” so I know to call on you. ◮ Press “View Participants”, then the little blue hand. Videos will be recorded & available after class. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  18. Talk Outline Logistics 1 Shortest Paths: Bellman-Ford 2 Dijkstra’s Algorithm 3 CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  19. Single-Source Shortest Paths Problem setup: CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  20. Single-Source Shortest Paths Problem setup: ◮ Given a directed graph G = ( V , E ) CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  21. Single-Source Shortest Paths Problem setup: ◮ Given a directed graph G = ( V , E ) ◮ Each edge u → v has distance : w ( u → v ) ∈ R CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  22. Single-Source Shortest Paths Problem setup: ◮ Given a directed graph G = ( V , E ) ◮ Each edge u → v has distance : w ( u → v ) ∈ R ◮ Distance of path is sum of distance of edges. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  23. Single-Source Shortest Paths Problem setup: ◮ Given a directed graph G = ( V , E ) ◮ Each edge u → v has distance : w ( u → v ) ∈ R ◮ Distance of path is sum of distance of edges. ◮ Given a source s CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  24. Single-Source Shortest Paths Problem setup: ◮ Given a directed graph G = ( V , E ) ◮ Each edge u → v has distance : w ( u → v ) ∈ R ◮ Distance of path is sum of distance of edges. ◮ Given a source s Goal: for every v , compute c ∗ ( v ), the distance of shortest s � v path in G . CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  25. Single-Source Shortest Paths Problem setup: ◮ Given a directed graph G = ( V , E ) ◮ Each edge u → v has distance : w ( u → v ) ∈ R ◮ Distance of path is sum of distance of edges. ◮ Given a source s Goal: for every v , compute c ∗ ( v ), the distance of shortest s � v path in G . Output two arrays: dist() and pred(). CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  26. Single-Source Shortest Paths Problem setup: ◮ Given a directed graph G = ( V , E ) ◮ Each edge u → v has distance : w ( u → v ) ∈ R ◮ Distance of path is sum of distance of edges. ◮ Given a source s Goal: for every v , compute c ∗ ( v ), the distance of shortest s � v path in G . Output two arrays: dist() and pred(). ◮ dist( v ) = c ∗ ( v ) for all v CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  27. Single-Source Shortest Paths Problem setup: ◮ Given a directed graph G = ( V , E ) ◮ Each edge u → v has distance : w ( u → v ) ∈ R ◮ Distance of path is sum of distance of edges. ◮ Given a source s Goal: for every v , compute c ∗ ( v ), the distance of shortest s � v path in G . Output two arrays: dist() and pred(). ◮ dist( v ) = c ∗ ( v ) for all v ◮ pred( s ) = None CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  28. Single-Source Shortest Paths Problem setup: ◮ Given a directed graph G = ( V , E ) ◮ Each edge u → v has distance : w ( u → v ) ∈ R ◮ Distance of path is sum of distance of edges. ◮ Given a source s Goal: for every v , compute c ∗ ( v ), the distance of shortest s � v path in G . Output two arrays: dist() and pred(). ◮ dist( v ) = c ∗ ( v ) for all v ◮ pred( s ) = None ◮ v ← pred( v ) ← pred(pred( v )) ← · · · ← s is shortest s � v path. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  29. Single-Source Shortest Paths Problem setup: ◮ Given a directed graph G = ( V , E ) ◮ Each edge u → v has distance : w ( u → v ) ∈ R ◮ Distance of path is sum of distance of edges. ◮ Given a source s Goal: for every v , compute c ∗ ( v ), the distance of shortest s � v path in G . Output two arrays: dist() and pred(). ◮ dist( v ) = c ∗ ( v ) for all v ◮ pred( s ) = None ◮ v ← pred( v ) ← pred(pred( v )) ← · · · ← s is shortest s � v path. Question: what if w ( u → v ) = 1 for all u → v ∈ E ? CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  30. Generic SSSP algorithm We maintain a vector dist that satisfies the invariant: dist( v ) ≥ c ∗ ( v ) for all v at all times. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  31. Generic SSSP algorithm We maintain a vector dist that satisfies the invariant: dist( v ) ≥ c ∗ ( v ) for all v at all times. InitializeSSSP (s): ◮ dist( v ) = ∞ ∀ v ◮ pred( v ) = None ∀ v ◮ dist( s ) = 0. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  32. Generic SSSP algorithm We maintain a vector dist that satisfies the invariant: dist( v ) ≥ c ∗ ( v ) for all v at all times. InitializeSSSP (s): ◮ dist( v ) = ∞ ∀ v ◮ pred( v ) = None ∀ v ◮ dist( s ) = 0. FordSSSP (s): ◮ InitializeSSSP (s) ◮ Repeat: ⋆ Pick an edge ⋆ If it is “tense”, relax it. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  33. Relaxing an edge Relax ( u → v ): ◮ If dist( v ) > dist( u ) + w ( u → v ): ⋆ dist( v ) ← dist( u ) + w ( u → v ) ⋆ pred( v ) ← u . Triangle Inequality For any edge u → v , c ∗ ( v ) ≤ c ∗ ( u ) + w ( u → v ) . Lemma If dist ( v ) ≥ c ∗ ( v ) for all v, then for any edge u → v, c ∗ ( v ) ≤ dist ( u ) + w ( u → v ) . Hence Relax preserves the invariant that dist ( v ) ≥ c ∗ ( v ) ∀ v. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

  34. Generic SSSP algorithm Invariant: dist( v ) ≥ c ∗ ( v ) for all v at all times. CS 331, Spring Eric Price (UT Austin) Shortest Paths / 24

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend