How to convert a graph to adjacency matrix?

Hi. I've created a graph G in MATLAB. But when I type A = adjacency(G), I get this error:
Unable to use a value of type 'graph' as an index.

1 件のコメント

Ameer Hamza
Ameer Hamza 2020 年 5 月 2 日
Can you share an example code that can recreate this error?

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

 採用された回答

Steven Lord
Steven Lord 2020 年 5 月 2 日

0 投票

You've created a variable named adjacency that is taking precedence over the adjacency method for graph objects. Rename the variable.

2 件のコメント

Nathan Tilley
Nathan Tilley 2020 年 5 月 2 日
s = {'1' '2'};
t = {'2' '3'};
G = graph(s,t);
A = adjacency(G);
This is my code, I'm still getting the same error
Ameer Hamza
Ameer Hamza 2020 年 5 月 2 日
Can you show the output of
which graph
which adjacency

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by