Use sorted set to cache number of reachable nodes