Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
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;

                }
            }
        }