Save this video free

Negative-length shortest paths and all-pairs shortest paths

Kent Quanrud · 1:16:14 · Watch on YouTube

Part of Purdue University Fundamental Algorithms (Fall 2026). See all 20 lectures and search them

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

Kent Quanrud develops a dynamic-programming approach to shortest paths with negative edge lengths, first bounding walks by their number of edges and then using the resulting Bellman–Ford-style relaxation to identify negative-infinity distances. For all-pairs shortest paths, he compares a doubling-based recurrence running in O(n³ log n) with Floyd–Warshall’s O(n³) recurrence, and previews Johnson’s algorithm as a way to handle negative edges more efficiently.

Key takeaways

Chapters

0:00 Why Dijkstra’s Distance Ordering Fails with Negative Edges
4:20 Negative Cycles Make Walk Distances Unbounded
7:17 Finite Shortest-Walk Distances Are Attained by Paths
15:20 Why Repeatedly Revisiting Improved Vertices Can Be Slow
23:24 Bounded-Edge Walks Provide a Progress Measure
28:48 The Bellman–Ford-Style Relaxation Recurrence
34:41 Running Time and the n−1-Edge Bound
38:56 Detecting Negative-Infinity Distances on Round n
43:02 Improvements Propagate Along Outgoing Edges
49:30 Reachability Marks Every Negative-Infinity Destination
53:12 Extending Single-Source Relaxation to All Pairs
55:08 All-Pairs Dynamic Programming with Bounded Edge Counts
58:14 Doubling the Edge Limit to Reduce Recurrence Rounds
1:03:03 Floyd–Warshall: Restricting Intermediate Vertices
1:08:00 Floyd–Warshall’s O(n³) Recurrence and Johnson Preview

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:00 All right. Okay. So, another graph lecture uh negative edge lengths and and all paired shortest paths. So, we've been doing graphs uh for the last couple of lectures. So, a week ago we did and I guess you've now looked at it for your homework. We did kind of first search and strongly connected components, topological sort, things like this. Uh, one thing to note, you haven't had a chance to do it in PSO yet. So that hopefully will help because right now you're in slight no man's land with the homework because you haven't done the PSO yet. So hopefully that'll be helpful tomorrow. Um, but any case, so we did uh strongly connected component desk first search and last time we did kind of shortest path type problems. The simplest example is kind of unweighted

0:49 where you can just do breast first search and something implicitly similar also works for weighted graphs. You know, something like Dyer's algorithm isn't really constructing the layers by distance, but still working in terms of closest to furthest from S. And if you remember, that's how we actually prove it's correct. If you get the first five vertices right, then you can get the sixth one right, and then you can get the seventh one right. And that's kind of important for trying to clearly articulate why it's correct. Okay, so today, what are we doing today? Today we're dealing with uh with negative edges. Okay, so there are some negative numbers in this graph and and otherwise uh you're just trying to get from s to t and you want to add things up to be as small as possible which could be a negative number. Um and uh yeah, for

1:39 this graph I always forget the answer to

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

In this course

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Kent Quanrud.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.