clc,clear
a=zeros(6);
a(1,2)=20;
a(2,1)=20;

a(1,5)=15;
a(5,1)=15;

a(2,3)=20;
a(3,2)=20;

a(2,4)=60;
a(4,2)=60;

a(2,5)=25;
a(5,2)=25;

a(3,4)=30;
a(4,3)=30;

a(3,5)=18;
a(5,3)=18;

a(5,6)=15;
a(6,5)=15;


s=cellstr(strcat('销售点',int2str([1:6]')));
G=graph(a,s,'upper');
p=plot(G,"EdgeLabel",G.Edges.Weight);
min_max_dist = Inf; 
best= 0;
for i = 1:6 
    max_dist = 0; 
    for j = 1:6 
        if j ~= i 
          [path,distence]= shortestpath(G,i,j);  
            if distence > max_dist 
                max_dist = distence;  
            end  
        end  
    end 
    if max_dist < min_max_dist  
        min_max_dist = max_dist;  
        best= i;  
    end  
end    
disp('最佳仓库位置：');  
disp(s{best});  
 



