Hi. I have an array for a TSP problem like this A = [1 2 3 4 5] where 1 2 3 shows the city number. I want to know if there's a function in matlab that gives the edge so E = [[1 2], [2 3], [3 4], [4 1]]. Is there a simple way to create such an array like that? since I have 700 arrays with 100x iterations. Thanks

 採用された回答

OCDER
OCDER 2018 年 5 月 23 日

0 投票

A = 1:4;
E = [A(1) repelem(A(2:end), 2) A(1)];
E =
1 2 2 3 3 4 4 1

1 件のコメント

Rajib Deyana
Rajib Deyana 2018 年 5 月 23 日
Great. Thabks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraph and Network Algorithms についてさらに検索

タグ

質問済み:

2018 年 5 月 23 日

コメント済み:

2018 年 5 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by