/**
 * Convert a vertex representation to the associated vertex.
 *
 * vertexRepresentation can be
 * - a Vertex: Returned as is
 * - a string: Interpreted as wsi4.util.toKey()'s return value
 */
export function toVertex(vertexRepresentation: Vertex|string): Vertex {
	if (typeof vertexRepresentation === "string") {
		const vertex = wsi4.graph.vertices()
			.find(v => wsi4.util.toKey(v) === vertexRepresentation);
		if (vertex === undefined) {
			return wsi4.throwError("No vertex found for key " + vertexRepresentation);
		}
		return vertex;
	} else {
		return vertexRepresentation;
	}
}
