for (int i = 0; i < h - 1; i++)
g.DrawLine(pen, new Point((int)ad[i].x, (int)ad[i].y), new Point((int)ad[i + 1].x, (int)ad[i + 1].y));
g.DrawLine(pen, new Point((int)ad[h - 1].x, (int)ad[h - 1].y), new Point((int)pd.x, (int)pd.y));
button3.Enabled = true;
}
else
MessageBox.Show("请先读取坐标");
图 5-6 cr路由模拟界面
5.7 MGDR模块功能
Mgdr模块主要根据路由准则找出路径并且显示出来。
代码如下:
while (juli(ps, pd) > 30)
{
j = 0;
for (int i = 0; i < 32; i++)
{
if (ps.x == aa[i].x && ps.y == aa[i].y)
continue;
if (juli(ps, aa[i]) < 30.0)
ac[j++] = aa[i]; }
jj = jiaodian(ps, pd, 30.0);
double min = juli(ac[0], jj);
ps1 = ac[0];
for (int i = 1; i < j; i++)
if (juli(ac[i], jj) < min)
{
ps1 = ac[i];
min = juli(ps1, jj);
}
jl[2] += juli(ps, ps1);
nl[2] += (juli(ps, ps1) * juli(ps, ps1));
ps = ps1;
ad[h++] = ps; 无线传感器网络中数据传输最优路径选择(15):http://www.751com.cn/tongxin/lunwen_2234.html