コード例 #1
0
ファイル: SKEMA.cs プロジェクト: longtomjr/SKON.NET
            private void StrongConnect(SKEMAObject v, VertexSuccessors VertexSuccessors)
            {
                indexMap[v]   = index;
                lowlinkMap[v] = index;
                index++;
                S.Push(v);

                List <SKEMAObject> successors = VertexSuccessors(v);

                SKEMAObject w;

                // Find the referenced definitions in the SKEMAObject
                foreach (SKEMAObject reference in successors)
                {
                    w = reference;

                    if (indexMap.ContainsKey(w) == false)
                    {
                        StrongConnect(w, VertexSuccessors);

                        lowlinkMap[v] = Math.Min(lowlinkMap[v], lowlinkMap[w]);
                    }
                    else if (S.Contains(w))
                    {
                        lowlinkMap[v] = Math.Min(lowlinkMap[v], indexMap[w]);
                    }
                }

                if (lowlinkMap[v] == indexMap[v])
                {
                    LinkedList <SKEMAObject> component = new LinkedList <SKEMAObject>();
                    do
                    {
                        w = S.Pop();
                        component.AddLast(w);
                    } while (w != v);

                    //Console.WriteLine("Added strongly connected component of lenght " + component.Count);
                    stronglyConnectedComponents.Add(component);
                }
            }
コード例 #2
0
ファイル: SKEMA.cs プロジェクト: longtomjr/SKON.NET
            internal List <LinkedList <SKEMAObject> > FindStronglyConnectedComponents(SKEMAObject obj, VertexSuccessors VertexSuccessors)
            {
                foreach (string v in obj.Keys)
                {
                    if (indexMap.ContainsKey(obj[v]) == false)
                    {
                        StrongConnect(obj[v], VertexSuccessors);
                    }
                }

                return(stronglyConnectedComponents);
            }