neo4j / graph-data-science

Source code for the Neo4j Graph Data Science library of graph algorithms.
https://neo4j.com/docs/graph-data-science/current/
Other
596 stars 157 forks source link

bug: the centrality degree algorithm displays opposite results With reverse and natural orientations in Ne04J and Graph Data Science Playground (Neuler) #228

Closed LyneEwandje closed 1 year ago

LyneEwandje commented 1 year ago

Environnement -Neo4j Desktop 4.4.5 -Neuler-graph data Science 0.1.54 -GDSL 2.0.3

Reproduction steps

1) insert graph CREATE (alice:User {name: 'Alice'}), (bridget:User {name: 'Bridget'}), (charles:User {name: 'Charles'}), (doug:User {name: 'Doug'}), (mark:User {name: 'Mark'}), (michael:User {name: 'Michael'}),

(alice)-[:FOLLOWS {score: 1}]->(doug), (alice)-[:FOLLOWS {score: -2}]->(bridget), (alice)-[:FOLLOWS {score: 5}]->(charles), (mark)-[:FOLLOWS {score: 1.5}]->(doug), (mark)-[:FOLLOWS {score: 4.5}]->(michael), (bridget)-[:FOLLOWS {score: 1.5}]->(doug), (charles)-[:FOLLOWS {score: 2}]->(doug), (michael)-[:FOLLOWS {score: 1.5}]->(doug)

image

  1. do the function reverse on the projection graph

CALL gds.graph.project( 'myGraph', 'User', { FOLLOWS: { orientation: 'REVERSE', properties: ['score'] } } )

 3. visualise the results With the orientation Reverse in Ne04j

image

  1. Select the database and configure

image

  1. visualize the results With the orientation Reverse

image

Comparison of results With the reverse and natural orientation in Neuler and Ne04J

neo

which gives us opposite results of the execution of the centrality degree algorithm in Ne04j and in Neuler

FlorentinD commented 1 year ago

Hello @LyneEwandje, the problem lies in specifying the REVERSE orientation twice in the cypher queries.

What happens is, that first during graph projection the relationships are reversed. Then when you call degree centrality with REVERSE orientation, you are reversing the projected relationships. This results in computing the degree centrality of the reversed REVERSE relationships or in short the NATURAL orientation.

I would suggest to remove your orientation from the degree query if you have more algorithms you want to run your graph.

LyneEwandje commented 1 year ago

Hello @FlorentinD,

Thanks for your quick answer!! Indeed I did the tests by removing the orientation of the degree request and by leaving only the definition of the projection graph and it works. Thanks !