Example #1
0
        public void Menu()
        {
            bool exit = false;

            while (!exit)
            {
                StreamWriter fileWriter = null;
                char         k;
                Console.Clear();
                Console.WriteLine("1. Research by certain matrix size");
                Console.WriteLine("2. Research by time per size");
                Console.WriteLine("3. Exit to main menu");
                var key = Console.ReadLine();
                switch (key)
                {
                case "1":
                    Console.WriteLine("Write research process and results to files? [y/n]");
                    do
                    {
                        k = Console.ReadKey().KeyChar;
                    } while (k != 'n' && k != 'y');
                    if (k == 'y')
                    {
                        fileWriter = _console.GetFileStream();
                    }
                    Console.WriteLine();

                    bound = _console.RandomInput();
                    Console.WriteLine("Enter research size:");
                    int.TryParse(Console.ReadLine(), out int size);
                    CounterReset();
                    ResearchForSize(fileWriter, size, true);
                    Compare(fileWriter);
                    if (fileWriter != null)
                    {
                        _console.WriteTimeToFile(FordFulkersonCount, $"FordFulkerson_{bound}");
                        _console.WriteTimeToFile(DinicsCount, $"Dinic_{bound}");
                        _console.WriteTimeToFile(GreedyCount, $"Greedy_{bound}");
                        _console.WriteTimeToFile(DFSCount, $"DFS_{bound}");
                        Console.WriteLine("\nFiles created!");
                    }
                    Console.ReadKey();
                    break;

                case "2":
                    Console.WriteLine("Write research process and results to files? [y/n]");
                    do
                    {
                        k = Console.ReadKey().KeyChar;
                    } while (k != 'n' && k != 'y');
                    if (k == 'y')
                    {
                        fileWriter = _console.GetFileStream();
                    }
                    Console.WriteLine();
                    ResearchByTimePerSize(fileWriter);
                    Console.ReadKey();
                    break;

                case "3":
                    exit = true;
                    break;
                }
                if (fileWriter != null)
                {
                    fileWriter.Close();
                }
            }
        }