private void StrongConnect(Vertex <T> v) { v.Index = index; v.LowLink = index; index++; stack.Push(v); foreach (Vertex <T> w in v.Dependencies) { if (w.Index < 0) { StrongConnect(w); v.LowLink = Math.Min(v.LowLink, w.LowLink); } else if (stack.Contains(w)) { v.LowLink = Math.Min(v.LowLink, w.Index); } } if (v.LowLink == v.Index) { var scc = new StronglyConnectedComponent <T>(); Vertex <T> w; do { w = stack.Pop(); scc.Add(w); } while (v != w); stronglyConnectedComponents.Add(scc); } }
public void Add(StronglyConnectedComponent <T> scc) { this.collection.AddLast(scc); }