So cel mai mare cost minim e maximul din linia 1. Apoi, poti folosi tehnica DeI :
void descompune(int x,int y)
{
int stop=0, k=1;
while(!stop && k<N)
{
if((A[x][k]+A[k][y] == A[x][y])&&(x!=k && y!=k))
{
descompune(x,k);
descompune(k,y);
stop=1;
}
k++;
}
if(stop)
prelucreaza k;
}
Apelezi descompune(1, nodul_cu_pricina)
;