graph algorithms

Hello,
I want implement a graph algorithm. How could I create a graph and compute for example the matrix of the distance of the paths among all the nodes?

Respuestas (1)

vansh gandhi
vansh gandhi el 15 de Jun. de 2023

0 votos

To create a graph you can look into this documentation Graphs in MATLAB
This is how you can compute for the matrix of the distance of the paths among all the nodes:
G = graph(); % Create a graph
G = addnode(G, 5); % Add 5 nodes to the graph
G = addedge(G, [1 1 2 2 3 4], [2 3 3 4 5 5]); % Add edges to the graph
Distances(G, 'Method' , 'unweighted') % Compute the matrix of distances

Categorías

Más información sobre Networks en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 29 de Mzo. de 2012

Respondida:

el 15 de Jun. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by