How to find out TSP of a graph.

조회 수: 2(최근 30일)
Ashish Verma
Ashish Verma 2022년 7월 28일
답변: Bruno Luong 2022년 7월 28일
I have 5 points in a graph and need to find TSP
s = [1 1 1 1 2 2 2 3 3 4 ]
t= [ 2 3 4 5 3 4 5 4 5 5]
G = graph(s,t);
G.Edges.Weight = [ 10 21 3 8 9 10 12 5 7 2 ];

답변(2개)

Sam Chak
Sam Chak 2022년 7월 28일
You want to plot the graph like this?
s = [1 1 1 1 2 2 2 3 3 4];
t = [2 3 4 5 3 4 5 4 5 5];
weights = [10 21 3 8 9 10 12 5 7 2];
G = graph(s, t, weights);
plot(G, 'EdgeLabel', G.Edges.Weight)
  댓글 수: 1
Ashish Verma
Ashish Verma 2022년 7월 28일
Actually no, i have that graph, from this graph i want to find TSP (from point 1 to 5) means travelling all vertices with minimum cost.

댓글을 달려면 로그인하십시오.


Bruno Luong
Bruno Luong 2022년 7월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by