public WeightedDiAdjacencyMatrix Transpose()
        {
            WeightedDiAdjacencyMatrix graph = new WeightedDiAdjacencyMatrix(matrix.Count);

            foreach (var item in Edges)
            {
                graph.AddEdge(item.VertexB + 1, item.VertexA + 1, item.Weight);
            }
            return(graph);
        }
示例#2
0
        public static void Run()
        {
            Console.WriteLine("---------------------------------------");

            var graph = new WeightedDiAdjacencyMatrix(5);

            graph.AddEdge(2, 1, 1f);
            graph.AddEdge(1, 4, 1f);
            graph.AddEdge(4, 5, 1f);
            graph.AddEdge(1, 3, 1f);
            graph.AddEdge(3, 2, 1f);
            //graph.PrintAdjacency();


            var kosaraju = new Kosaraju();

            kosaraju.PrintSCCs(graph);


            Console.ReadKey();
        }