% ___ Design :  Travelling Salesman Problem ________ 
% _________________________________________
% ______  Entfernungs- Matrix von 8 Städten  in Straßen-[km]  _____

clear all; close all; 
fprintf('\n'  );
disp(['°°°°°°°°°°°°°° S T A R T °°°°°°°°°°°°°°°°°°°° ',date,' °°°°°°°°°°°°°°°°°°°°°'])
fprintf('\n'  );
fprintf( '\t   Bestimmung Entfernung - Matrix  Kurierdienste  ');
fprintf('\n')   
F = {'::::','===','===','===','===','===','===',' ===','::::' } ;
for i = 1 : length(F)
	fprintf(1,'\t %1s', F{i});
end
fprintf('\n'  );

% > Stuttgart  Frankfurt  Würzburg  Berlin  Nürnberg  Regensburg  Passau  Ulm 
% :::: > Start :  Stuttgart
% :::: > Ziel :  Stuttgart

D =   [	   inf  633	   214   212   395	 148  297	 93; ...
            633   inf	  539	437	  616	492  496   614; ...
            214	 539	 inf	229	  445	126	 331   295; ...
            212	 437	229	   inf    227	110  112   193; ...
            395	 616	445	  227	 inf	335	 119   316; ...
            148	 492	126	  110	324	   inf   210   191; ...
            297	 496	331	  112	119	  210	inf    220; ...
              93  614	 295   193	  316  191	220    inf ];
% ::::::::::::::::> Control : Symmetrie der Matrix ::::::::::::::::::::::.
Tup = triu(D,1);
Tdo = tril(D,-1);
Test = Tdo -Tup';

if isempty(Test)                 % > [ ~=0]   oder mit [isempty ]
    disp('alles O.K.')
else
    error(' Distance between Cities not correct')
    break
end

% :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
%  Compute the shortest distance between all pair of nodes (D is the weighted
%  adjacency matrix).  >> non connected vectices must have Inf value
N = length(D);
for k=1:N
   D = min(D,repmat(D(:,k),[1 N])+repmat(D(k,:),[N 1]));
end
D1 = D
