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 commentaire

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

Connectez-vous pour commenter.

 Réponse acceptée

Steven Lord
Steven Lord le 2 Mai 2020

0 votes

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

2 commentaires

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Networks dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by