187
+ epsilon/(n-1) * (ones(n,n)-eye(n));
end
% compute principal left eigenvector of RW - the importance in a
% directed graph
[pie, eigpie] = eigs(RW.’,1);
importance = abs(pie);
% build symmetric directed Laplacian
imphalf = diag(sqrt(importance));
impminushalf = sparse(n,n);
for i = 1:n
if importance(i) > 1e-10;
impminushalf(i,i) = 1./imphalf(i,i);
end
end
L = speye(n,n) - (imphalf * RW * impminushalf
+ impminushalf * RW’ * imphalf)/2;
if nargin < 3
[Vector,E] = eig(L);
[e,IX] = sort(diag(E));
Vector = Vector(:,IX);
else
[Vector,E] = eigs(2 * speye(n)-L,k);
e = 2 - diag(E);
end
Vector = impminushalf * Vector;
varargout{1} = Vector;
varargout{2} = e;
varargout{3} = importance;
function [varargout] = SignedLaplacian(posW, negW, type, k)
% Spectral embedding of a signed adjacency matrix
%
% The matrices posW and negW are the weighted adjacency matrices of
% the positive and negative edges of the network
% type= un or empty: unnormalized graph Laplacian
%
SNS: simple normalized signed graph Laplacian
%
BNS: balanced normalized signed graph Laplacian
%
% k = cluster the graph into k groups (default is disabled)
%
% Vector = eigenvector matrix for embedding
% E = the diagonal matrix of the Laplacian eigenvalues
%
% varargout = cell array
%
1: Vector
%
2: E
Précédent

- 208/231

Suivant