← Latest papers
💻 computer science

O~\tilde{O}ptimal Algorithm for 2-Approximate All Pair Shortest Paths -- almost

This paper presents a randomized algorithm combining combinatorial techniques with fast matrix multiplication to compute a 2-approximation of all-pairs shortest paths in undirected, unweighted graphs in O~(n2)\tilde{O}(n^2) time, guaranteeing accuracy for all pairs at distance at least a constant c0c \ge 0.

Original authors: Manoj Gupta, Mrigankashekhar Shandilya

Published 2026-07-22
📖 7 min read🧠 Deep dive

Original authors: Manoj Gupta, Mrigankashekhar Shandilya

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are a delivery driver in a massive, sprawling city where every street is exactly the same length. Your job is to figure out the quickest route between every possible pair of addresses in the city. If the city has a million houses, that's a trillion different routes to calculate. In the world of computer science, this is called the "All-Pairs Shortest Path" problem. It's the digital equivalent of trying to map every single shortcut in a labyrinth.

For decades, computers have been great at finding these routes, but there's a catch: the more accurate the map, the longer it takes to draw. If you want the perfect route, the computer might have to work so hard it takes forever, especially in huge cities. But what if you're okay with a route that is "good enough"—say, no more than twice as long as the absolute best path? This is called a "2-approximation." It's like telling a driver, "Don't worry about finding the single perfect shortcut; just give me a route that won't make you late by more than a factor of two." The big question for scientists has been: Can we draw this "good enough" map for a whole city of a million houses almost as fast as it takes to just write down the list of all the houses?

This paper, written by Manoj Gupta and Mrigankashekhar Shandilya, tackles that exact challenge. They have designed a new, clever method to create these "good enough" maps for almost every pair of locations in a city, and they do it with a speed that is nearly as fast as theoretically possible.

The Problem: The Trillion-Route Nightmare

Let's say you have a graph, which is just a fancy word for a network of dots (vertices) connected by lines (edges). Think of the dots as people at a party and the lines as friendships. If you want to know the shortest chain of introductions between any two people, that's a shortest path.

If the party is small, you can just ask everyone. But if the party has nn people, there are n2n^2 (n times n) pairs of people. If nn is a million, n2n^2 is a trillion. The paper notes that simply writing down the answer for every pair takes time proportional to this trillion. So, the "speed limit" for this problem is n2n^2. You can't go faster than that because you have to write down the answer.

The goal of this research is to hit that speed limit. They want an algorithm that runs in roughly n2n^2 time (specifically, O~(n2)\tilde{O}(n^2), which hides some tiny, annoying math factors) and guarantees that the route it finds is at most twice the length of the true shortest path.

The Old Ways: Guessing and Checking

Before this paper, scientists had tried to solve this. Some methods were like trying to find a needle in a haystack by checking every single piece of hay. Others were smarter but still had a blind spot.

One famous approach by Dor, Halperin, and Zwick could find these "good enough" routes very quickly, but only for people who were already far apart (at least O(logn)O(\log n) steps away). If two people were sitting right next to each other, the method might fail or be slow. A more recent improvement by Gupta (in 2025) pushed this boundary, handling people who were at least O(loglogn)O(\log \log n) steps apart. But there was still a tiny gap: what about people who are just a few steps away? The old methods couldn't guarantee the "twice as long" rule for everyone while staying super fast.

The New Idea: The "Ball" and the "Cluster"

The authors' solution is a mix of two different strategies: a careful, step-by-step combinatorial approach and a powerful mathematical trick called Fast Matrix Multiplication (FMM).

To understand their trick, imagine the party again. They pick a few random people to be "Pivots."

  1. The Ball: Around every person, they draw an invisible "ball" containing everyone who is closer to them than to their nearest Pivot.
  2. The Cluster: Conversely, a "Cluster" is the group of people whose balls contain a specific person.

The magic insight is that for most people, these "Balls" are small and manageable. If you are inside someone's Ball, you are close to them, and you can find the exact distance quickly.

The path between two people, let's call them Alice and Bob, can be broken into three parts:

  1. The Prefix: Alice walking to the edge of her Ball.
  2. The Middle: The walk from the edge of Alice's Ball to the edge of Bob's Ball.
  3. The Suffix: Bob walking from the edge of his Ball to his destination.

The authors realized that the Prefix and Suffix are easy because they happen inside these small, low-degree Balls. The tricky part is the Middle. If the Middle is short, they can just guess and check. If the Middle is long, they need a different tactic.

The Two-Pronged Attack: Sparse vs. Dense

The paper splits the problem into two scenarios based on how many people are "close" to a specific point on the path.

Scenario A: The Sparse Case (Few Neighbors)
Imagine the middle part of the path is surrounded by very few people. In this case, the algorithm simply checks every possible pair of "close" people. Because there are so few of them, this check is fast. It's like checking every possible shortcut in a quiet neighborhood; you can do it quickly because there aren't many streets.

Scenario B: The Dense Case (Many Neighbors)
Now, imagine the middle part is in a crowded city center with thousands of people nearby. Checking every single pair here would take forever. This is where the authors bring in the "Fast Matrix Multiplication" (FMM).

Think of FMM as a super-powerful calculator that can multiply huge grids of numbers almost instantly. The authors create a small, random sample of people (a "Lucky Set") from the crowd. They use the FMM calculator to check if anyone in this Lucky Set can serve as a stepping stone between Alice and Bob.

Here is the clever part: Because the middle section of the path is guaranteed to be short (a constant number of steps), and because the "Lucky Set" is chosen randomly, there is a very high probability that at least one person in the Lucky Set is standing right on that short middle path. The FMM calculator then instantly computes the distances through this lucky person, giving a "good enough" estimate for the whole trip.

The Result: A Near-Perfect Map

By combining these two strategies, the authors prove that they can find a route that is at most twice the true distance for all pairs of people who are at least a constant number of steps apart (specifically, a distance of at least cc, where cc is a constant like 906).

The paper shows that this can be done in O~(n2)\tilde{O}(n^2) time. This is a massive improvement because it means the algorithm is as fast as the theoretical limit allows (since you have to write down n2n^2 answers).

What This Means

The paper doesn't just suggest this might work; they provide a rigorous mathematical proof that their randomized algorithm works with "high probability" (meaning it works almost every time you run it).

They explicitly rule out the idea that you need to check every pair of people to get this speed. Instead, they show that by splitting the problem into "sparse" (check everything) and "dense" (use the lucky sample and math magic), you can bypass the slow parts.

While they don't claim to have solved the problem for every single pair (specifically, pairs that are extremely close, like 1 or 2 steps apart, might need a different constant), they have nearly resolved the problem for the vast majority of cases. They have bridged the gap between the old methods that worked for distant pairs and the need for a method that works for everyone, all while keeping the speed record intact.

In short, they found a way to draw a "good enough" map of a trillion-route city in the time it takes to list the city's population, using a mix of careful walking and a super-calculator to skip the boring parts.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →