private int GetDirectDependentsInternal(Reference @ref, DependencyMap map) { IList dependents = new ArrayList(); map.GetDirectDependents(@ref, dependents); return(dependents.Count); }
/// <summary> /// Perform the topological sort algorithm on our graph /// </summary> private IList TopologicalSort(DependencyMap dependents, DependencyMap precedents, IList sources) { var q = new Queue(sources); IList output = new ArrayList(); IList directDependents = new ArrayList(); while (q.Count > 0) { var n = (Reference)q.Dequeue(); output.Add(n); directDependents.Clear(); dependents.GetDirectDependents(n, directDependents); foreach (Reference m in directDependents) { dependents.RemoveDependency(n, m); precedents.RemoveDependency(m, n); if (precedents.ContainsTail(m) == false) { q.Enqueue(m); } } } // We assume no circular references return(output); }