我正在创建我的第一个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)Article Rank与Page Rank共享API,它确实支持权重; b)Article Rank是一种Alpha层算法,因此不支持产品,也没有经过正确性,性能等检查和完全支持的算法的可用性审查。
该文档确实在标题Graph type support
下继续说明该算法支持:
这是一个特别的答案,让我们继续在Github上进行对话。