private static long MeasureTime(IAlgorithmsInterface algorithm)
        {
            var sw = new Stopwatch();

            sw.Start();
            algorithm.Request();
            sw.Stop();
            return(sw.ElapsedMilliseconds);
        }
 private static void Write(IAlgorithmsInterface algorithm)
 {
     Console.WriteLine($"{algorithm.Result.Weight}");
     foreach (var item in algorithm.Result.Path)
     {
         Console.Write(item + " ");
     }
     Console.WriteLine();
 }
        public static void ComputeAndSave(IAlgorithmsInterface algorithm)
        {
            using (StreamWriter writer = new StreamWriter(algorithm.Name + ".txt"))
            {
                for (var i = 0; i < 10; i++)
                {
                    Console.WriteLine(algorithm.Name);
                    long time = MeasureTime(algorithm);

                    Console.WriteLine("Time:");
                    Console.WriteLine(time);

                    Console.WriteLine("Path:");
                    Write(algorithm.Result.Path);

                    Console.WriteLine("Weight:");
                    Console.WriteLine(algorithm.Result.Weight);

                    Console.WriteLine();
                }
                writer.Close();
            }
        }
        private static void ComputeAndSaveDeviation(IAlgorithmsInterface algorithm, int trueSolution, int iterations)
        {
            long timeSum = 0;
            var  results = new List <int>();

            for (int i = 0; i < iterations; i++)
            {
                Console.WriteLine(algorithm.Name);
                long time = MeasureTime(algorithm);

                timeSum += time;
                Console.WriteLine("Time");
                Console.WriteLine(time);

                Console.WriteLine("Path:");
                Write(algorithm.Result.Path);

                Console.WriteLine("Weight:");
                Console.WriteLine(algorithm.Result.Weight);
                results.Add(algorithm.Result.Weight);
            }

            Console.WriteLine("Deviation");

            float sum = 0;

            foreach (var result in results)
            {
                sum += (result - trueSolution) * 100f / trueSolution;
            }

            sum /= results.Count;
            Console.WriteLine(sum + "%");
            Console.WriteLine("Average Time:");
            Console.WriteLine(timeSum / iterations);
            Console.WriteLine();
        }
 public ValidationController(IAlgorithmsInterface algorithmsInterface)
 {
     _algorithmsInterface = algorithmsInterface;
 }