public static void FindSCCs(Graph_AdjacencyList_Lite graph) { StronglyConnectedComponents_Kosarajus kDFS = new StronglyConnectedComponents_Kosarajus(); Dictionary<int, int> result = kDFS.FindSCCsInGraph(graph); List<int> fiveTop = FindMaxValuesInDictionary(result, 5); Console.WriteLine(string.Format("There were {0} SCCs in the graph. The leaders were {1}, 5 largest SCCs were {2}", result.Count, Utilities.FormatPrintDictionary<int, int>(result), Utilities.FormatPrintList<int>(fiveTop))); }
public static void Test0() { Graph_AdjacencyList_Lite myGraph = Utilities.ReadEdgeListIntoGraph_Lite(pathToFile0); Graph_AdjacencyList_Lite revGraph = Graph_AdjacencyList_Lite.ReverseGraph(myGraph); Console.WriteLine(string.Format("Reversed Graph:{0}{1}", Environment.NewLine, revGraph.ToString())); Graph_AdjacencyList_Lite reRevGraph = Graph_AdjacencyList_Lite.ReverseGraph(revGraph); Console.WriteLine(string.Format("Re-reversed Graph:{0}{1}", Environment.NewLine, reRevGraph.ToString())); StronglyConnectedComponents_Kosarajus kDFS = new StronglyConnectedComponents_Kosarajus(); Dictionary<int, int> result = kDFS.FindSCCsInGraph(myGraph); Console.WriteLine(string.Format("There were {0} SCCs in the graph. The leaders were {1}", result.Count, Utilities.FormatPrintDictionary<int, int>(result))); }
public static void Test1() { Graph_AdjacencyList_Lite myGraph = Utilities.ReadEdgeListIntoGraph_Lite(pathToFile1); Console.WriteLine(string.Format("Original Graph:{0}{1}", Environment.NewLine, myGraph.ToString())); Graph_AdjacencyList_Lite revGraph = Graph_AdjacencyList_Lite.ReverseGraph(myGraph); Console.WriteLine(string.Format("Reversed Graph:{0}{1}", Environment.NewLine, revGraph.ToString())); Graph_AdjacencyList_Lite reRevGraph = Graph_AdjacencyList_Lite.ReverseGraph(revGraph); Console.WriteLine(string.Format("Re-reversed Graph:{0}{1}", Environment.NewLine, reRevGraph.ToString())); StronglyConnectedComponents_Kosarajus kDFS = new StronglyConnectedComponents_Kosarajus(); Dictionary<int, int> result = kDFS.FindSCCsInGraph(myGraph); List<int> fiveTop = FindMaxValuesInDictionary(result, 5); Console.WriteLine(string.Format("There were {0} SCCs in the graph. The leaders were {1}{3}5 largest SCCs were {2}", result.Count, Utilities.FormatPrintDictionary<int, int>(result), Utilities.FormatPrintList<int>(fiveTop), Environment.NewLine)); }