Weight chart in Neo4j

I have an instance of Neo4j. I have a balanced relationship. One such example represents all the places in the world and has a distance between each place.

Now it seems easy to create a connection between two nodes: A and B:

Relationship relationship = A.createRelationshipTo(B, Relations.Knows );

But what about the actual strength of the relationship. The following was suggested here:

create a-[:`KNOWS_0.34`]->b

This works, but it is not a very wonderful solution, especially if you want to calculate the shortest distance, depending on the weight.

Is there a way to do this and keep the int or float relationship?

+4
source share
2 answers

I did not know about this, but it seems you can set additional properties when creating Relationship:

Relationship relAB = createRelationship( nodeA, nodeC, "length", 2d );
+3
source

!

Neo4j. , . *. dijkstra .

+3

Source: https://habr.com/ru/post/1529914/


All Articles