Fix bug of not erasing the visiting of the nodes resulting in empty graphs