MATCH (n:cabinet)
WHERE n.name IN {cabinet}
WITH collect(n) AS nodes
UNWIND nodes AS n
UNWIND nodes AS m
WITH *
WHERE id(n) < id(m)
MATCH path = allShortestPaths((n)-[relation*..10]-(m))
WHERE ALL(x IN relation
WHERE x.type = 'Parameter')
WITH
collect({ path: path, pathLength: length(path) }) AS data,
max(length(path)) AS maxLength
WITH [row IN data WHERE row.pathLength = maxLength] AS rows
UNWIND rows AS row
RETURN row.path AS path
The last query you have looks mostly right, with a few exceptions:
In your allShortestPaths() match, your predicate for all relationships having the type Parameter isn't quite right. What you have here looks for a type property = 'Parameter', but the type of a relationship isn't a property. For this comparison, you should use WHERE type(x) = 'Parameter'. That said, since you already know what the type should be, and it likely isn't dynamic, it's better to put this into the pattern itself that way you don't even need a WHERE clause: MATCH path = allShortestPaths((n)-[relation:Parameter*..10]-(m))
The error shows that you didn't provide a cabinet parameter (which is used in the WHERE clause of your first MATCH). If you're executing this via the browser, you need to set a parameter cabinet which should be a list of string names. Use :help param from the browser to get syntax help for how to set a parameter before you execute your query.
MATCH path = allShortestPaths((n)-[relation*..10]-(m))
WHERE ALL(x IN relation
WHERE type(x) = 'Parameter') RETURN path
o/p -
Neo.DatabaseError.Statement.ExecutionFailed
Neo.DatabaseError.Statement.ExecutionFailed: The shortest path algorithm does not work when the start and end nodes are the same. This can happen if you
perform a shortestPath search after a cartesian product that might have the same start and end nodes for some
of the rows passed to shortestPath. If you would rather not experience this exception, and can accept the
possibility of missing results for those rows, disable this in the Neo4j configuration by setting
`cypher.forbid_shortestpath_common_nodes` to false. If you cannot accept missing results, and really want the
shortestPath between two common nodes, then re-write the query using a standard Cypher variable length pattern
expression followed by ordering by path length and limiting to one result.
[2]
I also tried this cypher -
MATCH path = allShortestPaths((n)-[relation:Parameter]-(m)) RETURN path
o/p -
Neo.DatabaseError.Statement.ExecutionFailed
Neo.DatabaseError.Statement.ExecutionFailed: The shortest path algorithm does not work when the start and end nodes are the same. This can happen if you
perform a shortestPath search after a cartesian product that might have the same start and end nodes for some
of the rows passed to shortestPath. If you would rather not experience this exception, and can accept the
possibility of missing results for those rows, disable this in the Neo4j configuration by setting
`cypher.forbid_shortestpath_common_nodes` to false. If you cannot accept missing results, and really want the
shortestPath between two common nodes, then re-write the query using a standard Cypher variable length pattern
expression followed by ordering by path length and limiting to one result.
accordingly, i tried to find the variable -
cypher.forbid_shortestpath_common_nodes
in the Neo4j-Home folder, and inside conf/neo4j.conf and also inside other folders. But i could not find the boolean variable.
I am not sure if that is the correct folder for the Neo4j desktop version because i downloaded neo4j couple of times when i got error max entries exceeded and i am currently using the image of neo4j to start & run neo4j . So does my folder neo4j-community-3.4.9 proper and correct folder for neo4j-desktop-offline-1.1.10-x86_64 (1).AppImage ? Does this neo4j initialized from Image file have a folder repository? Please help.
MATCH path = allShortestPaths((n)-[relation*..10]-(m))
WHERE n.company="cateina" AND m.name="cabinet" AND ALL(x IN relation WHERE type(x) = 'Parameter')
RETURN path
And the output i got is -
#### Neo.DatabaseError.Statement.ExecutionFailed
Neo.DatabaseError.Statement.ExecutionFailed: The shortest path algorithm does not work when the start
and end nodes are the same. This can happen if you perform a shortestPath search after a cartesian
product that might have the same start and end nodes for some of the rows passed to shortestPath. If you
would rather not experience this exception, and can accept the possibility of missing results for those rows,
disable this in the Neo4j configuration by setting `cypher.forbid_shortestpath_common_nodes` to false. If you
cannot accept missing results, and really want the shortestPath between two common nodes, then re-write
the query using a standard Cypher variable length pattern expression followed by ordering by path length
and limiting to one result.
And the name is correct that i entered. i.e. - cabinet
query -
MATCH (n)-[r:Parameter]->(m) WHERE m.name = "cabinet" RETURN n,m,r