示例#1
0
        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);
        }
示例#2
0
 public void AddVertice(DependencyVertex target)
 {
     Vertices.Add(new DependencyVertice(target));
 }