private void StrongConnect(List <List <ProductionNode> > strongList, Stack <TarjanNode> S, int indexCounter, TarjanNode v) { v.Index = indexCounter; v.LowLink = indexCounter++; S.Push(v); foreach (TarjanNode w in v.Links) { if (w.Index == -1) { StrongConnect(strongList, S, indexCounter, w); v.LowLink = Math.Min(v.LowLink, w.LowLink); } else if (S.Contains(w)) { v.LowLink = Math.Min(v.LowLink, w.LowLink); } } { TarjanNode w = null; if (v.LowLink == v.Index) { strongList.Add(new List <ProductionNode>()); do { w = S.Pop(); strongList.Last().Add(w.SourceNode); } while (w != v); } } }
private void StrongConnect(List<List<ProductionNode>> strongList, Stack<TarjanNode> S, int indexCounter, TarjanNode v) { v.Index = indexCounter; v.LowLink = indexCounter++; S.Push(v); foreach (TarjanNode w in v.Links) { if (w.Index == -1) { StrongConnect(strongList, S, indexCounter, w); v.LowLink = Math.Min(v.LowLink, w.LowLink); } else if (S.Contains(w)) { v.LowLink = Math.Min(v.LowLink, w.LowLink); } } { TarjanNode w = null; if (v.LowLink == v.Index) { strongList.Add(new List<ProductionNode>()); do { w = S.Pop(); strongList.Last().Add(w.SourceNode); } while (w != v); } } }