code for assign the weight in a graph
조회 수: 2 (최근 30일)
이전 댓글 표시
Using adjacency matrix a graph is created, now i want to assign the weight on the edges of graph. Could anybody tell me the code to assign the weight in a graph.
댓글 수: 0
답변 (1개)
Vishnu
2023년 7월 12일
The instructions provided to add weights to a graph in MATLAB documentation are as follows:-
A = [0 5 3 0;0 0 1 2; 0 0 0 11; 0 0 0 0];
G = graph(A,'lower');
G.Edges.Weight = [10 20 30 40 50]';
As you can see in this example we have created a graph using an asymmetric adjacency matrix. Using the graph object returned by graph() we can add weights to its edges. for further reading please visit:- Graph Documentation
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!