Skip to content

[WIP] Node reductions - #283

Closed
pradkrish wants to merge 2 commits into
graphistry:masterfrom
pradkrish:issue_193
Closed

pradkrish wants to merge 2 commits into
graphistry:masterfrom
pradkrish:issue_193

Conversation

@pradkrish

@pradkrish pradkrish commented Dec 7, 2021 •

Copy link
Copy Markdown
Contributor

For issue #193

@pradkrish

Copy link
Copy Markdown
Contributor Author

@lmeyerov Despite this being pretty much a work in progress, I already opened a PR to get some initial feedback. I hope that's okay :)

This is a partial implementation of table reductions. The function replace_nodes_with_edges(node_selector) can currently accept both a string and a list of strings. For example the following calls g.replace_nodes_with_edges(['m']) and g.replace_nodes_with_edges('m') both yield the same results. Here is an example:

g = graphistry.edges(pd.DataFrame([{'x': 'a', 'y': 'm'},
                                   {'x': 'b', 'y': 'm'},
                                   {'x': 'c', 'y': 'n'},
                                   {'x': 'd', 'y': 'm'}]), 'x', 'y')
g.replace_nodes_with_edges(['m',])
print(g._edges)

#result
   x  y reduced_from
0  a  b            m
1  a  d            m
2  b  d            m
3  c  n          NaN

What are your thoughts?

@lmeyerov

lmeyerov commented Dec 8, 2021 •

Copy link
Copy Markdown
Contributor

Cool, some thoughts:

  • what happens if m is a src (x), not dst (y)?
  • how about specify nodes as a Series, say 1-column or if multi-column, index on g._node, to help composition?

Ex:

annoying_nodes_df = g._nodes[ g._nodes['type'] == 'event' ]
g2 = g.replace_nodes_with_edges(annoying_nodes_df)
  • reduced_from right now (afaict) would report "m,n,o,p" instead of "m" when used on a list input

I'll need to look at itertools, but the rest seems straightforward to port to cudf / dask_cudf :)

@pradkrish

pradkrish commented Dec 10, 2021 •

Copy link
Copy Markdown
Contributor Author

@lmeyerov Thank you very much for your feedback. I have pushed another commit now. Kindly have a look at the replace_nodes_with_edges(..) function comments, it should address some of the issues your raised. I have also added some tests to show how to use this function. As far itertools, I have replaced the logic which now uses numpy.tril. Please have a look and let me know what you think. :)

For now I would like to make some headway into getting the table reductions into a good shape before starting to work on pregel/graphx style mapping.

@lmeyerov

Copy link
Copy Markdown
Contributor

Great!

In case it helped, I sketched out a few the top use cases we see in the original ticket: #193

re:tril, I'm struggling to understand that logic, which suggests someone doing a future bugfix here would need to rewrite it.. can it be something like pd.concat? I'm guessing once the aggregation operators come in and more tests, we'll have a better sense of what needs to be fast/slow, so simple vector pd calls should get us far..

@lmeyerov

lmeyerov commented Dec 18, 2021 •

Copy link
Copy Markdown
Contributor

Just checking in on this. Maybe the thing to do is:

  • make sure each of the motivating examples is in a test
  • test a few different tricky graph shapes

I'm thinking we can land this as-is, and update the underlying feature request for future PRs to explore (a) a custom reductions mode for this (ex: summary stats) and (b) multi-node collapsing/grouping (ex: collapse connected nodes name/email/address/username into a single labeled node)

@lmeyerov lmeyerov closed this Mar 13, 2022
lmeyerov added a commit that referenced this pull request Oct 3, 2026
…bench #283)

The docs policy caps graphistry/compute commit drift at 12 since a published run's
measured commit; this branch adds 8 on top of master's 8. Instead of a waiver, the
GraphBench 20k/100k and SNB boards were re-measured at 2d64913 under the published
protocol and republished from pyg-bench (#283, same contract v3). Drift for the four
re-measured runs is now 0; the bench-provenance directives name the new run ids.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ropeBMLJUuy6ViYwy15ud
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

Successfully merging this pull request may close these issues.

2 participants