Please can someone help me the plotting of data from a gml file, never worked with such file before. The dataset can be downloaded from http://www-personal.umich.edu/~mejn/netdata/dolphins.zip

 채택된 답변

KSSV
KSSV 2018년 9월 25일
편집: KSSV 2018년 9월 25일

0 개 추천

fileName = 'dolphins.gml';
inputfile = fopen(fileName);
l=0;
k=1;
A = zeros([],2) ;
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');
if ~isempty(nums)
if l==1
l=0;
A(k,2)=str2double(nums{1});
k=k+1;
continue;
end
A(k,1)=str2double(nums{1});
l=1;
else
l=0;
continue;
end
end
fclose(inputfile) ;
G = zeros([],[]) ;
for i=1:length(A)
G(A(i,1)+1,A(i,2)+1) = 1;
G(A(i,2)+1,A(i,1)+1) = 1;
end
figure
g = graph(G) ;
plot(g)
figure
L=diag(sum(G))-G;
[v,~]=eig(L);
xy=v(:,[2 3]) ;
gplot(G,xy,'.-r')

댓글 수: 8

Isaac Osei Agyemang
Isaac Osei Agyemang 2018년 9월 25일
Please I've seen it before, I'm new to matlab and i want to plot the data in that file in a form of a graph, dont have any idea of that, can you help me.
KSSV
KSSV 2018년 9월 25일
The data is read and Adjacency matrix can be created.....can you show me how the output is? Any pictorial example?
Isaac Osei Agyemang
Isaac Osei Agyemang 2018년 9월 25일
this is how i'm expecting it in matlab, i used a visualizer called gephi to plot it, but i want to use matlab so i can compute some analysis the gephi can't do.
Isaac Osei Agyemang
Isaac Osei Agyemang 2018년 9월 25일
편집: Isaac Osei Agyemang 2018년 9월 25일
I get this error when i use the code you wrote.
Error using fgets Invalid file identifier. Use fopen to generate a valid file identifier.
Error in fgetl (line 32) [tline,lt] = fgets(fid);
Error in Dol (line 8) tline = fgetl(inputfile);
and when i changed it to fopen, it runs without any error but the graph does not show.
KSSV
KSSV 2018년 9월 25일
See to it that..the .gml file is present in the folder where code is run.
Isaac Osei Agyemang
Isaac Osei Agyemang 2018년 9월 26일
Please the file is in the same location but am not getting any output
KSSV
KSSV 2018년 9월 26일
You getting any error?
Isaac Osei Agyemang
Isaac Osei Agyemang 2018년 9월 26일
yes please, it runs without any output, I've got the dataset in a mat file, can I send it to you via email?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Graphics에 대해 자세히 알아보기

태그

질문:

2018년 9월 25일

댓글:

2018년 9월 26일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by