I am trying to build a network graph with word adjacency data. But I am getting the error "Target must be a dense double array of node indices". Following is my code:
fileName = 'adjnoun.gml';
inputfile = fopen(fileName);
A=[];
l=0;
k=1;
while 1
% Get a line from the input file
tline = fgetl(inputfile);
% Quit if end of file
if ~ischar(tline)
break
end
nums = regexp(tline,'\d+','match'); %get number from string
if length(nums)
if l==1
l=0;
A(k,2)=str2num(nums{1});
k=k+1;
continue;
end
A(k,1)=str2num(nums{1});
l=1;
else
l=0;
continue;
end
end
A= sort(A);
g = graph(A(:,1),A(:,2));
A is 425X2 double matrix. When I am trying to create the graph g = graph(A(:,1),A(:,2))
, it is throwing the error.