我正在创建我的第一个Neo4j(4.0.4(应用程序,我正在尝试根据加权ArticleRank算法对结果进行排序。到目前为止,一切都很直观,但我无法弄清楚为什么关系权重不会影响 ArticleRank 分数。
给定架构:
MERGE (paper0:Paper {name:'Paper 0'})
MERGE (paper1:Paper {name:'Paper 1'})
MERGE (paper2:Paper {name:'Paper 2'})
MERGE (paper3:Paper {name:'Paper 3'})
MERGE (paper4:Paper {name:'Paper 4'})
MERGE (paper5:Paper {name:'Paper 5'})
MERGE (paper6:Paper {name:'Paper 6'})
MERGE (paper1)-[:CITES {weight: 10.0}]->(paper0)
MERGE (paper2)-[:CITES {weight: 1.0}]->(paper0)
MERGE (paper2)-[:CITES {weight: 100.0}]->(paper1)
MERGE (paper3)-[:CITES {weight: 10.0}]->(paper0)
MERGE (paper3)-[:CITES {weight: 1.0}]->(paper1)
MERGE (paper3)-[:CITES {weight: 100.0}]->(paper2)
MERGE (paper4)-[:CITES {weight: 10.0}]->(paper0)
MERGE (paper4)-[:CITES {weight: 1.0}]->(paper1)
MERGE (paper4)-[:CITES {weight: 100.0}]->(paper2)
MERGE (paper4)-[:CITES {weight: 10.0}]->(paper3)
MERGE (paper5)-[:CITES {weight: 100.0}]->(paper1)
MERGE (paper5)-[:CITES {weight: 1.0}]->(paper4)
MERGE (paper6)-[:CITES {weight: 10.0}]->(paper1)
MERGE (paper6)-[:CITES {weight: 100.0}]->(paper4)
当我运行此查询时:
CALL gds.alpha.articleRank.stream({
nodeProjection: 'Paper',
relationshipProjection: {
CITES: {
properties: 'weight'
}
},
relationshipWeightProperty: 'weight'
})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS page, score
ORDER BY score DESC
我得到的结果与运行此查询时的结果相同:
CALL gds.alpha.articleRank.stream({
nodeProjection: 'Paper',
relationshipProjection: 'CITES'
})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS page, score
ORDER BY score DESC
结果是:
╒═════════╤═══════════════════╕
│"page" │"score" │
╞═════════╪═══════════════════╡
│"Paper 0"│0.3462769146633946 │
├─────────┼───────────────────┤
│"Paper 1"│0.31950147982279303│
├─────────┼───────────────────┤
│"Paper 4"│0.21375000253319743│
├─────────┼───────────────────┤
│"Paper 2"│0.21092906260164457│
├─────────┼───────────────────┤
│"Paper 3"│0.18028125041164458│
├─────────┼───────────────────┤
│"Paper 5"│0.15000000000000002│
├─────────┼───────────────────┤
│"Paper 6"│0.15000000000000002│
└─────────┴───────────────────┘
鉴于关系具有不同的权重,为什么在使用权重时运行 ArticleRank 算法会产生与不使用权重时相同的分数?
GDS 1.2 中的文章排名实现不支持权重。
该文档无助地列出了配置参数中的relationshipWeightProperty
。这在技术上是正确的,因为算法配置接受此参数。但是算法会忽略它。看起来像这样的原因是 a( 文章排名与页面排名共享 API,后者确实支持权重,b( 文章排名是一种阿尔法层算法,因此它不受产品支持,并且没有经过完全支持的算法的正确性、性能和可用性审查。
文档确实在标题Graph type support
下继续说,该算法支持:
- 定向,未加权 无
- 定向,无加权
这是一个SO答案,让我们继续在Github上进行对话。