power method e pagerank come funzioni esterne

This commit is contained in:
2014-12-10 13:00:02 +01:00
parent 8968dbd158
commit 60e284f24e
5 changed files with 216 additions and 0 deletions

19
functions/external/costruzioneMatrice.m vendored Normal file
View File

@@ -0,0 +1,19 @@
function A=costruzioneMatrice(G,p)
% c = out-degree, r = in-degree
[n,n] = size(G);
c = sum(G,1);
r = sum(G,2);
% Scale column sums to be 1 (or 0 where there are no out links).
k = find(c~=0);
D = sparse(k,k,1./c(k),n,n);
% Solve (I - p*G*D)*x = e
e = ones(n,1);
I = speye(n,n);
%Conventional power method
z = ((1-p)*(c~=0) + (c==0))/n;
A = p*G*D + e*z;