Spaces:
Sleeping
Sleeping
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'); |