klinic / graph_analysis.m
acmc
First commit in HuggingFace
93e1b64
raw
history blame
No virus
1.22 kB
% Read the CSV file
data = readtable('MGREL.RRF', Delimiter='|', FileType='text', NumHeaderLines=0, VariableNamingRule='preserve');
data = renamevars(data,"#CUI1","CUI1");
data = data(1:1000,:);
ids_1 = data.CUI1;
for k = 1 : length(ids_1)
cellContents = ids_1{k};
% Truncate and stick back into the cell
ids_1{k} = cellContents(2:end);
end
ids_1 = str2double(ids_1);
ids_2 = data.CUI2;
ids_2 = data.CUI1(2:end);
for k = 1 : length(ids_2)
cellContents = ids_2{k};
% Truncate and stick back into the cell
ids_2{k} = cellContents(2:end);
end
ids_2 = str2double(ids_2);
ids_1 = ids_1(1:end-1);
ids_2 = ids_2(2:end);
% Get the number of unique nodes
%nodes = unique([ids_1; ids_2]);
%num_nodes = length(nodes);
% Initialize sparse adjacency matrix
%A = sparse(ids_1, ids_2, 1, max(ids_2), max(ids_2));
% Display adjacency matrix
%disp(A);
%G = digraph(A);
G = digraph(ids_1, ids_2);
[bin,binsize] = conncomp(G,'Type','weak');
bin(1:100)
size(unique(bin))
max(binsize)
pg_ranks = centrality(G,'pagerank');
G.Nodes.PageRank = pg_ranks;
%hub_ranks = centrality(G,'hubs');
%auth_ranks = centrality(G,'authorities');
%G.Nodes.Hubs = hub_ranks;
%G.Nodes.Authorities = auth_ranks;
G.Nodes
%plot(G);