cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Neo.ClientError.Statement.SyntaxError

// Find maximum diameter of network
// maximum shortest path between two nodes
MATCH (a:Character), (b:Character) WHERE id(a) > id(b)
MATCH p=shortestPath((a)-[:INTERACTS*]-(b))
RETURN length(p) AS Length, extract(IN nodes(p) | x.name) AS Path
ORDER BY len DESC LIMIT 4
 
Neo.ClientError.Statement.SyntaxError
Extract is no longer supported. Please use list comprehension instead (line 5, column 29 (offset: 206))
"RETURN length(p) AS Length, extract(x IN nodes(p) | x.name) AS Path"
1 ACCEPTED SOLUTION

glilienfield
Ninja
Ninja

Try this:

 
match(a:Character)
match(b:Character)
where id(a) > id(b)
match p=shortestPath((a)-[:INTERACTS*]-(b))
return length(p) as Length, [x in nodes(p) | x.name] as Path
order by Length desc
limit 4

View solution in original post

2 REPLIES 2

glilienfield
Ninja
Ninja

Try this:

 
match(a:Character)
match(b:Character)
where id(a) > id(b)
match p=shortestPath((a)-[:INTERACTS*]-(b))
return length(p) as Length, [x in nodes(p) | x.name] as Path
order by Length desc
limit 4

thank you very much,
can run

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online