File size: 1,218 Bytes
93e1b64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
% 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);