📄 gfx.cpp
字号:
#include "stdafx.h"
#include "Network.h"
#include "GFX.h"
/* global variables */
extern NODE_TYPE nodeT[4000];
extern NETWORK_TYPE net;
int bestNeighborX(int from,int dest);
void BuildGFX(int root){
int i;
for( i = 0 ; i < net.NUM_NODES;i++){
int next = bestNeighborX(i,root);
if(next != INVALID_ID)
SetNextHop(i, root, next);
}
}
int bestNeighborX(int from,int dest) //gfX
{
int i;
int to;
bool found = false;
double test = -1;
int find;
double currenttest;
assert(from < net.NUM_NODES && dest < net.NUM_NODES);
if(from == dest) return from;
for (i=0;i<nodeT[from].neighbornum;i++)
{
// printf("%d\n",i);
if ((unidirectional(from, nodeT[from].neighbor[i])==true))
continue;
if(adistance(nodeT[from].neighbor[i],dest) > adistance(from,dest)) continue;
to = nodeT[from].neighbor[i];
double a,b,c;
a = adistance(from, to);
b = adistance(from, dest);
c = adistance(to,dest);
if((b-c) < 0) continue;
if (b>c)
/* to discuss */
currenttest = (b-c) * linkquality(from,to);
if (currenttest > test)
{ test = currenttest;
find = nodeT[from].neighbor[i];
found = true;
}
}
if (found == false){
printf("node %d can not do greedy forward\n",from);
find = INVALID_ID;
assert(false);
}
// printf("%d->%d\n",from,find);
return find;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -