Exemple #1
0
        private void Short_Path_Click(object sender, EventArgs e)
        {
            if (Map.Text == "")
            {
                MessageBox.Show("Select Map First !", "", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else if (Qery_text.text == "" || Convert.ToInt32(Qery_text.text) > queries.Number_Of_Queries)
            {
                MessageBox.Show("Invalid Query Number !", "", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                sssp = new ShortestPathAlgorithm();
                Stopwatch AlgoTime = Stopwatch.StartNew();
                sssp.Calculate_ShortestPath(graph, queries, TestCaseNo);
                AlgoTime.Stop();
                int AlgorithmTime      = (int)AlgoTime.ElapsedMilliseconds;
                int TotalExecutionTime = GraphConstructionTime + AlgorithmTime;

                panel2.Visible      = true;
                totaldisL.Text      = sssp.totalDistance.ToString() + " Km";
                totaltimeL.Text     = sssp.totalTime.ToString() + " mins";
                walkingdL.Text      = sssp.totalWalkingDistance.ToString() + " Km";
                vehdL.Text          = sssp.totalVehD.ToString() + " Km";
                executionTimeL.Text = AlgorithmTime.ToString() + " ms";
                drawShortestPath(graph.intersections, sssp.shortest_path_nodes, draw_panal, scl);
            }
        }
        void check(string mapfile)
        {
            if (mapfile == "OLMap")
            {
                queries = new queries("OLQueries");
                ch      = new CheckCorrectness("OLOutput", queries.Number_Of_Queries);
            }
            else if (mapfile == "SFMap")
            {
                queries = new queries("SFQueries");
                ch      = new CheckCorrectness("SFOutput", queries.Number_Of_Queries);
            }
            else
            {
                if (mapfile == "map1")
                {
                    queries = new queries("queries1");
                    ch      = new CheckCorrectness("output1", queries.Number_Of_Queries);
                }
                else if (mapfile == "map2")
                {
                    queries = new queries("queries2");
                    ch      = new CheckCorrectness("output2", queries.Number_Of_Queries);
                }
                else if (mapfile == "map3")
                {
                    queries = new queries("queries3");
                    ch      = new CheckCorrectness("output3", queries.Number_Of_Queries);
                }
                else if (mapfile == "map4")
                {
                    queries = new queries("queries4");
                    ch      = new CheckCorrectness("output4", queries.Number_Of_Queries);
                }
                else if (mapfile == "map5")
                {
                    queries = new queries("queries5");
                    ch      = new CheckCorrectness("output5", queries.Number_Of_Queries);
                }
            }
            graph    = new Graph(mapfile);
            shortest = new ShortestPathAlgorithm();
            string m;
            bool   accepted = true;

            for (int i = 0; i < queries.Number_Of_Queries; i++)
            {
                Stopwatch s = Stopwatch.StartNew();
                shortest.Calculate_ShortestPath(graph, queries, i);
                s.Stop();
                richTextBox1.AppendText("Total Time = " + shortest.totalTime.ToString() + " mins\n");
                richTextBox1.AppendText("Total Distance = " + shortest.totalDistance.ToString() + " Km\n");
                richTextBox1.AppendText("Total Walking Distance = " + shortest.totalWalkingDistance.ToString() + " Km\n");
                richTextBox1.AppendText("Total Vehcile Distance = " + shortest.totalVehD.ToString() + " Km\n");
                richTextBox1.AppendText("Execution Time = " + (int)s.ElapsedMilliseconds + " ms\n");
                m = ch.checkoutput(shortest.totalTime, shortest.totalDistance, shortest.totalWalkingDistance, shortest.totalVehD, (int)s.ElapsedMilliseconds, i);
                richTextBox1.AppendText(m + "\n");
                richTextBox1.AppendText("\n");
                if (m != "Case # " + (i + 1).ToString() + " Succeeded")
                {
                    accepted = false;
                    break;
                }
                richTextBox1.ScrollToCaret();
            }
            if (accepted)
            {
                richTextBox1.AppendText("All Cases Succeeded\n");
            }
        }