Esempio n. 1
0
        public static List <SCC <Procedure> > ComputeOrderedSCCs(Graph <Procedure> graph)
        {
            Adjacency <Procedure> next = new Adjacency <Procedure>(graph.Successors);
            Adjacency <Procedure> prev = new Adjacency <Procedure>(graph.Predecessors);

            var sccs = new StronglyConnectedComponents <Procedure>(graph.Nodes, next, prev);

            sccs.Compute();
            //sccs.Iter(s => { s.Iter(p => Console.Write(p + ", ")); Console.WriteLine(); });

            var order = sccs.ToList();

            for (int i = 0; i < order.Count; i++)
            {
                for (int j = i + 1; j < order.Count; j++)
                {
                    Debug.Assert(order[i].All(p => order[j].All(p2 => !graph.Edge(p2, p))));
                }
            }

            return(order);
        }