Poly-time sublinear-space connectivity
Adapted from a talk by Prasanna Ramakrishnan at Stanford’s teach-us-anything seminar.
You probably know the drill about
- DFS/BFS gets you
,1 - Savitch’s gets you
.
Can you get the best of both worlds? Some believe
Idea
Pras claims that if you’re given one week and the hint “find something in the middle of BFS and Savitch’s”, you could come up with it. I doubt I could.
The idea is to split the problem into two parts:
- one BFS-like part that “splits the path from
to into segments of length ”; - one Savitch-like part that can check whether two nodes are at distance
(as long as is small).
The BFS-like part makes a lot of concessions in time in order to cut space. The Savitch-like part makes a lot of concessions in space in order to cut time.
BFS-like part: cut it up
BFS requires a lot of space to store all the “equidistance shells”: for each
How do you compute
- it’s at distance exactly
from ; - it’s not in any of the earlier shells
.
The first part is easy to check using two small-distance queries from each
Overall, we only make a polynomial number of queries, and we need
This means that to get poly-time sublinear-space connectivity, we need
; ; .
Savitch-like part
Let’s figure what time-space trade-off we can get from Savitch assuming
But really, out-of-the-box Savitch’s cares way too much about optimizing space. We only want sublinear space (we have this annoying
The trick is to reduce Savitch’s branching factor at the expense of space. Instead of choosing a specific middle vertex among all
The specification of one recursion of Savitch’s then becomes:
: returns a vector representing which nodes from collection are reachable within distance from at least one of the nodes in collection that are indicated by a in .
To solve this recursive problem, first initialize
- make a recursive call to find out the vector
of each possible node in collection that is reachable within distance from at least one of the nodes in collection indicated by ; - make a second recursive call to find out the vector
of each possible node in collection that is reachable within distance from at least one of the nodes in collection indicated by ; - set
(component-wise).
Overall, there are
Choosing parameters
Let’s ignore the
The log factors in the right-hand side are probably not going to be very different, so a reasonable first step is to equalize the denominators by setting
Then, it only remains to solve for