Fix the problem with "dist" in Vertex: the parameter must be a reference to variable.