Finding Successor
Since each node of a successor graph has a unique successor, we can also define a function succ(x, k) that gives the node that we will reach if we begin at node x and walk k steps forward. For example, in our example graph succ(4, 6) = 2, because we will reach node 2 by walking 6 steps from node 4 (Fig. 33).
![]() |
|---|
| Fig. 33: Walking in a successor graph |
A straightforward way to calculate a value of succ(x, k) is to start at node x and walk k steps forward, which takes time. However, using preprocessing, any value of succ(x, k) can be calculated in only time.
Let u denote the maximum number of steps we will ever walk. The idea is to precalculate all values of succ(x, k) where k is a power of two and at most u. This can be efficiently done, because we can use the following recurrence:
The idea is that a path of length k that begins at node x can be divided into two paths of length k/2. Precalculating all values of succ(x, k) where k is a power of two and at most u takes time, because values are calculated for each node. In our example graph, the first values are as follows:
After the precalculation, any value of succ(x, k) can be calculated by presenting k as a sum of powers of two. Such a representation always consists of parts, so calculating a value of succ(x, k) takes time. For example, if we want to calculate the value of succ(x, 11), we use the formula
In our example graph,
