我正在研究HITS算法实现的加权版本。
其中HITS A是权威分数,HITS H是中心分数,维基百科中算法的伪代码:
G := set of pages
for each page p in G do
p.auth = 1 // p.auth is the authority score of the page p
p.hub = 1 // p.hub is the hub score of the page p
function HubsAndAuthorities(G)
for step from 1 to k do // run the algorithm for k steps
norm = 0
for each page p in G do // update all authority values first
p.auth = 0
for each page q in p.incomingNeighbors do // p.incomingNeighbors is the set of pages that link to p
p.auth += q.hub
norm += square(p.auth) // calculate the sum of the squared auth values to normalise
norm = sqrt(norm)
for each page p in G do // update the auth scores
p.auth = p.auth / norm // normalise the auth values
norm = 0
for each page p in G do // then update all hub values
p.hub = 0
for each page r in p.outgoingNeighbors do // p.outgoingNeighbors is the set of pages that p links to
p.hub += r.auth
norm += square(p.hub) // calculate the sum of the squared hub values to normalise
norm = sqrt(norm)
for each page p in G do // then update all hub values
p.hub = p.hub / norm // normalise the hub values
请提供伪代码或java实现
答案 0 :(得分:1)
对于算法的加权版本,您需要更改更新部分中的代码:
p.hub += weight(p,r) * r.auth
^^^
同样地:
p.auth += weight(q,p) * q.hub
^^^
请注意,如果我们为所有节点设置wight(u,v)=1
,这个更新会衰减到原始算法,这是一个理想的属性。