Fix random walk code to work for non-contiguous sequences of node ids