src/Misc/EFTools/XmlCore/Model/DependencyGraph.cs
/// <summary>
///     do a breadth-first search to find all nodes reachable from item.
///     edgeFunction determines the nodes directly reachable from any
///     given item.
/// </summary>
/// <param name="item"></param>
/// <param name="closureFunction"></param>
/// <returns></returns>
do a breadth-first search to find all nodes reachable from item.
edgeFunction determines the nodes directly reachable from any
given item.
do a breadth - first search to find all nodes reachable from item . edgeFunction determines the nodes directly reachable from any given item .
private static ICollection<T> GetClosure(T item, EdgeFunction edgeFunction)
        {
            var closure = new QueueHashSet<T>();
            var queue = new QueueHashSet<T>();
            foreach (var i in edgeFunction(item))
            {
                queue.Enqueue(i);
            }
            while (queue.Count > 0)
            {
                var i = queue.Dequeue();
                if (!closure.Contains(i))
                {
                    closure.Enqueue(i);
                    foreach (var j in edgeFunction(i))
                    {
                        if (!queue.Contains(j)
                            && !closure.Contains(j))
                        {
                            queue.Enqueue(j);
                        }
                    }
                }
            }
            return closure.Queue;
        }
private static ICollection < T > GetClosure ( T item , EdgeFunction edgeFunction ) { var closure = new QueueHashSet < T > ( ) ; var queue = new QueueHashSet < T > ( ) ; foreach ( var i in edgeFunction ( item ) ) { queue . Enqueue ( i ) ; } while ( queue . Count > 0 ) { var i = queue . Dequeue ( ) ; if ( ! closure . Contains ( i ) ) { closure . Enqueue ( i ) ; foreach ( var j in edgeFunction ( i ) ) { if ( ! queue . Contains ( j ) && ! closure . Contains ( j ) ) { queue . Enqueue ( j ) ; } } } } return closure . Queue ; }
do a breadth-first search to find all nodes reachable from item.
do a breadth - first search to find all nodes reachable from item .
// get first element in queue
None
item
T
None
edgeFunction
EdgeFunction
closureFunction
None