hello friends
i wanna know is this algorithm for Travelling salesman problem (TSP) correct ? if isn't help me for correct algorithm plz ?
tnx

int tsp(int **adjMatrix, int numberPoints)
{
    for (int i = 0; i < numberPoints; i++) 
        for (int j = 0; j < numberPoints; j++) 
            for (int k = 0; k < numberPoints; k++)
                if (adjMatrix[i][k] + adjMatrix[k][j] < adjMatrix[i][j])
                    adjMatrix[i][j] = adjMatrix[i][k] + adjMatrix[k][j];

    int min = OO;

    for (int i = 0; i < numberPoints; i++) 
        for (int j = 0; j < numberPoints; j++) 
            if (adjMatrix[i][j] + adjMatrix[j][i] < min)
                min = adjMatrix[i][j] + adjMatrix[j][i];

    return min;
}

Sigh... I see that your first problem is that you don't understand C syntax, especially with regard to pointer arithmetic... Where did you get this code and if you wrote it yourself, where did you get the algorithm? Start with that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.