Exemplo n.º 1
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            //graphCreator1 = new GraphViewer(

            try
            {
                 throw new NotImplementedException();

                Point p1 = new Point(20, 20, Settings1.Default.NodeSize,0, Color.Black);
                Point p2 = new Point(40, 40, Settings1.Default.NodeSize,1, Color.Black);

                Route r1 = new Route(new int[] { 0, 1 });
                Route r2 = new Route(new int[] { 0, 1 });
                Route r3 = new Route(new int[] { 0, 1 });
                Graph g = new Graph(new System.Collections.ArrayList() { p1, p2 }, new Route[] { r1, r2, r3 });

                //graphCreator1 = new GraphViewer(g) as GraphCreator;
                //graphCreator1.points.Add(p1);
                //graphCreator1.points.Add(p2);

                /*graphCreator1.edges.Add(new Edge(p1, p2, 0, 0));
                graphCreator1.edges.Add(new Edge(p1, p2, 1, 1));
                graphCreator1.edges.Add(new Edge(p1, p2, 2, 2));
                 */

                //graphCreator1.r
                //graphCreator1.Redraw(true);
                //graphCreator1.DrawRoutes(new Route[] { r1, r2, r3 });
            }
            catch (Exception ex) { Console.WriteLine(ex.Message); }
        }
Exemplo n.º 2
0
 public GraphViewer(Graph g)
 {
     graph = g;
     points = new ArrayList(g.nodes.Length);
     Status.Points = points;
     edges = new ArrayList();
     InitializeComponent();
 }
Exemplo n.º 3
0
 public Node(Graph g, int bn)
 {
     graph = g;
     n = bn;
     len = int.MaxValue;
 }
Exemplo n.º 4
0
 public AdjNode(Graph g, int nn, int rn)
 {
     graph = g;
     node = g.GetNode(nn);
     route = rn;
 }
Exemplo n.º 5
0
        private void resultBtn_Click(object sender, EventArgs e)
        {
            try
            {
                Array a = routes.ToArray(typeof(Route));
                graphcreator.tempdiredges.Clear();
                Graph g = new Graph(points, a as Route[]);
                string path;
                resultLbl.Text = g.ShortestRoute(srcPoint.SelectedIndex, destPoint.SelectedIndex, out path).ToString();

                Node c1 = null;
                Node c2 = null;
                //graphcreator.CreateGraphics().Clear(Color.White);
                graphcreator.state = GraphCreator.GState.ResultPath;
                graphcreator.Redraw(true);
                graphcreator.DrawNodes(true);
                while (g.nodestomove.Count >1)
                {
                    /*
                    if (c != null)
                    {
                        graphcreator.DrawDirectEdge(c.point, ((Node)g.nodestomove.Peek()).point, ((Route)routes[((Node)g.nodestomove.Peek()).r]).color);
                    }
                    c = (Node)g.nodestomove.Dequeue();
                    */

                    c1 = (Node)g.nodestomove.Dequeue();
                    c2 = (Node)g.nodestomove.Peek();

                    graphcreator.DrawDirectEdge(c1.point, c2.point, ((Route)routes[c1.r]).color);
                    graphcreator.tempdiredges.Add(new Edge(c1.point, c2.point, c1.r, 0, ((Route)routes[c1.r]).color));
                }
                MessageBox.Show(path);
                //statusb

            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "+" + ex.StackTrace); }
        }