예제 #1
0
        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);
                }
            }
        }
예제 #2
0
		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);
				}
			}
		}