graph algorithms

조회 수: 1 (최근 30일)
john
john 2012년 3월 29일
답변: vansh gandhi 2023년 6월 15일
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?

답변 (1개)

vansh gandhi
vansh gandhi 2023년 6월 15일
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

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by