public bool AreVerticesConnected(T from, T to) { if (TryGetVertex(to, out Vertex <T> toVertex) && TryGetVertex(from, out Vertex <T> fromVertex)) { var verticesFromSource = BreadthFirstSearch.GetConnectedVertices(this, fromVertex); return(verticesFromSource.Contains(toVertex)); } throw new ArgumentOutOfRangeException("Some vertex is not part of the graph."); }