File size: 1,738 Bytes
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function visualize_connectedNodes()
    % Read the data and create the connections map
    data = readtable('MGREL.RRF', 'Delimiter', '|', 'FileType', 'text', 'NumHeaderLines', 0, 'VariableNamingRule', 'preserve');
    data = renamevars(data, '#CUI1', 'CUI1');
    data = data(1:1000,:); 

    connectionsMap = containers.Map('KeyType', 'char', 'ValueType', 'char');

    for i = 1:size(data, 1)
        node = data{i, 'CUI1'};
        char_node = char(node);

        connectedNode = data{i, 'CUI2'};
        char_connectedNode = char(connectedNode);

        if isKey(connectionsMap, char_node)
            connectionsMap(char_node) = [connectionsMap(char_node), '|', char_connectedNode];
        else
            connectionsMap(char_node) = char_connectedNode;
        end
    end

    % Prompt the user for input
    prompt = 'Enter a key:';
    dlgtitle = 'Input';
    dims = [1 35];
    definput = {'C0000727'};
    userInput = inputdlg(prompt, dlgtitle, dims, definput);

    % Check if user canceled the dialog
    if isempty(userInput)
        disp('User canceled the operation.');
        return;
    end

    key = userInput{1};

    % Check if the key exists in the connectionsMap
    if isKey(connectionsMap, key)
        % Split the value string by the pipe symbol '|'
        split_values = strsplit(connectionsMap(key), '|');

        % Display the connected nodes
        disp(split_values);

        % Visualize the graph
        G = graph();
        for i = 1:length(split_values)
            G = addedge(G, key, split_values{i});
        end

        figure;
        plot(G, 'Layout', 'force');
        title('Graph of Connected Nodes');
    else
        disp('Key does not exist in the connectionsMap.');
    end
end