aplbrain / aplbrain/grand-cypher
multiedge should not be aggregated.
- Dominant language
- Python
- Stars
- 129
- Forks
- 17
- PR merge metrics
- PR metrics pending
Description
Our library is treating multi edge graph as DiGraph. It does this by somewhat aggregated multi edges between 2 nodes into 1 row. In Neo4j specs, we should have each edge as a row.
For example this is the current behavior
```python
def test_edge_directionality(self):
host = nx.MultiDiGraph()
host.add_node("a", name="Alice", age=25)
host.add_node("b", name="Bob", age=30)
host.add_edge("a", "b", __labels__={"friend"}, years=1)
host.add_edge("b", "a", __labels__={"colleague"}, years=2)
host.add_edge("b", "a", __labels__={"mentor"}, years=4)
qry = """
MATCH (a)-[r]->(b)
RETURN a.name, b.name, r.__labels__, r.years
"""
res = GrandCypher(host).run(qry)
assert res["a.name"] == ["Alice", "Bob"]
assert res["b.name"] == ["Bob", "Alice"]
assert res["r.__labels__"] == [
{(0, "friend"): {"friend"}},
{(0, "colleague"): {"colleague"}, (1, "mentor"): {"mentor"}},
]
assert res["r.years"] == [
{(0, "friend"): 1},
{(0, "colleague"): 2, (1, "mentor"): 4},
]
```
the realtionship Bob to Alice is either colleague or mentor, and the lib currently return both in a row as ` {(0, "colleague"): {"colleague"}, (1, "mentor"): {"mentor"}}`. This is a good attempt to bring python MultiDiGraph outside to the cypher, but this behavior is not friendly.
To follow neo4j, the return should be
```python
assert res == {
"a.name": ["Alice", "Bob", "Bob"],
"b.name": ["Bob", "Alice", "Alice"],
"r.__labels__": [{"friend"}, {"colleague"}, {"mentor"}],
"r.years": [1, 2, 4],
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.