-
Notifications
You must be signed in to change notification settings - Fork 0
/
findshortest.m
40 lines (37 loc) · 958 Bytes
/
findshortest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function s=findshortest(list,framematrix,start,ending)
maxvalue=0;
s=[];
s(1)=start;
used=zeros(1,48);
used(6)=1;
caculatemin(s,list{s(1)});
function []=caculatemin(arr,candi)
if size(arr,2)==46
for k=1:size(candi,2)
if used(candi(k))==0 && candi(k)==ending
arr=[arr,candi(k)];
value = 0;
for l=1:size(arr,2)-1
value=value+framematrix(arr(l),arr(l+1));
end
if value > maxvalue
s=arr
maxvalue=value
end
end
end
else
for k=1:size(candi,2)
if candi(k)==0
continue;
end
if used(candi(k))==0
tarr=[arr,candi(k)];
used(candi(k))=1;
caculatemin(tarr,list{candi(k)});
used(candi(k))=0;
end
end
end
end
end