Divide By Sixty Four

Transitive closure of a digraph with n=2000n = 2000 vertices, one second. Floyd-Warshall is Θ(n3)=8⋅109\Theta(n^3) = 8 \cdot 10^9. What saves you?

A

One bitset row per vertex: the inner loop becomes a single word-parallel OR, giving O(n3/w)O(n^3/w) with w=8w = 8, about 1.0⋅1091.0 \cdot 10^9 word operations.

B

One bitset row per vertex: the inner loop becomes a single word-parallel OR, giving O(n3/w)O(n^3/w) with w=64w = 64, about 1.3⋅1081.3 \cdot 10^8 word operations.

C

One char row per vertex: the inner loop becomes a single byte compare, giving O(n3)O(n^3) with the whole matrix in cache, about 8⋅1098 \cdot 10^9 byte operations.

D

One Kosaraju condensation per graph: the inner loop becomes a single DAG traversal, giving O(n+m)O(n + m) with w=64w = 64, about 4⋅1064 \cdot 10^6 edge operations.