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 Kommentar

Ameer Hamza
Ameer Hamza am 2 Mai 2020
Can you share an example code that can recreate this error?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Steven Lord
Steven Lord am 2 Mai 2020

0 Stimmen

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

2 Kommentare

s = {'1' '2'};
t = {'2' '3'};
G = graph(s,t);
A = adjacency(G);
This is my code, I'm still getting the same error
Can you show the output of
which graph
which adjacency

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Networks finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by