I have written piece of Code for controlling that whether the Answer is a complete Cycle(Hamiltonian Cycle) or it is just a Sub-tour in Travelling Salesman Problem. Suppose that we have an Answer which starts from City"1", if we have such a Cycle then "flag=1".

Any Help will be appreciated.

Code: Select all

```
loop(i$(ord(i)<>1),
if(x.l('1',i)=1,
loop((j,v)$((ord(i)<>ord(j)) and (ord(j)<>ord(v)) and ord(i)<>ord(v)),
if(x.l(i,j)=1 and x.l(j,v)=1,
loop(y$(ord(y)<>1),
if(x.l(y,'1')=1,
flag=1;
);
);
);
);
);
);
);
);
```