public static void ExecuteOnVerticesRecursive <TVertex, TEdge>(this IBidirectionalGraph <TVertex, TEdge> graph, TVertex rootVertex, EdgeDirection edgeDirection, Action <TVertex> actionOnVertex) where TEdge : IEdge <TVertex> { actionOnVertex(rootVertex); foreach (var layoutEdge in graph.GetEdges(rootVertex, edgeDirection)) { var nextVertex = layoutEdge.GetEndVertex(edgeDirection); graph.ExecuteOnVerticesRecursive(nextVertex, edgeDirection, actionOnVertex); } }