If this path is unvisited then and if the cost is less then update the cost
if ( j != i && ( visitedRouteList [ j ] == 0 ) ) { if ( tsp [ i ] [ j ] < min ) { min = tsp [ i ] [ j ] ; route [ counter ] = j + 1 ; } } j ++ ;