Hi I have an algorithm which try's to find the "maximum distance" between two nodes.
I have read each node from the file and that works. However, when the program try's to perform the MaxDist algorithm I get the vector subscript out of range error.
float tempDist;
float currentMax;
string node_1_name;
string node_2_name;
for (unsignedint i = 0; i < list_of_Nodes.capacity(); i++)
{
for (unsignedint k = i + 1; k < list_of_Nodes.capacity(); k++)
{
//Get the distance between two Nodes.
tempDist = ArcLength(list_of_Nodes[i].getLat(), list_of_Nodes[i].getLong(), list_of_Nodes[k].getLat(), list_of_Nodes[k].getLong());
//Get the names of the two Nodes.
node_1_name = list_of_Nodes[i].getName();
node_2_name = list_of_Nodes[k].getName();
//Check to see if the currentMax if less or greather than the tempDist.
if (tempDist > currentMax)
{
currentMax = tempDist;
}
}
}
returntrue;
If anyone could point out where I am going wrong that would be great.