Brandon Fergerson
Brandon Fergerson

Reputation: 41

ArticleRank appears to ignore relationship weights

I'm creating my first Neo4j (4.0.4) application and I'm trying to order results based on the weighted ArticleRank algorithm. Everything has been intuitive so far but I can't figure out why relationship weights do not affect the ArticleRank score.

Given the schema:

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)

When I run this query:

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

I get the same result as when I run this query:

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

The result, which is:

╒═════════╤═══════════════════╕
│"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│
└─────────┴───────────────────┘

Given the relationships have different weights, how is it that running the ArticleRank algorithm while utilizing weights results in the same scores as when the weights aren't used?

Upvotes: 4

Views: 108

Answers (1)

jjaderberg
jjaderberg

Reputation: 9952

The Article Rank implementation in GDS 1.2 does not support weights.

The documentation is unhelpfully listing a relationshipWeightProperty among the configuration parameters. This is technically correct, because the algorithm configuration does accept this parameter. But the algorithm will ignore it. The reason it looks like this is that a) Article Rank shares API with Page Rank, which does support weights, b) Article Rank is an alpha tier algorithm, so it is not product supported and has not gone through anything like the correctness, performance and usability review of the fully supported algos.

The documentation does go on to say under the heading Graph type support, that the algorithm supports:

  • directed, unweighted
  • undirected, unweighted

That's an SO answer, let's continue the conversation on Github.

Upvotes: 1

Related Questions