Пример #1
0
 public Edge(Node snode, Node enode,double svalue)
 {
     this.snode = snode;
     this.enode = enode;
     this.svalue = svalue;
     edges = new EdgesCollection(this);
 }
Пример #2
0
 public Edge(Node snode, Node enode, double svalue)
 {
     this.snode  = snode;
     this.enode  = enode;
     this.svalue = svalue;
     edges       = new EdgesCollection(this);
 }
Пример #3
0
 internal bool EdgeSearch(string start, string end, EdgesCollection ec, Edge e1)
 {
     for (int i = ec.Count - 1; i >= 0; i--)
     {
         e1 = ec[i];
         if (e1.Snode.Name == start && e1.Enode.Name == end)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #4
0
        private void btnDsave_Click(object sender, EventArgs e)
        {
            EdgesCollection EC     = map.Edge.Edges;
            Edge            edge   = new Edge();
            double          svalue = double.Parse(txtDistance.Text);;

            if (EdgeSearch(txtDstart.Text, txtDend.Text, EC, edge))
            {
                edge.Svalue = svalue;
            }
            else
            {
                if (SearchNode(txtDstart.Text) != null && SearchNode(txtDend.Text) != null)
                {
                    edge        = new Edge(SearchNode(txtDstart.Text), SearchNode(txtDend.Text));
                    edge.Svalue = svalue;
                    EC.Add(edge);
                }
            }
        }
Пример #5
0
        int k = 0;//用于自增后读出print里的数据
        internal void exchange(EdgesCollection edge)
        {
            int r = map.Node.Nodes.Count;//输入点数R

            double[] a = new double[(r + 1) * (r + 1)];

            for (int i = 0; i < r; i++)
            {
                for (int j = i + 1; j < r; j++)
                {
                    MessageBox.Show(edge[k].Snode.Name + "到" + edge[k].Enode.Name + "的距离是:" + edge[k].Svalue);
                    a[i * r + j] = edge[k].Svalue;
                    if (k < r * (r - 1) / 2)
                    {
                        k++;
                    }
                }
            }
            //----完善距离矩阵(距离矩阵其实可以是个上三角矩阵,
            //----但为了处理方便,还是将其完整成一个对称阵)-----------
            for (int i = 0; i < r; i++)
            {
                for (int j = 0; j < r; j++)
                {
                    if (i == j)
                    {
                        a[i * r + j] = 0;
                    }
                    a[j * r + i] = a[i * r + j];
                }
                if (i == r - 1)
                {
                    Marx   m    = new Marx(r, a);
                    string outs = "";
                    m.Find_way();
                    m.Display(ref outs, comEnd.Text, map.Node.Nodes);
                    txtOutroute.Text = outs;
                }
            }
        }
Пример #6
0
        internal void exchange(EdgesCollection edge)
        {
            int r = map.Node.Nodes.Count;//输入点数R
            double[] a=new double[(r + 1) * (r + 1)];

            for (int i = 0; i < r; i++)
            {
                for (int j = i + 1; j < r; j++)
                {

                    MessageBox.Show(edge[k].Snode.Name + "到" + edge[k].Enode.Name + "的距离是:" + edge[k].Svalue);
                    a[i * r + j] = edge[k].Svalue;
                    if (k < r * (r - 1) / 2)
                    {
                        k++;
                    }
                }
            }
            //----完善距离矩阵(距离矩阵其实可以是个上三角矩阵,
            //----但为了处理方便,还是将其完整成一个对称阵)-----------
            for (int i = 0; i < r; i++)
            {
                for (int j = 0; j < r; j++)
                {
                    if (i == j)
                    {
                        a[i * r + j] = 0;
                    }
                    a[j * r + i] = a[i * r + j];
                }
                if (i == r - 1)
                {
                    Marx m = new Marx(r, a);
                    string outs="";
                    m.Find_way();
                    m.Display(ref outs, comEnd.Text, map.Node.Nodes);
                    txtOutroute.Text = outs;

                }
            }
        }
Пример #7
0
        internal bool EdgeSearch(string start,string end, EdgesCollection ec, Edge e1)
        {
            for(int i=ec.Count-1;i>=0;i--)
            {
                 e1 = ec[i];
                if (e1.Snode.Name == start && e1.Enode.Name == end)
                {
                    return true;
                }

            }
             return false;
        }
Пример #8
0
 public Edge()
 {
     edges = new EdgesCollection(this);
 }
Пример #9
0
        private double svalue; //权值

        #endregion Fields

        #region Constructors

        public Edge(Node snode,Node enode)
        {
            this.snode =snode;
            this.enode = enode;
            edges = new EdgesCollection(this);
        }
Пример #10
0
 public Edge()
 {
     edges = new EdgesCollection(this);
 }
Пример #11
0
 public Edge(Node snode, Node enode)
 {
     this.snode = snode;
     this.enode = enode;
     edges      = new EdgesCollection(this);
 }