Beispiel #1
0
        private void SetGraph(CityGraph g)
        {
            GViewer viewer = new GViewer();

            viewer.Graph = g.MSAGLGraph;
            panel1.SuspendLayout();
            viewer.Dock = DockStyle.Fill;
            panel1.Controls.Clear();
            panel1.Controls.Add(viewer);
            panel1.ResumeLayout();
        }
Beispiel #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         int targetDay = int.Parse(dayTxtBox.Text);
         if (targetDay < 0)
         {
             throw new Exception("Query hari tidak boleh negatif!");
         }
         string[] g = listKotaTxtBox.Text.Split('\n');
         Dictionary <string, City> map = new Dictionary <string, City>();
         int       i     = 0;
         string[]  l     = g[i++].Split(' ');
         string    root  = l[1];
         CityGraph graph = new CityGraph();
         int       n     = int.Parse(l[0]);
         while (n-- > 0)
         {
             string[] line = g[i++].Split(' ');
             map[line[0]] = new City(line[0], int.Parse(line[1]));
             graph.MSAGLGraph.AddNode(new Node(line[0]));
         }
         g = petaTxtBox.Text.Split('\n');
         i = 0;
         n = int.Parse(g[i++]);
         while (n-- > 0)
         {
             string[] line = g[i++].Split(' ');
             graph.AddEdge(map[line[0]], map[line[1]], double.Parse(line[2]));
         }
         graph.Query(map[root], targetDay);
         SetGraph(graph);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Input tidak valid!\n" + ex.Message);
     }
 }