Skip to content

Adding a new magic command: %degreeDistribution #749

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sariyuce
Copy link

@sariyuce sariyuce commented Jun 9, 2025

Description of changes:

%degreeDistribution visualizes the degree distribution of the graph. It'll make use of a newly implemented degreeDistribution algorithm in NA (not GA yet).

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.




# %degreeDistribution. Takes traversalDirection, vertexLabels, edgeLabels parameters, and visualizes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can you add a more comprehensive docstring here to explain its overall purpose and usage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like

    This magic analyzes and displays the distribution of vertex degrees in the graph,
    allowing filtering by vertex and edge types. It provides an interactive visualization
    with statistics including maximum degree, median degree, and mean degree. 

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, any estimates on how long this query would take? If its going to be long running, it would be nice to have a progress indicator or something that indicates how much time this could take.

Copy link
Author

@sariyuce sariyuce Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the description.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making the OC call only takes a couple seconds for com-Orkut, which is really large. But visualization takes some time, and I'm working on it. I'll keep the progress bar in mind in case. Thanks for pointing out.

"we will default to using all the edge labels.")


# TODO: Additional parameter for saving the visualization?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any estimates on how much effort this would require to implement as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's trivial but not sure if needed, will confirm with Dave/Ozan.

@needs_local_scope
@display_exceptions
@neptune_graph_only
def degreeDistribution(self, line, local_ns: dict = None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what i understand this would only work for Neptune Analytics, right? Please add error handling for when this magic is used with Neptune. Refer to the load magic for reference.
Reference Link: https://github.com/aws/graph-notebook/blob/main/src/graph_notebook/magics/graph_magic.py#L2056-L2061

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, added but please check; I did not use try/catch.

Copy link
Contributor

@adityaramesh12 adityaramesh12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulations on your first contribution, @sariyuce! :)

Nice work on implementing the degree distribution visualization! This is a great addition implementing the degree distribution visualization functionality for Neptune Analytics.

The implementation is well-structured and the interactive widget approach will be very useful for users exploring graph degree distributions. Really nice work!

I've added a few suggestions to enhance the code further.

Additionally, Since there are multiple commits in this PR, please remember to squash them when merging to keep our commit history clean. Also ensure you modify the commit message.

Let me know if you need any clarification on the suggestions!
Looking forward to more contributions from you. 🚀

@sariyuce
Copy link
Author

Thanks for the comments! I addressed the comments but will have some more changes before the next push. Will squash all.

@sariyuce sariyuce reopened this Jun 10, 2025
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