function [ d index1 index2 ] = Dijkstra1(a)
%a 表示图的权值矩阵
% d 表示所求最短路径权和
%index1 表示标号顶点顺序
%index1 表示标号顶点索引
%% 参数初始化
M = max(max(a));
pb = zeros(1,length(a));
pb(1) = 1;
index1 = 1;
d(1:length(a)) = M ;
d(1) = 0;
temp = 1;
%% 更新d并记录顶点顺序和索引
while sum(pb) < length(a)
tb = find(pb == 0);
d(tb) = min(d(tb),d(temp) + a(temp,tb));
tmpb = find(d(tb) == min(d(tb)));
temp = tb(tmpb(1));
pb(temp) = 1;
index1 = [index1,temp];
index = index1(find(d(index1) == d(temp) - a(temp,index1)));
if length(index)>=2;
index = index(1);
end
index2(temp) = index;
end
end