Hello everyone,
Neo4j : 3.5.12
I'm looking to contract relationships of shortestpaths regarding some constraints. But, I can not find how to do it. I have a graph with two labels (Airport and Station) and distance as a property of my relationships.
My problem that the weight should be a cumulative value of precedent weights.
Example :
Given this example of a path : a - 1 -b -c -2-d where 1 and 2 are not airport, the query to create the path:
CREATE (a:Airport{id: 'a'})-[:LINKS {distance: 3 }]->(b:Station {id: '1'})-[:LINKS {distance: 4 }]->(c:Airport {id: 'b'})-[:LINKS {distance: 1}]->(d:Airport{id: 'c'})-[:LINKS {distance: 2}]->(e:Station{id: '2'})-[:LINKS {distance: 1}]->(f:Airport{id: 'd'})
Expectation (see the picture below) :
** a - 1 with weight 0
a - b with weight 0
a - c with weight 1
a - 2 with weight 1
a - d with weight 2 (since there two intermediate airports (b and c).**
The cumulative weight are illustrated by the CONTRACT
relationships which has two properties: weight
and distance
which is the sum of contracted relationships.
Output : add shortcuts with weights (new relationships with number of airports) and the sum of distance of relations.
Thank you so much