Clear Filters
Clear Filters

Shortest Path calculation problem

4 views (last 30 days)
vimal r
vimal r on 17 Mar 2020
Commented: KSSV on 17 Mar 2020
%mat = [0,10,15,20;10,0,35,25;15,35,0,30;20,25,30,0]
pkg load io
mat = xlsread('distance matrix2.xlsx')
source = 1
len = length(mat)
vertex = zeros(1,len-1)
for i=1:len-1
vertex(i)=i+1
end
minpath = intmax
num = factorial(len-1)
count=0
while(count<num)
current_pathweight=0
k=source
for i=1:len-1
current_pathweight=current_pathweight+mat(k,vertex(i))
k=vertex(i)
end
current_pathweight=current_pathweight+mat(k,source)
if(current_pathweight<minpath)
minpath=current_pathweight
end
vertex=myperms(vertex)
count = count+1
end
when i run shows error:
Undefined function or variable 'pkg'.
Error in main (line 2)
pkg load io
  1 Comment
KSSV
KSSV on 17 Mar 2020
This is a octave code.....remove the line pkg load io

Sign in to comment.

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!