-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_matching.m
More file actions
66 lines (54 loc) · 1.35 KB
/
Copy pathplot_matching.m
File metadata and controls
66 lines (54 loc) · 1.35 KB
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
60
61
62
63
64
65
66
function plot_matching(adjacency_matrix, level, pair, view_vxs)
matching_flag = false;
if ~isempty(pair)
matching_flag = true;
end
level_flag = false;
if ~isempty(level)
level_flag = true;
end
num_nodes = length(adjacency_matrix(:,1));
if ~isempty(view_vxs)
delete_indices = true(1,num_nodes);
delete_indices(view_vxs) = false;
adjacency_matrix(delete_indices,:) = 0;
adjacency_matrix(:,delete_indices) = 0;
end
if level_flag
x = zeros(1,num_nodes);
y = zeros(1,num_nodes);
for k = 0: max(level)
lev = find(level==k);
l = length(lev);
x0 = 0;
for i = lev
x(i) = x0;
x0 = x0+(1+.3*rand)/l^1.25;
y(i) = k;
end
end
xy = [x;y]';
end
if ~level_flag
theta = linspace(0,2*pi,num_nodes+1);
theta = theta(1:num_nodes);
x = sin(theta);
y = cos(theta);
xy = [x;y]';
end
gplot(adjacency_matrix,xy,'-*');
axis([min(xy(:,1))-.25, max(xy(:,1))+.25, min(xy(:,2))-.25, max(xy(:,2))+.25]);
hold on;
for i = 1: num_nodes
text(x(i),y(i)+.05,num2str(i))
end
if matching_flag
matching_matrix = zeros(num_nodes);
for i = 1: length(pair)
if pair(i) <= num_nodes
matching_matrix(i,pair(i)) = 1;
end
end
matching_matrix = matching_matrix & adjacency_matrix;
gplot(matching_matrix,xy,'r-')
end