필터 지우기
필터 지우기

How to plot a path in special order in an complete graph?

조회 수: 2 (최근 30일)
Marlon Ulbort
Marlon Ulbort 2021년 6월 26일
댓글: Marlon Ulbort 2021년 6월 26일
Dear Community,
For example, given ist a prah G with 29 nodes and 406 edges. An optimal solution of the travelings Salesman Problem is given in a vector a including every node in special order, plus the first node again to complete the cycle. So vector a consists 30 but 29 entries.
A=triu(magic(29));%adjacency matrix
G=graph(A);
a=[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 1];
Is there an easy way to plot the tour, highlight the tour just by feeding a?

채택된 답변

Chunru
Chunru 2021년 6월 26일
A=triu(magic(6)); % adjacency matrix
G=digraph(A); % for digraph
h=plot(G); % plot graph
a = [1:6 1]; % tour
highlight(h, a, 'EdgeColor', 'g'); % Note that 6->1 is not a path
  댓글 수: 1
Marlon Ulbort
Marlon Ulbort 2021년 6월 26일
Upsi, thats an easy answer... embarrassing i didnt tried it before...
Thanks alot! Great help :--)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by