Skip to content

Variable length relationship defaults differ from neo4j cypher specs #77

@AdrianVollmer

Description

@AdrianVollmer

Hey there, I think I found another bug. And this time I have a fix!

I guess it's not even strictly a bug, but a question of convention. My changes break your test cases, so clearly we disagree on this point - but I have doubts you intended this. Consider this simple graph:

0--->1--->2

I want to find paths from 0 to 2:

import grand
from grandcypher import GrandCypher

G = grand.Graph(backend=grand.backends.NetworkXBackend(directed=True))

G.nx.add_node(0, index=0)
G.nx.add_node(1, index=1)
G.nx.add_node(2, index=2)

G.nx.add_edge(0, 1)
G.nx.add_edge(1, 2)

qry = "MATCH p=(n)-[]->(m) WHERE n.index == 0 AND m.index=2 RETURN p"
res = GrandCypher(G.nx).run(qry)
print(res["p"])  # prints: []

I would expect this to return the entire graph. The reason that it doesn't is that this sets minh to 1 and maxh to 2 (which means it searches only for paths with 1 hop, as far as I can tell). That's not what the neo4j 4.4 specs say:

https://neo4j.com/docs/cypher-manual/4.4/syntax/patterns/

https://neo4j.com/docs/cypher-manual/4.4/clauses/match/#varlength-rels

minHops and maxHops are optional and default to 1 and infinity respectively.

I proposed some changes in #76.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions