Skip to content
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

Grand maybe useful? #11

Open
j6k4m8 opened this issue Dec 11, 2024 · 5 comments
Open

Grand maybe useful? #11

j6k4m8 opened this issue Dec 11, 2024 · 5 comments

Comments

@j6k4m8
Copy link

j6k4m8 commented Dec 11, 2024

Hey Ben! Saw this repo and wondered if Grand meets your needs or if not, if there are improvements we could make that would get things more usable for you?

from grand import Graph
from grand.backends import DataFrameBackend
import pandas as pd

# Create an edges DataFrame
edges = pd.DataFrame({
    'source': [0, 1, 2, 3, 4],
    'target': [1, 2, 3, 4, 0],
    'weight': [1, 2, 3, 4, 5],
})

nodes = pd.DataFrame({
    'name': [0, 1, 2, 3, 4],
    'value': [1, 2, 3, 4, 5],
})

graph = Graph(backend=DataFrameBackend(edge_df=edges, node_df=nodes), directed=True)

(Should work on out-of-core pandas-like big data as well.)

It's useful for me to know what the shortcomings are!

@bdpedigo
Copy link
Owner

hey @j6k4m8 - that's awesome, thanks for letting me know! I simply didn't know that Grand had those tools, so I'll have to see if it meets the same needs or not.

My initial impression from looking at the Grand wiki is that what I'm more interested in here is a "dialect" that I haven't found in a graph library to my satisfaction, which would mimic the syntax of pandas. Not for the sake of performance (in fact it'll probably be much less optimized than a true graph library) but simply because im used to the pandas syntax for selecting and filtering data. For instance (from the readme), much like a pandas groupby:

for color, subgraph in nf.groupby_nodes("color", axis="both"):
    print(color)
    print(subgraph.edges)

gives

('blue', 'blue')
  source  target  weight
1       1       2       2
3       2       1       4
('blue', 'red')
  source  target  weight
2       2       3       3
('red', 'blue')
  source  target  weight
0       0       1       1
('red', 'red')
  source  target  weight
4       3       0       5

@j6k4m8
Copy link
Author

j6k4m8 commented Dec 11, 2024

Ooh neat! grand-cypher kinda gets close, though we don't fully meet the cypher spec yet so groupbys are a bit weak...

I've really liked the few minutes I've spent with the networkframe query style so far! Food for thought, wonder if there are synergies in the future :)

@bdpedigo
Copy link
Owner

Ooh neat! grand-cypher kinda gets close, though we don't fully meet the cypher spec yet so groupbys are a bit weak...

ah, cool! that looks like similar idea but for sql syntax?

I've really liked the few minutes I've spent with the networkframe query style so far! Food for thought, wonder if there are synergies in the future :)

Great! FWIW this is something I pick up and put down periodically if it's helpful for a specific project, so I'm sure there are issues and things that could be improved. But would love to look for synergies!

@j6k4m8
Copy link
Author

j6k4m8 commented Dec 11, 2024

very sql-like, though specifically targeting the neo4j-popularized cypher language... so everything that works in grand-cypher also works on a neo4j database.

definitely lots of good crossover! easy one that comes to mind is if we could abstract away the underlying data structures and get you access to networkframe queries in, say, graph databases and sql just as easily, through grand. thinking out loud, just starting some threads we can pick back up if it ever becomes relevant!

@bdpedigo
Copy link
Owner

that sounds great to me, the drawback of what i was doing was always that relying on the dataframes themselves is going to be suboptimal for many graph queries, so abstracting that away but keeping the syntax would be lovely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants