I ran this query in neo4j:
MATCH (n1:`Anumber`)-[*..2]-(n2)
WHERE n1 <> n2
AND all(node in nodes(n1)-[*..2]-(n2) WHERE node:`Anumber` OR node:`Bnumber`)
WITH n1, n2, COLLECT(p) AS paths
WHERE size(paths) > 1
RETURN n1, n2, size(paths) AS degree, paths
but got this error:
Invalid input '[': expected "+" or "-" (line 3, column 27 (offset: 76))
"AND all(node in nodes(n1)-[*..2]-(n2) WHERE node:`Anumber` OR node:`Bnumber`)"
How do I fix this problem?
You probably meant to use this logic:
MATCH p=(n1:Anumber)-[*..2]-(n2)
WHERE n1 <> n2 AND
ALL(n IN NODES(p) WHERE n:Anumber OR n:Bnumber)
WITH n1, n2, COLLECT(p) AS paths
WHERE size(paths) > 1
RETURN n1, n2, size(paths) AS degree, paths