Graph Partition: Spectral Partitioning
Table of Contents
Graph $G(E,V)$ partition: $V=V_1 + V_2$
%%html
<center><iframe src="https://www.youtube.com/embed/fPaOkWzJySQ"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
%%html
<center><iframe src="https://www.youtube.com/embed/BgCukCFZr9A"
width="560" height="315" frameborder="0" allowfullscreen></iframe></center>
Solution
Solution using Lagrange multipliers (optional)
A = [0 0 0 1 1 0 1 0;
0 0 0 1 0 1 0 1;
0 0 0 0 1 0 1 0;
1 1 0 0 0 1 0 0;
1 0 1 0 0 0 1 0;
0 1 0 1 0 0 0 1;
1 0 1 0 1 0 0 0;
0 1 0 0 0 1 0 0];
L = diag(sum(A,1)) - A;
[V,D] = eig(L);
diag(D)
[ds,Y] = sort(diag(D));
u2 = V(:,Y(2))
[v2,I] = sort(u2,'ascend');
%plot -s 700,300
subplot(1,2,1), plot(1:8,u2,'.'), xlim([0 9])
subplot(1,2,2), plot(1:8,v2,'.'), xlim([0 9])
A
B = A(I,I)
I
%plot -s 700,300
subplot(1,2,1), spy(A)
subplot(1,2,2), spy(B)
%plot -s 700,300
A = [0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0;
0 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0;
0 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0;
0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0;
1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0;
0 0 1 0 1 0 1 0 0 1 0 0 0 0 0 0;
1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0;
0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0;
0 1 0 0 0 0 0 0 0 1 1 1 1 0 1 0;
0 0 0 0 0 1 0 1 1 0 1 0 0 0 1 0;
0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0;
0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0;
0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0;
0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 1;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0;
];
L = diag(sum(A,1)) - A;
[V,D] = eig(L);
u2 = V(:,2);
[v2,I] = sort(u2,'ascend');
subplot(1,2,1), plot(1:16,u2,'.'), xlim([0 17])
subplot(1,2,2), plot(1:16,v2,'.'), xlim([0 17])
spy(A(I,I))
S = 1:16;
S(u2<0)
%plot -s 560,420
[A,~] = xlsread([pwd,'\data_files\matrix_noheader.csv']);
spy(A)
L = diag(sum(A,1)) - A;
[V,D] = eig(L);
plot(1:34,diag(D),'.'), title('eigenvalues')
%plot -s 700,300
u2 = V(:,2);
[v2,I] = sort(u2,'ascend');
subplot(1,2,1), plot(1:34,u2,'.'), title('2nd smallest eigenvector','fontsize',8), xlim([0 35])
subplot(1,2,2), plot(1:34,v2,'.'), title('sorted','fontsize',8), xlim([0 35])
%plot -s 700,300
subplot(1,2,1), spy(A)
subplot(1,