aplbrain / aplbrain/grand

Multi-edges between two nodes

Open
#52 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
116
Forks
8
PR merge metrics
No merged PRs in 30d

Description

Hello, I use the new version 0.5.1 of grand-graph:

```python
from grand import Graph
from grandcypher import GrandCypher
from grand.backends._sqlbackend import SQLBackend

backend=SQLBackend(db_url="sqlite:///demo2.db")
G = Graph(backend=backend)

G.nx.add_node("spranger", type="Person")
G.nx.add_node("meier", type="Person")
G.nx.add_node("krause", type="Person")
G.nx.add_node("Berlin", type="City")
G.nx.add_node("Paris", type="City")
G.nx.add_node("London", type="City")

G.nx.add_edge("spranger", "Paris", type="LIVES_IN")
G.nx.add_edge("krause", "Berlin", type="LIVES_IN")
G.nx.add_edge("meier", "London", type="LIVES_IN")
G.nx.add_edge("spranger", "Berlin", type="BORN_IN")
G.nx.add_edge("krause", "Berlin", type="BORN_IN")
G.nx.add_edge("meier", "Berlin", type="BORN_IN")

result1 = GrandCypher(G.nx).run("""
MATCH (n)-[r]->(c)
WHERE
n.type == "Person"
and
c.type == "City"

RETURN n, r, c
""")

from lark.lexer import Token
n = result1[Token('CNAME', 'n')]
r = result1[Token('CNAME', 'r')]
c = result1[Token('CNAME', 'c')]

for i in range(len(n)):
print(f"{n[i]} - {r[i].get('type')} -> {c[i]}")

backend.commit()
backend.close()
```

results in

- spranger - BORN_IN -> Berlin
- spranger - LIVES_IN -> Paris
- meier - BORN_IN -> Berlin
- meier - LIVES_IN -> London
- krause - BORN_IN -> Berlin-

1. The "krause - LIVES_IN -> Berlin" relation is not stored (as any second relation between two same nodes) .
This might be due to the cause that our "G.nx" doesn't cope with multigraphs.
2. In plain grandcypher I can query "Match (p:Person)" . How do I do this in my cypher query above?
3. Would it be a good idea to have the backend and the graph layer (e.g. netwrokx) completely transparent and just run Cypher queries, also for creating nodes and relations?

Kind Regards.
Steffen, the graphologist

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.