我正在创建我的第一个 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 算法会产生与不使用权重时相同的分数吗?