Hey there,
this is my first experience with the neo4j database. And i am a really beginner in it. But i think i got the most things working for now. But now i have a problem. I try to get the shortest path from a source to a target node, but i need properties from the relation.
Our nodes are in the Format:
CREATE (:NodeType {name: 'A'})
CREATE (:NodeType {name: 'B'})
Then our relations are:
MATCH (n:NodeType {name: 'A'}),(m:NodeType {name: 'B'})
CREATE (n)-[:UPGRADE {description: 'climb above the tree', price: 5.5}]->(m)
MATCH (n:NodeType {name: 'A'}),(m:NodeType {name: 'B'})
CREATE (n)-[:UPGRADE {description: 'go around the forest', price: 7.5}]->(m)
Each relation has an own description, and this description is relevant to us. So we try to get the shortest path from our graph with this information.
We try the following:
CALL gds.graph.project(
'neo4j',
'NodeType',
'UPGRADE',
{
relationshipProperties: 'price',
}
)
And after this we used:
MATCH (source:NodeType {name: 'A'}), (target:NodeType {name:'B'})
CALL gds.shortestPath.yens.stream('neo4j', {
sourceNode: source,
targetNode: target,
k: 2,
relationshipWeightProperty: 'price'
})
YIELD index, sourceNode, targetNode, totalCost, nodeIds, costs, path
RETURN
index,
gds.util.asNode(sourceNode).name AS sourceNodeName,
gds.util.asNode(targetNode).name AS targetNodeName,
totalCost,
[nodeId IN nodeIds | gds.util.asNode(nodeId).name] AS nodeNames,
costs,
nodes(path) as path
ORDER BY index
This works really fine, i get the shortest path in a form of a table. But i can not get the "description" information for the relations. But i need them as well.
Is there any solution or any trick that i can get the shortest path with the information of the relation properties ? So that i can put this information on the result ?
Thank you