-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-edges between two nodes #52
Comments
Hi @spranger! @jackboyla just added support for multigraphs in Grand-Cypher here: aplbrain/grand-cypher#42 So that's certainly going to help here. I also think (need to do a deeper dive before I can confirm) that this is indeed a limitation of Grand right now; I don't think we support MultiGraphs very well. (Maybe @acthecoder23 this would be a fun project to chew on?) Just thinking out loud, probably the correct answer is to split Graph/DiGraph/MultiGraph/MultiDiGraph implementations like we briefly discuss in this issue: #44 ... A short-term solution might be to create a MultiDiGraph in networkx itself (rather than in Grand) and try out @jackboyla's new implementation (which I'll have on PyPI / pip-installable shortly in |
PS: Just got back from a week in Berlin, and totally thinking about adding a |
@j6k4m8 I can give this a shot. I'll have to do a little digging but it'd be worthwhile |
@spranger also to answer 2. -- to from grandcypher import GrandCypher
import networkx as nx
host = nx.MultiDiGraph()
host.add_node("a", name="Alice", age=30)
host.add_node("b", name="Bob", age=40)
host.add_node("c", name="Charlie", age=50)
host.add_edge("a", "b", __labels__={"friend"}, years=3) # <---
host.add_edge("a", "c", __labels__={"colleague"}, years=10)
host.add_edge("a", "c", __labels__={"parent"}, duration='forever')
host.add_edge("b", "c", __labels__={"colleague"}, duration=10)
host.add_edge("b", "c", __labels__={"mentor"}, years=2)
qry = """
MATCH (a)-[r]->(b)
RETURN a.name, b.name, r.__labels__, r.duration
"""
res = GrandCypher(host).run(qry)
print(res)
'''
{'a.name': ['Alice', 'Alice', 'Bob'],
'b.name': ['Bob', 'Charlie', 'Charlie'],
'r.__labels__': [{0: {'friend'}}, {0: {'colleague'}, 1: {'parent'}}, {0: {'colleague'}, 1: {'mentor'}}],
'r.duration': [{0: None}, {0: None, 1: 'forever'}, {0: 10, 1: None}]}
''' |
Hello, I use the new version 0.5.1 of grand-graph:
results in
This might be due to the cause that our "G.nx" doesn't cope with multigraphs.
Kind Regards.
Steffen, the graphologist
The text was updated successfully, but these errors were encountered: