195
D = diag(crossweights);
Wp = [posW + D, D; D, D];
bigD = sparse(2 * n);
bigD(1:n, n+1:2 * n) = D;
bigD(n+1:2 * n, 1:n) = D;
Xpos = [ bigD, Wp; Wp’, bigD];
Xneg = sparse(4 * n);
Xneg(n+1:2 * n, 3 * n+1:4 * n) = negW;
Xneg(3 * n+1:4 * n, n+1:2 * n) = negW’;
%%%% compute our signed Laplacian
[Vector,e] = SignedLaplacian(Xpos,Xneg,type,k);
PosOut = Vector(1:n,:);
Negout = Vector(n+1:2 * n,:);
PosIn = Vector(2 * n+1:3 * n,:);
NegIn = Vector(3 * n+1:4 * n,:);
if nargout == 1
varargout{1} = Vector;
elseif nargout == 2
varargout{1} = Vector;
varargout{2} = e;
else
varargout{1} = PosOut;
varargout{2} = Negout;
varargout{3} = PosIn;
varargout{4} = NegIn;
varargout{5} = e;
varargout{6} = Xpos;
varargout{7} = Xneg;
end
function F = BCGE(W,Y,ew)
% Given a graph with some nodes labelled, build the enhanced
%
signed graph and embed it using out signed spectral embedding
%
% W: the n * n weighted adjacency matrix of a undirected graph.
% Y: an n * 2 label indication matrix, with value {0 1};
%
0 rows for unlabelled nodes.
% ew: [apw,anw] vector for positive and negative added edge weights
%
between labeled points; default value is [1,1].
[n,m] = size(Y);
% build the negative matrix with only one undirected edge.
negW = sparse(n+2,n+2);
negW(n+1,n+2) = ew(2);
negW(n+2,n+1) = ew(2);
% build the positive matrix from the adjacency matrix with
% added positive edges.
posW = sparse(n+2,n+2);
posW(1:n,1:n) = W;
posW(1:n,n+1) = ew(1) * Y(:,1);
posW(n+1,1:n) = ew(1) * Y(:,1)’;
Précédent

- 216/231

Suivant