I have written (and optimized, using "PROFILE") a Cypher query that answers neighbors of a node given the node. Now I find an apoc procedure (apoc.neighbors.athop
) that seems to do the same thing.
Is the APOC version better? Faster? More robust?
I understand the value of APOC when there is no counterpart in regular Cypher for the given behavior. In the case of collecting neighbors, the Cypher seems easy:
MATCH (target:SomeLabel)
WITH target
MATCH (target)-[:ADJOINS]-(neighbor:SomeLabel)
WITH target, neighbor
As I understand it, the APOC counterpart is:
MATCH (target:SomeLabel)
WITH target
CALL apoc.neighbors.athop(target, "ADJOINS", 1)
YIELD node
RETURN node
Why would I choose the latter over the former?