191
function [varargout] = TemporalDirLaplacian(W,k,alpha,beta)
% Spectral embedding of a directed graph changing with time
%
% n is the number of nodes, and c is the number of different time
%
periods
%
% W: is an n * n * c weighted adjacency matrix of the graph. It can be
%
undirected or directed, or a random walk matrix.
% k: the number of eigenvectors corresponding to the k smallest
%
eigenvalues desired (default is all);
% alpha: a value between 0 and 1, down-weighting the contribution of
%
matrices from previous time periods
% beta: a value between 0 and 1, the total probability of a random
%
walk transitioning to one of the other layers in the large
%
constructed graph (default is 0.5)
%
% Vout = the eigenvector matrix of out-roles
% Vin = the eigenvector matrix of in-roles
% E = the diagonal matrix of Laplacian eigenvalue
% bigW = the large constructed adjacency matrix
%
for rendering purposes
% varargout = cell array
%
1: Vout
%
2: Vin
%
3: E
%
4: bigW
[n,m,c] = size(W);
%%%% incorporate the backwards weighting using alpha
A(:,:,1) = W(:,:,1);
for i = 2:c
A(:,:,i) = alpha * A(:,:,i-1) + W(:,:,i);
end
%%%% compute the new typed Directed Laplacian
[Vout, Vin, e, bigW] = TypedDirLaplacian(A, k, beta);
varargout{1} = Vout;
varargout{2} = Vin;
varargout{3} = e;
varargout{4} = bigW;
function [varargout] = TypedLaplacian(W, k, epsilon, LazyRate)
% Spectral embedding of a typed directed network
%
% n is the number of nodes, and c is the number of different edge
% types
% W: an n * n * c weighted adjacency matrix. It can be
%
undirected or directed, or a random walk matrix.
% epsilon: a value between 0 and 1, used to avoid the problem
% of reducibility of directed graphs -- the Google trick (default is 0)
function [varargout] = TemporalDirLaplacian(W,k,alpha,beta)
% Spectral embedding of a directed graph changing with time
%
% n is the number of nodes, and c is the number of different time
%
periods
%
% W: is an n * n * c weighted adjacency matrix of the graph. It can be
%
undirected or directed, or a random walk matrix.
% k: the number of eigenvectors corresponding to the k smallest
%
eigenvalues desired (default is all);
% alpha: a value between 0 and 1, down-weighting the contribution of
%
matrices from previous time periods
% beta: a value between 0 and 1, the total probability of a random
%
walk transitioning to one of the other layers in the large
%
constructed graph (default is 0.5)
%
% Vout = the eigenvector matrix of out-roles
% Vin = the eigenvector matrix of in-roles
% E = the diagonal matrix of Laplacian eigenvalue
% bigW = the large constructed adjacency matrix
%
for rendering purposes
% varargout = cell array
%
1: Vout
%
2: Vin
%
3: E
%
4: bigW
[n,m,c] = size(W);
%%%% incorporate the backwards weighting using alpha
A(:,:,1) = W(:,:,1);
for i = 2:c
A(:,:,i) = alpha * A(:,:,i-1) + W(:,:,i);
end
%%%% compute the new typed Directed Laplacian
[Vout, Vin, e, bigW] = TypedDirLaplacian(A, k, beta);
varargout{1} = Vout;
varargout{2} = Vin;
varargout{3} = e;
varargout{4} = bigW;
function [varargout] = TypedLaplacian(W, k, epsilon, LazyRate)
% Spectral embedding of a typed directed network
%
% n is the number of nodes, and c is the number of different edge
% types
% W: an n * n * c weighted adjacency matrix. It can be
%
undirected or directed, or a random walk matrix.
% epsilon: a value between 0 and 1, used to avoid the problem
% of reducibility of directed graphs -- the Google trick (default is 0)
