I am attempting to create the adjacency matrix of a star tree: https://en.wikipedia.org/wiki/Star_(graph_theory)
I have the following for a 10 vertices graph:
AdjacencyMatrix = [0 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0]; % sets the adjacency matrix
Is there a quicker way to create a matrix like this but of a larger scale e.g. 100x100?

 採用された回答

Star Strider
Star Strider 2017 年 1 月 8 日

1 投票

One approach:
AdjacencyMatrix = zeros(100);
AdjacencyMatrix(2:size(AdjacencyMatrix,1), 1) = 1;
AdjacencyMatrix(1, 2:size(AdjacencyMatrix,2)) = 1;

2 件のコメント

MK96
MK96 2017 年 1 月 8 日
Thanks
Star Strider
Star Strider 2017 年 1 月 8 日
My pleasure.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLinear Algebra についてさらに検索

製品

質問済み:

2017 年 1 月 8 日

コメント済み:

2017 年 1 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by