Azzera filtri
Azzera filtri

Shortest Path calculation problem

4 visualizzazioni (ultimi 30 giorni)
vimal r
vimal r il 17 Mar 2020
Commentato: KSSV il 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 Commento
KSSV
KSSV il 17 Mar 2020
This is a octave code.....remove the line pkg load io

Accedi per commentare.

Risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by