%%-------------------- brute force algorithm
IJ = load('BB');
nz = size(IJ,1);
z = ones(nz,1) ;
B = sparse(IJ(:,1), IJ(:,2), z);
n = size(B,1); 

G = graph(B);
plot(G)
%%--------------------
[U, D] = eig(full(B));
d = diag(D);


[t, k] = max(abs(d));
v = U(:,k);
if (0)
disp('my e-vector centrality')

v = v/sum(v)

disp('from matlab:')

centrality(G,'eigenvector') 
(0)
%%-------------------- page rank 
degs = ones(1,n)*B;

w = 1./degs;
B = B .* (ones(n,1)*w) ;

e = ones(n,1);
z = (1/n)*e;
del = 0.85;

B = (1-del)*e*z' + del*B;
[U, D] = eig(full(B));
d = diag(D);

[t, k] = max(abs(d));
u = U(:,k);
disp('my page-rank centrality')
u = u/sum(u)

disp('from matlab:')

centrality(G,'pagerank') 





