Function to calculate reachable nodes complete