File size: 1,483 Bytes
90c8ced
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1fb895a
90c8ced
a6bd112
90c8ced
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

function display_elementsForKey(connectionsMap, key)
    % Check if the key exists in the connectionsMap
    if isKey(connectionsMap, key)
        % Get the value associated with the key
        value = connectionsMap(key);
        
        % Split the value string by the pipe symbol '|'
        split_values = strsplit(value, '|');
        
        % Display all elements associated with the key
        disp(split_values);
    else
        disp('Key does not exist in the connectionsMap.');
    end
end

data = readtable('MGREL.RRF', Delimiter='|', FileType='text', NumHeaderLines=0, VariableNamingRule='preserve');
data = renamevars(data,"#CUI1","CUI1");
data = data(1:2000,:); 

% Create a Map to store connections
connectionsMap = containers.Map('KeyType','char', 'ValueType','any');

% Iterate through the connections matrix
for i = 1:size(data, 1)
    % Extract node and connected node
    node = data{i, 'CUI1'};
    char_node = char(node);

    connectedNode = data{i, 'CUI2'};
    char_connectedNode = char(connectedNode);
    
    % Check if the node is already a key in the map
    if isKey(connectionsMap, char_node)
        % If the node exists, append the connected node to its list
        connectionsMap(char_node) = [connectionsMap(char_node),'|', char_connectedNode];
    else
        % If the node doesn't exist, create a new key-value pair
        connectionsMap(char_node) = char_connectedNode;
    end
end

display_elementsForKey(connectionsMap, 'C0000727');