I am writing below the error message reflected:
??? Error using ==> check_matlab_bgl at 50the matrix A must be sparse. (See set_matlab_bgl_default.)Error in ==> components at 39if check, check_matlab_bgl(A,struct()); endError in ==> StoreADJMatrix at 83comps = components(adjmat)%%%%%%%%%%%%%%Part of the code
% I have also attached matfile having adjmat matrix for no of nodes 50 in 200X 200 area
R=29;row=1;E=zeros(0,0);format short gfor i=1:noOfNodesfor j=1:noOfNodesdistance(i,j) = sqrt((Xd(i)-Xd(j))^2 + (Yd(i)-Yd(j))^2);if distance (i,j) <= R && (i~=j)% row=row+1;
matrix(i, j) = 1; % there is a link;
E(row,1)=i;E(row,2)=j;E(row,3)=distance(i,j);row=row+1;elsematrix(i,j) = 0;end;end;endsave('NodeGraph.mat','matrix','distance','E','-append')%for each pair (i,j) in the connectivity list E, set adj(i,j) to 1
fromlist = E(:,1);tolist = E(:,2);adjmat=zeros(noOfNodes,noOfNodes);fromtoidx = sub2ind([noOfNodes,noOfNodes], fromlist, tolist); %as linear indices
adjmat(fromtoidx) = 1;tofromidx = sub2ind([noOfNodes,noOfNodes], tolist, fromlist); %connections are bidirectional
adjmat(tofromidx) = 1;save('NodeGraph.mat','adjmat','-append')%nMST=grMinSpanTree(E)
gplot(adjmat,coords(:,:),'-*')grid onaxis squarecomps = components(adjmat)%%%%%%%%%%%%%%
Best Answer