need to create a 15X15 matrix for a graph. with diagonal values as 1 and adjacent edges for a graph AS 1 AND all the other values of the matrix as zeros.

Respuestas (1)

Walter Roberson
Walter Roberson el 14 de Dic. de 2022
Use graph() or digraph() with the s, t input form. s should contain a list of edge source node numbers and t should contain the matching edge target node numbers. The s and t should also a section listing all of the node numbers and t the same list, so that an edge is built between each node and itself.
Once this is done, ask for the adjacency matrix of the graph() object.
There are certainly other ways to create the array. For example if you have the s and t as described then
accumarray([s(:),t(:)], 1)

Categorías

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

Etiquetas

Preguntada:

el 14 de Dic. de 2022

Respondida:

el 14 de Dic. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by