Skip to content

Find siblings including self #70

@Benja1972

Description

@Benja1972

I would like to create a simple query to the graph with hierarchy. Starting from a child I would like to find a parent and all children of this parent including starting node. Here the example of the code,

from grandcypher import GrandCypher
import networkx as nx


host = nx.DiGraph()
host.add_node("p",  foo="Parent")
host.add_node("c1", foo="Child01")
host.add_node("c2", foo="Child02")
host.add_node("c3", foo="Child03")
host.add_node("c4", foo="Child04")
host.add_node("c5", foo="Child05")


host.add_edge("c1", "p")
host.add_edge("c2", "p")
host.add_edge("c3", "p")
host.add_edge("c4", "p")
host.add_edge("c5", "p")


qry = """
MATCH (n {foo: "Child01"})-->()<--(s)
RETURN s.foo
"""
print(GrandCypher(host).run(qry))

In current implementation the code output exclude initial node Child01

{'s.foo': ['Child02', 'Child03', 'Child04', 'Child05']}

Is it implemented on purpose?
How I can alter this behavior in single query?

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