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 comentario

Ameer Hamza
Ameer Hamza el 2 de Mayo de 2020
Can you share an example code that can recreate this error?

Iniciar sesión para comentar.

 Respuesta aceptada

Steven Lord
Steven Lord el 2 de Mayo de 2020

0 votos

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

2 comentarios

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graph and Network Algorithms en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 1 de Mayo de 2020

Comentada:

el 2 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by