I have an array (nodes[][]
) that contains values of effective distances that looks something like this:
__ __
|1 0.4 3 |
|0.4 1 0 |
|3 3.2 1 ... |
|0.8 4 5 |
|0 0 1 |
-- --
Where the first value, node[0][0]
is the distance from node 0 to node 0 which is 1.
So the distance from node 2 to node 1 is 3.2 (node[2][1]=3.2
)
I need, given a node column, to search through the rows to find the farthest distance, while not picking itself (node[1][1]
)
The method I was thinking to do something like this:
int n=0;
currentnode=0; //this is the column I am searching now
if(currentnode==n)
n++;
best=node[n][currentnode];
nextbest=node[n++][currentnode];
if(nextbest>best)
best=nextbest;
else
for(int x=n;x<max;x++) //max is the last column
{
if(currentnode==n)
continue;
nextbest=node[x][currentnode];
if(nextbest>best)
best=nextbest;
}
I can't think of a better method to do this. I could use functions to make it shorter but this is GENERALLY what I am thinking about using. After this I have to loops this to go to the next column that the best distance returns and do this routine again.