Filter löschen
Filter löschen

Shortest Path calculation problem

4 Ansichten (letzte 30 Tage)
vimal r
vimal r am 17 Mär. 2020
Kommentiert: KSSV am 17 Mär. 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 Kommentar
KSSV
KSSV am 17 Mär. 2020
This is a octave code.....remove the line pkg load io

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by