how to use the figure instead of biograph in graphshortestpath
    6 views (last 30 days)
  
       Show older comments
    
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 Comments
Answers (1)
  Walter Roberson
      
      
 on 27 May 2015
        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 Comments
  Walter Roberson
      
      
 on 27 May 2015
				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.
See Also
Categories
				Find more on Creating and Concatenating Matrices in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
