Exemple #1
0
        private void StrongConnect(CycleFind v, Dictionary <Node, CycleFind> V, Stack <CycleFind> S, List <IEnumerable <CycleFind> > output, ref int index)
        {
            v.Index   = index;
            v.LowLink = index;
            index++;
            S.Push(v);
            v.OnStack = true;

            foreach (var w in GetNodes(v, V))
            {
                if (w.IndexIsUndefined)
                {
                    StrongConnect(w, V, S, output, ref index);
                    v.LowLink = Math.Min(v.LowLink, w.LowLink);
                }
                else if (w.OnStack)
                {
                    v.LowLink = Math.Min(v.LowLink, w.Index);
                }
            }

            if (v.LowLink == v.Index)
            {
                var       scc = new List <CycleFind>();
                CycleFind sccNode;
                do
                {
                    sccNode         = S.Pop();
                    sccNode.OnStack = false;
                    scc.Add(sccNode);
                } while (sccNode != v);
                output.Add(scc);
            }
        }
Exemple #2
0
 private IEnumerable <CycleFind> GetNodes(CycleFind c, Dictionary <Node, CycleFind> V) => GetNodesAffectedByUpdates(c.Node.TriggeredUpdates).Select(a => V[a]);