getClosestVertex(vertex) {
    let minDist = 99999;
    let minVertex = null;

    for (var i = 0; i < this.graph.vertices.length; i++) {
      let v = this.graph.vertices[i];

      if (v.id === vertex.id) {
        continue;
      }

      let distSq = vertex.position.distanceSq(v.position);

      if (distSq < minDist) {
        minDist = distSq;
        minVertex = v;
      }
    }

    return minVertex;
  }
Returns the closest vertex (connected as well as unconnected).

@param {Vertex} vertex The vertex of which to find the closest other vertex.
@returns {Vertex} The closest vertex.