Graph Algorithm 6