I am using neo4j GDS library and wondering is there any way I can mutate a property on the relationship which is already exist on the node. e.g. I have nodes with label Person connected nodes Book using relationship read. I am using the Page Rank algorithm which gives me expected output but I want to use weighted algorithm and wants to use the property Price on the Book. As per my document I could find that I can use the weight on the relationship using "relationshipWeightProperty" but couldn't find anything related to node. So is there any way I can use the weight from the target nodes property or is there any way I can mutate the price property on the relationship from the node and then use it?
Asked
Active
Viewed 250 times
1 Answers
0
So there are a couple of things...
PageRank does not support node weights, so there is no option to use that.
You can either use Cypher Projection to project the node weight as the relationship property without having to transform the underlying stored graph.
You can create a relationship weight in the database and use Native Projection to project the newly created relationship weight (along with other information)
Edit:
First you need to add the node property to the relationships with cypher.
MATCH (i:Instrument)<-[l:LIKES]-()
SET l.score = i.score
And then run the above projection query.

Tomaž Bratanič
- 6,319
- 2
- 18
- 31
-
Thanks for the reply. How can I achieve 2. I used following code to create a new relationship in projection and adds property but could not put a node property on a relationship. CALL gds.graph.create( 'personsAndInstruments', ['Person', 'Instrument'], { LIKES: { type: 'LIKES', properties: { strength: { property: 'strength', defaultValue: 1.0 }, score: { property: 'score' } } } } ) Really appreciate if you have example to share. – user2813165 Feb 16 '22 at 18:19
-
I've added an edit – Tomaž Bratanič Feb 16 '22 at 18:35
-
Thanks a lot, I will try with your suggestion. – user2813165 Feb 16 '22 at 19:30