I have a cypher query that currently returns all of the relationships from a given node with a variable length path:
MATCH (n)
WHERE n.name = ({name})
OPTIONAL MATCH path=n-[*..2]-(c)
WHERE n <> c
WITH rels(path) AS rels
UNWIND rels AS rel
WITH DISTINCT rel
RETURN startnode(rel).name as source, endnode(rel).name as target, rel.average_alignment
I'm looking to add the path length as part of the return:
MATCH (n)
WHERE n.name = ({name})
OPTIONAL MATCH path=n-[*..2]-(c)
WHERE n <> c
WITH rels(path) AS rels
UNWIND rels AS rel
WITH DISTINCT rel
RETURN startnode(rel).name as source, endnode(rel).name as target, rel.average_alignment, length(path)
How does one include the path length along with all of the relationships?