private static void FindConnections(Dictionary <int, Node> nodes) { List <string> connections = new List <string> { "F0!", "StartTX!", "G0!", "ACK!", "B!", "StopTX!", "SOK!", "REQ?", "F0!" }; Console.WriteLine($"Searching for: {string.Join(',', connections)}"); IConnectionAnalyser connectionAnalyser = new ConnectionAnalyser(); var solutions = connectionAnalyser.FindConnections(nodes, connections); Console.WriteLine(); Console.WriteLine($"Solutions found: {solutions.Count}"); int solutionIndex = 0; foreach (var solution in solutions) { Console.WriteLine(FormatConnectionRow(++solutionIndex, solution, connections)); } }
private static void FindPaths(Dictionary <int, Node> nodes) { string endNodesFile = @".\Data\end-nodes.txt"; var endNodes = File.ReadAllLines(endNodesFile) .Select(x => int.Parse(x)) .ToList(); Node startNode = nodes.GetValueOrDefault(0); IConnectionAnalyser connectionAnalyser = new ConnectionAnalyser(); Stopwatch sw = new Stopwatch(); sw.Start(); var solutions = connectionAnalyser.FindPaths(startNode, endNodes); sw.Stop(); Console.WriteLine(); Console.WriteLine($"Finished in {sw.Elapsed.Hours}h{sw.Elapsed.Minutes}m"); Console.WriteLine($"Total seconds: {sw.Elapsed.TotalSeconds}s"); Console.WriteLine($"Solutions found: {solutions.Count}"); var outputFile = @".\Data\result.txt"; using var streamWriter = new StreamWriter(outputFile); int solutionIndex = 0; foreach (var solution in solutions) { string solutionResult = FormatPathRow(++solutionIndex, solution); Console.WriteLine(solutionResult); streamWriter.WriteLine(solutionResult); } }