I have a query in Neo4j to calculate the path with the lowest transition cost between items. In my case I know exactly what are the types of elements to go including the depth .. here's an example:
MATCH path = (n0: TermOccurrence) - [: CONNECTS] -> (n1: TermOccurrence) - [: CONNECTS] -> (n2: TermOccurrence) - [: CONNECTS] -> (n3: TermOccurrence) WHERE n0.termName = ' n 'AND n1.termName =' a 'AND n2.termName =' x 'AND n3.termName =' e 'RETURN path AS shortestPath, REDUCE (cost = 0, r in RELATIONSHIPS (path) | cost + r.transitionCost) AS totalCost ORDER BY totalCost ASC LIMIT 1
In this case as a result of the query I get the lowest cost path correctly however when I change the values of the termName fields from 'n' 'a' 'x' 'e' to 'n', 'a', 'n', 'a 'the result is empty ... I suspect cypher is not accepting duplicate relationships in the traversal path ... Has anyone been through something similar? My db is organized as follows:
TermOccurrence -> [: Connects] -> TermOccurrence
Thanks Enzo
Ok ! this is my path when i query for the string 'n' 'a' 'x' 'e' : naxe img
This is my path when i query for the string 'n' 'a' 'n' 'e' : name img
And finally when i query for the string 'n' 'a' 'n' 'a' nana img
I think this is happening because n->a relationship occurs more than one time on path but in my model this is perfectly normal... What I don't know is if there is a way around this restriction with neo4j...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.