⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pagerankpow.m

📁 有趣的可视的数值方法 出自网站http://www.mathworks.com/moler
💻 M
字号:
function [x,cnt] = pagerankpow(G)% PAGERANKPOW  PageRank by power method with no matrix operations.% x = pagerankpow(G) is the PageRank of the graph G.% [x,cnt] = pagerankpow(G) also counts the number of iterations.% There are no matrix operations.  Only the link structure% of G is used with the power method.% Link structure[n,n] = size(G);for j = 1:n   L{j} = find(G(:,j));   c(j) = length(L{j});end% Power methodp = .85;delta = (1-p)/n;x = ones(n,1)/n;z = zeros(n,1);cnt = 0;while max(abs(x-z)) > .0001   z = x;   x = zeros(n,1);   for j = 1:n      if c(j) == 0         x = x + z(j)/n;      else         x(L{j}) = x(L{j}) + z(j)/c(j);      end   end   x = p*x + delta;   cnt = cnt+1;end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -