Fix Graph algoritm