Skip to content

Adding a new magic command: %degreeDistribution#749

Merged
theneelshah merged 15 commits intoaws:mainfrom
sariyuce:degdist
Mar 11, 2026
Merged

Adding a new magic command: %degreeDistribution#749
theneelshah merged 15 commits intoaws:mainfrom
sariyuce:degdist

Conversation

@sariyuce
Copy link
Contributor

@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.

"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
Contributor 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.

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
Contributor 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
if degree_spread >= 100 and n > 1000:
x_scale = 'Log'
bin_type = 'Logarithmic'
initial_bin_width = (np.log10(max_deg+1) - np.log10(min_deg+1)) / np.log10(expected_nbins)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here shouldn't we divide by expected_nbins directly instead of log(expected_nbins) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, this does logarithmic binning.

with stats_output:
stats_output.clear_output(wait=True)
total_nodes = sum(counts)
total_edges = sum(d * c for d, c in zip(unique_degrees, counts)) // 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

when td is inbound or outbound isn't the total_edges just sum(d * c for d, c in zip(unique_degrees, counts))?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right, thanks for catching this.

Copy link
Contributor Author

@sariyuce sariyuce left a comment

Choose a reason for hiding this comment

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

Addressed Pratap's comments.

@theneelshah theneelshah merged commit 6ee84a1 into aws:main Mar 11, 2026
5 checks passed
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.

4 participants