189
display(’Simple normalized signed graph Laplacian decomposition’);
L = Dpos - posW - Dneg + negW;
D = Dpos + Dneg;
D2 = zeros(n,n);
for i=1:n
if D(i,i) ˜= 0
D2(i,i) = 1/D(i,i)ˆ0.5;
end
end
Lsym = D2 * L * D2; % L=Dˆ(-0.5) * L * Dˆ(-0.5);
if k == n
[Vector,eigenvalue] = eig(Lsym);
E = diag(eigenvalue);
[E,IXY] = sort(E,1,’ascend’);
Vector = Vector(:,IXY);
else
[Vector,eigenvalue] = eigs(2 * eye(n)-Lsym,k);
E = 2 - diag(eigenvalue);
end
Vector = D2 * Vector;
varargout{1} = Vector;
varargout{2} = E;
% balanced normalized signed graph Laplacian
elseif strcmp(type,’BNS’) || strcmp(type,’Bns’) || strcmp(type,’bns’)
display(’Balanced normalized signed graph Laplacian decomposition’);
L = Dpos - posW + negW;
D = Dpos + Dneg;
D2 = zeros(n,n);
for i=1:n
if D(i,i) ˜= 0
D2(i,i) = 1/D(i,i)ˆ0.5;
end
end
Lsym = D2 * L * D2; %L=Dˆ(-0.5) * L * Dˆ(-0.5);
if k == n
[Vector,eigenvalue] = eig(Lsym);
E = diag(eigenvalue);
[E,IXY] = sort(E,1,’ascend’);
Vector = Vector(:,IXY);
else
[Vector,eigenvalue] = eigs(2 * eye(n) - Lsym,k);
E = 2 - diag(eigenvalue);
end
Vector = D2 * Vector;
varargout{1} = Vector;
varargout{2} = E;
else
error(’Type cannot be identified’);
end
function [varargout] = TypedDirLaplacian(W, k, LazyRate)
% Spectral embedding of a graph with directed typed edges
%
% n is the number of nodes, and c is the number of different edge
% types.
display(’Simple normalized signed graph Laplacian decomposition’);
L = Dpos - posW - Dneg + negW;
D = Dpos + Dneg;
D2 = zeros(n,n);
for i=1:n
if D(i,i) ˜= 0
D2(i,i) = 1/D(i,i)ˆ0.5;
end
end
Lsym = D2 * L * D2; % L=Dˆ(-0.5) * L * Dˆ(-0.5);
if k == n
[Vector,eigenvalue] = eig(Lsym);
E = diag(eigenvalue);
[E,IXY] = sort(E,1,’ascend’);
Vector = Vector(:,IXY);
else
[Vector,eigenvalue] = eigs(2 * eye(n)-Lsym,k);
E = 2 - diag(eigenvalue);
end
Vector = D2 * Vector;
varargout{1} = Vector;
varargout{2} = E;
% balanced normalized signed graph Laplacian
elseif strcmp(type,’BNS’) || strcmp(type,’Bns’) || strcmp(type,’bns’)
display(’Balanced normalized signed graph Laplacian decomposition’);
L = Dpos - posW + negW;
D = Dpos + Dneg;
D2 = zeros(n,n);
for i=1:n
if D(i,i) ˜= 0
D2(i,i) = 1/D(i,i)ˆ0.5;
end
end
Lsym = D2 * L * D2; %L=Dˆ(-0.5) * L * Dˆ(-0.5);
if k == n
[Vector,eigenvalue] = eig(Lsym);
E = diag(eigenvalue);
[E,IXY] = sort(E,1,’ascend’);
Vector = Vector(:,IXY);
else
[Vector,eigenvalue] = eigs(2 * eye(n) - Lsym,k);
E = 2 - diag(eigenvalue);
end
Vector = D2 * Vector;
varargout{1} = Vector;
varargout{2} = E;
else
error(’Type cannot be identified’);
end
function [varargout] = TypedDirLaplacian(W, k, LazyRate)
% Spectral embedding of a graph with directed typed edges
%
% n is the number of nodes, and c is the number of different edge
% types.
