%This function creates the google matrix and probability vector for a %network. function [GMatrix,BiggestEigenvector]=GMatrixMaker(AMatrix,q) %This part creates the Google matrix n=length(AMatrix); %Amount of elements in network G1=(q/n).*ones(n,n); %First part of google equation formula G3=sum(AMatrix').^-1; %Last part of google equation G3=repmat(G3,n,1); %Making last part correct size G2=(AMatrix.').*((1-q).*G3); %Middle part of google matrix GMatrix=G1+G2; %Creating the google matrix %This part finds the eigenvector corresponding to the biggest eigenvalue [EigenVectors,EigenValues]=eig(GMatrix); [BiggestEigenvalue,BiggestEigenvaluePosition]=max(max(EigenValues)); BiggestEigenvector=EigenVectors(:,BiggestEigenvaluePosition); BiggestEigenvector=BiggestEigenvector/sum(BiggestEigenvector);