Spaces:
Sleeping
Sleeping
Commit
·
90c8ced
1
Parent(s):
1e2e3b8
matlab
Browse files- .DS_Store +0 -0
- MATLAB/.DS_Store +0 -0
- MATLAB/main.m +44 -0
- MATLAB/test.m +58 -0
- MATLAB/visualize_app.mlapp +0 -0
- MATLAB/visualize_connectedNodes_continuous.m +61 -0
.DS_Store
CHANGED
|
Binary files a/.DS_Store and b/.DS_Store differ
|
|
|
MATLAB/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
MATLAB/main.m
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
function display_elementsForKey(connectionsMap, key)
|
| 3 |
+
% Check if the key exists in the connectionsMap
|
| 4 |
+
if isKey(connectionsMap, key)
|
| 5 |
+
% Get the value associated with the key
|
| 6 |
+
value = connectionsMap(key);
|
| 7 |
+
|
| 8 |
+
% Split the value string by the pipe symbol '|'
|
| 9 |
+
split_values = strsplit(value, '|');
|
| 10 |
+
|
| 11 |
+
% Display all elements associated with the key
|
| 12 |
+
disp(split_values);
|
| 13 |
+
else
|
| 14 |
+
disp('Key does not exist in the connectionsMap.');
|
| 15 |
+
end
|
| 16 |
+
end
|
| 17 |
+
|
| 18 |
+
data = readtable('MGREL.RRF', Delimiter='|', FileType='text', NumHeaderLines=0, VariableNamingRule='preserve');
|
| 19 |
+
data = renamevars(data,"#CUI1","CUI1");
|
| 20 |
+
data = data(1:1000,:);
|
| 21 |
+
|
| 22 |
+
% Create a Map to store connections
|
| 23 |
+
connectionsMap = containers.Map('KeyType','char', 'ValueType','any');
|
| 24 |
+
|
| 25 |
+
% Iterate through the connections matrix
|
| 26 |
+
for i = 1:size(data, 1)
|
| 27 |
+
% Extract node and connected node
|
| 28 |
+
node = data{i, 'CUI1'};
|
| 29 |
+
char_node = char(node);
|
| 30 |
+
|
| 31 |
+
connectedNode = data{i, 'CUI2'};
|
| 32 |
+
char_connectedNode = char(connectedNode);
|
| 33 |
+
|
| 34 |
+
% Check if the node is already a key in the map
|
| 35 |
+
if isKey(connectionsMap, char_node)
|
| 36 |
+
% If the node exists, append the connected node to its list
|
| 37 |
+
connectionsMap(char_node) = [connectionsMap(char_node),'|', char_connectedNode];
|
| 38 |
+
else
|
| 39 |
+
% If the node doesn't exist, create a new key-value pair
|
| 40 |
+
connectionsMap(char_node) = char_connectedNode;
|
| 41 |
+
end
|
| 42 |
+
end
|
| 43 |
+
|
| 44 |
+
display_elementsForKey(connectionsMap, 'C0000727');
|
MATLAB/test.m
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function visualize_connectedNodes()
|
| 2 |
+
% Read the data and create the connections map
|
| 3 |
+
data = readtable('MGREL.RRF', 'Delimiter', '|', 'FileType', 'text', 'NumHeaderLines', 0, 'VariableNamingRule', 'preserve');
|
| 4 |
+
data = renamevars(data, '#CUI1', 'CUI1');
|
| 5 |
+
data = data(1:1000,:);
|
| 6 |
+
|
| 7 |
+
connectionsMap = containers.Map('KeyType', 'char', 'ValueType', 'char');
|
| 8 |
+
|
| 9 |
+
for i = 1:size(data, 1)
|
| 10 |
+
node = data{i, 'CUI1'};
|
| 11 |
+
char_node = char(node);
|
| 12 |
+
|
| 13 |
+
connectedNode = data{i, 'CUI2'};
|
| 14 |
+
char_connectedNode = char(connectedNode);
|
| 15 |
+
|
| 16 |
+
if isKey(connectionsMap, char_node)
|
| 17 |
+
connectionsMap(char_node) = [connectionsMap(char_node), '|', char_connectedNode];
|
| 18 |
+
else
|
| 19 |
+
connectionsMap(char_node) = char_connectedNode;
|
| 20 |
+
end
|
| 21 |
+
end
|
| 22 |
+
|
| 23 |
+
% Prompt the user for input
|
| 24 |
+
prompt = 'Enter a key:';
|
| 25 |
+
dlgtitle = 'Input';
|
| 26 |
+
dims = [1 35];
|
| 27 |
+
definput = {'C0000727'};
|
| 28 |
+
userInput = inputdlg(prompt, dlgtitle, dims, definput);
|
| 29 |
+
|
| 30 |
+
% Check if user canceled the dialog
|
| 31 |
+
if isempty(userInput)
|
| 32 |
+
disp('User canceled the operation.');
|
| 33 |
+
return;
|
| 34 |
+
end
|
| 35 |
+
|
| 36 |
+
key = userInput{1};
|
| 37 |
+
|
| 38 |
+
% Check if the key exists in the connectionsMap
|
| 39 |
+
if isKey(connectionsMap, key)
|
| 40 |
+
% Split the value string by the pipe symbol '|'
|
| 41 |
+
split_values = strsplit(connectionsMap(key), '|');
|
| 42 |
+
|
| 43 |
+
% Display the connected nodes
|
| 44 |
+
disp(split_values);
|
| 45 |
+
|
| 46 |
+
% Visualize the graph
|
| 47 |
+
G = graph();
|
| 48 |
+
for i = 1:length(split_values)
|
| 49 |
+
G = addedge(G, key, split_values{i});
|
| 50 |
+
end
|
| 51 |
+
|
| 52 |
+
figure;
|
| 53 |
+
plot(G, 'Layout', 'force');
|
| 54 |
+
title('Graph of Connected Nodes');
|
| 55 |
+
else
|
| 56 |
+
disp('Key does not exist in the connectionsMap.');
|
| 57 |
+
end
|
| 58 |
+
end
|
MATLAB/visualize_app.mlapp
ADDED
|
Binary file (37.7 kB). View file
|
|
|
MATLAB/visualize_connectedNodes_continuous.m
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function visualize_connectedNodes_continuous()
|
| 2 |
+
% Read the data and create the connections map
|
| 3 |
+
data = readtable('MGREL.RRF', 'Delimiter', '|', 'FileType', 'text', 'NumHeaderLines', 0, 'VariableNamingRule', 'preserve');
|
| 4 |
+
data = renamevars(data, '#CUI1', 'CUI1');
|
| 5 |
+
data = data(1:10000,:);
|
| 6 |
+
|
| 7 |
+
connectionsMap = containers.Map('KeyType', 'char', 'ValueType', 'char');
|
| 8 |
+
|
| 9 |
+
for i = 1:size(data, 1)
|
| 10 |
+
node = data{i, 'CUI1'};
|
| 11 |
+
char_node = char(node);
|
| 12 |
+
|
| 13 |
+
connectedNode = data{i, 'CUI2'};
|
| 14 |
+
char_connectedNode = char(connectedNode);
|
| 15 |
+
|
| 16 |
+
if isKey(connectionsMap, char_node)
|
| 17 |
+
connectionsMap(char_node) = [connectionsMap(char_node), '|', char_connectedNode];
|
| 18 |
+
else
|
| 19 |
+
connectionsMap(char_node) = char_connectedNode;
|
| 20 |
+
end
|
| 21 |
+
end
|
| 22 |
+
|
| 23 |
+
% Loop for continuous interaction
|
| 24 |
+
while true
|
| 25 |
+
% Prompt the user for input
|
| 26 |
+
prompt = 'Enter a key (or type "exit" to quit):';
|
| 27 |
+
dlgtitle = 'Input';
|
| 28 |
+
dims = [1 50];
|
| 29 |
+
definput = {'C0000727'};
|
| 30 |
+
userInput = inputdlg(prompt, dlgtitle, dims, definput);
|
| 31 |
+
|
| 32 |
+
% Check if user canceled the dialog or typed "exit"
|
| 33 |
+
if isempty(userInput) || strcmp(userInput{1}, 'exit')
|
| 34 |
+
disp('Exiting...');
|
| 35 |
+
break;
|
| 36 |
+
end
|
| 37 |
+
|
| 38 |
+
key = userInput{1};
|
| 39 |
+
|
| 40 |
+
% Check if the key exists in the connectionsMap
|
| 41 |
+
if isKey(connectionsMap, key)
|
| 42 |
+
% Split the value string by the pipe symbol '|'
|
| 43 |
+
split_values = strsplit(connectionsMap(key), '|');
|
| 44 |
+
|
| 45 |
+
% Display the connected nodes
|
| 46 |
+
disp(split_values);
|
| 47 |
+
|
| 48 |
+
% Visualize the graph
|
| 49 |
+
G = graph();
|
| 50 |
+
for i = 1:length(split_values)
|
| 51 |
+
G = addedge(G, key, split_values{i});
|
| 52 |
+
end
|
| 53 |
+
|
| 54 |
+
figure;
|
| 55 |
+
plot(G, 'Layout', 'force');
|
| 56 |
+
title('Graph of Connected Nodes');
|
| 57 |
+
else
|
| 58 |
+
disp('Key does not exist in the connectionsMap.');
|
| 59 |
+
end
|
| 60 |
+
end
|
| 61 |
+
end
|