private bool CheckCycle(DependencyVertex dependencyVertex) { var cycle = false; if (dependencyVertex.Visited) { return(true); } dependencyVertex.Visited = true; var vertices = dependencyVertex.Vertices.Where(v => !v.Visited); if (vertices.Any()) { foreach (var vertice in vertices) { vertice.Visited = true; cycle = cycle || CheckCycle(vertice.Target); } } return(cycle); }
public void AddVertice(DependencyVertex target) { Vertices.Add(new DependencyVertice(target)); }