public RoutesDTO DuplexDijksterDisabled(string startLatLon, string endLatLon)
        {
            KeyValuePair <NodeGraphDTO, NodeGraphDTO> nodes = BeforeCalculateDisabledShortestPath(startLatLon, endLatLon);

            PrepareData.PutStartEnd(nodes.Key, nodes.Value);
            var          watch = Stopwatch.StartNew();
            NodeGraphDTO node  = duplexDijkster.CalculateShortestPath(nodes.Key, nodes.Value);

            watch.Stop();
            time = watch.Elapsed;
            RoutesDTO routes = AfterCalculateShortestPathDuplex(node);

            PrepareData.RemoveStartEnd(nodes.Key, nodes.Value);
            return(routes);
        }
        public RoutesDTO MultiLabelDIsabled(string startLatLon, string endLatLon, string k)
        {
            KeyValuePair <NodeGraphDTO, NodeGraphDTO> nodes = BeforeCalculateDisabledShortestPath(startLatLon, endLatLon);

            PrepareData.PutStartEnd(nodes.Key, nodes.Value);
            multiLabel.K = Int32.Parse(k);
            var          watch = Stopwatch.StartNew();
            NodeGraphDTO node  = multiLabel.CalculateShortestPath(nodes.Key, nodes.Value);

            watch.Stop();
            time = watch.Elapsed;
            RoutesDTO routes = AfterCalculateShortestPathMultiLabel(node);

            PrepareData.RemoveStartEnd(nodes.Key, nodes.Value);
            return(routes);
        }
        public ActionResult Statistics()
        {
            var statistic = new
            {
                GraphMemory         = Utils.GraphMemory,
                DisabledGraphMemory = Utils.DisabledGraphMemory,
                GraphTime           = Utils.GraphTime,
                DisabledGraphTime   = Utils.DisabledGraphTime,
                PocetVrcholov       = Utils.PocetVrcholov
            };
            int            opakovani  = 10;
            int            algoritmus = 0;
            TimeSpan       time;
            Zakladny       zakladny       = new Zakladny();
            Dijkster       dijkster       = new Dijkster();
            AStar          astar          = new AStar();
            LabelCorrect   labelCorrect   = new LabelCorrect();
            LabelSet       labelSet       = new LabelSet();
            DuplexDijkster duplexDijkster = new DuplexDijkster();
            var            watch          = Stopwatch.StartNew();
            Random         random         = new Random();

            NodeGraphDTO[]   startNodes = new NodeGraphDTO[opakovani];
            NodeGraphDTO[]   endNodes   = new NodeGraphDTO[opakovani];
            List <RoutesDTO> routesAll  = new List <RoutesDTO>(6);

            for (int i = 0; i < opakovani; i++)
            {
                startNodes[i] = PrepareData.NodesGraph.Values.ElementAt(random.Next(PrepareData.NodesGraph.Count));
                endNodes[i]   = PrepareData.NodesGraph.Values.ElementAt(random.Next(PrepareData.NodesGraph.Count));
            }

            for (int j = 0; j < 6; j++)
            {
                RoutesDTO routes = new RoutesDTO();
                for (int i = 0; i < opakovani; i++)
                {
                    PrepareData.PrepareNodesGraph();
                    switch (j)
                    {
                    case 0:
                        PrepareData.PutStartEnd(startNodes[i], endNodes[i]);
                        watch.Restart();
                        var n = zakladny.CalculateShortestPath(startNodes[i], endNodes[i], PrepareData.DisabledMovementGraph);
                        watch.Stop();
                        time = watch.Elapsed;
                        AfterCalculateShortestPath(n, time, routes);
                        PrepareData.RemoveStartEnd(startNodes[i], endNodes[i]);
                        break;

                    case 1:
                        PrepareData.PutStartEnd(startNodes[i], endNodes[i]);
                        watch.Restart();
                        n = dijkster.CalculateShortestPath(startNodes[i], endNodes[i]);
                        watch.Stop();
                        time = watch.Elapsed;
                        AfterCalculateShortestPath(n, time, routes);
                        PrepareData.RemoveStartEnd(startNodes[i], endNodes[i]);
                        break;

                    case 2:
                        PrepareData.PutStartEnd(startNodes[i], endNodes[i]);
                        watch.Restart();
                        n = astar.CalculateShortestPath(startNodes[i], endNodes[i]);
                        watch.Stop();
                        time = watch.Elapsed;
                        var a = routes.Route.Last;
                        AfterCalculateShortestPath(n, time, routes);
                        PrepareData.RemoveStartEnd(startNodes[i], endNodes[i]);
                        break;

                    case 3:
                        PrepareData.PutStartEnd(startNodes[i], endNodes[i]);
                        watch.Restart();
                        n = labelSet.CalculateShortestPath(startNodes[i], endNodes[i]);
                        watch.Stop();
                        time = watch.Elapsed;
                        AfterCalculateShortestPath(n, time, routes);
                        PrepareData.RemoveStartEnd(startNodes[i], endNodes[i]);
                        break;

                    case 4:
                        PrepareData.PutStartEnd(startNodes[i], endNodes[i]);
                        watch.Restart();
                        n = labelCorrect.CalculateShortestPath(startNodes[i], endNodes[i]);
                        watch.Stop();
                        time = watch.Elapsed;
                        AfterCalculateShortestPath(n, time, routes);
                        PrepareData.RemoveStartEnd(startNodes[i], endNodes[i]);
                        break;

                    case 5:
                        PrepareData.PutStartEnd(startNodes[i], endNodes[i]);
                        watch.Restart();
                        n = duplexDijkster.CalculateShortestPath(startNodes[i], endNodes[i]);
                        watch.Stop();
                        time = watch.Elapsed;
                        AfterCalculateShortestPathDuplex(n, time, routes);
                        PrepareData.RemoveStartEnd(startNodes[i], endNodes[i]);
                        break;
                    }
                }
                routesAll.Add(routes);
            }

            double[] PocetHranCesty            = new double[6];
            double[] PocetSpracovanychVrcholov = new double[6];
            double[] DlzkaCesty = new double[6];
            double[] CasVypoctu = new double[6];
            algoritmus = 0;
            foreach (RoutesDTO r in routesAll)
            {
                opakovani = r.Route.Count == 0 ? opakovani : r.Route.Count;
                long   PocetHranCestyA            = 0;
                long   PocetSpracovanychVrcholovA = 0;
                double DlzkaCestyA = 0;
                double CasVypoctuA = 0;
                foreach (RouteDTO route in r.Route)
                {
                    PocetHranCestyA            += route.PocetHranCesty;
                    PocetSpracovanychVrcholovA += route.PocetSpracovanychVrcholov;
                    DlzkaCestyA += route.DlzkaCesty;
                    CasVypoctuA += route.CasVypoctu;
                }
                PocetHranCesty[algoritmus]            = (double)PocetHranCestyA / opakovani;
                PocetSpracovanychVrcholov[algoritmus] = (double)PocetSpracovanychVrcholovA / opakovani;
                DlzkaCesty[algoritmus] = DlzkaCestyA / opakovani;
                CasVypoctu[algoritmus] = CasVypoctuA / opakovani;
                algoritmus++;
            }
            return(Json(statistic));
        }