-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdatePlot.m
More file actions
39 lines (33 loc) · 757 Bytes
/
updatePlot.m
File metadata and controls
39 lines (33 loc) · 757 Bytes
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
function updatePlot(ax, A, nodes)
numNodes = length(nodes);
% Clear axes
cla(ax);
hold(ax, 'on');
% Draw all edges
for i = 1:numNodes
for j = i+1:numNodes
if A(i,j) == 1
ni = nodes{i};
nj = nodes{j};
plot(ax, ...
[ni.x, nj.x], ...
[ni.y, nj.y], ...
'k-', 'LineWidth', 1.5);
end
end
end
% Draw all nodes as objects
for i = 1:numNodes
node = nodes{i};
h = plot(ax, ...
node.x, node.y, ...
node.shape, ...
'MarkerSize', 10, ...
'MarkerFaceColor', node.color, ...
'MarkerEdgeColor', 'k');
h.ButtonDownFcn = @(src, event) onNodeClick(node.id);
end
axis(ax, 'equal');
axis(ax, 'off');
drawnow;
end