how to use the figure instead of biograph in graphshortestpath
조회 수: 1 (최근 30일)
이전 댓글 표시
in graphshortestpath biograph is not work proprly please tell me how to use the figure instead of biograph
when i used graphshortestpath used biograph does not show error are encounter is like
Error using biograph (line 155)
CM must be a sparse or full square matrix
my code is
every_node_dist =
1.0000 2.0000 59.6129
1.0000 3.0000 60.2274
1.0000 4.0000 82.2382
1.0000 5.0000 40.5560
2.0000 3.0000 50.9495
2.0000 4.0000 30.4809
2.0000 5.0000 82.0061
3.0000 4.0000 46.1959
3.0000 5.0000 51.8620
4.0000 5.0000 92.7230
w=[every_node_dist(:,3)]'
w =
59.6129 60.2274 82.2382 40.5560 50.9495 30.4809 82.0061 46.1959 51.8620 92.7230
source_node_no=[every_node_dist(:,1)]'
source_node_no =
1 1 1 1 2 2 2 3 3 4
desti_node_no=[every_node_dist(:,2)]'
desti_node_no =
2 3 4 5 3 4 5 4 5 5
DG = sparse(source_node_no,destination_node_no,w)
DG =
(1,2) 59.6129
(1,3) 60.2274
(2,3) 50.9495
(1,4) 82.2382
(2,4) 30.4809
(3,4) 46.1959
(1,5) 40.5560
(2,5) 82.0061
(3,5) 51.8620
(4,5) 92.7230
h = view(biograph(DG,[],'ShowWeights','on'))
Error using biograph (line 155)
CM must be a sparse or full square matrix
please some one help me sort out problem
댓글 수: 0
답변 (1개)
Walter Roberson
2015년 5월 27일
maxnode = max([source_node_no, destination_node_no]);
DG = sparse(source_node_no, destination_node_no, w, maxnode, maxnode);
Your problem was that you were not creating a square sparse matrix.
댓글 수: 4
Walter Roberson
2015년 5월 27일
How do you delete the column from the matrix? And why? Empty columns take only a few bytes of storage in sparse matrices, and most algorithms require that the adjacency matrix be square.
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Data Preparation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!