Skip to content

Add HITS algorithm benchmark to benchmark suite - #8625

Merged
dschult merged 3 commits into
networkx:mainfrom
rossbar:hits-benchmark
Jun 28, 2026
Merged

dschult merged 3 commits into
networkx:mainfrom
rossbar:hits-benchmark

Conversation

@rossbar

@rossbar rossbar commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

See #8620 for motivation.

Unfortunately the old implementation of HITS was removed so long ago (nx version 2.6(!)) reliably building old/new NetworkX for comparison no longer seems to be possible, at least with a Python version that's still supported. You can probably do so if you go all the way back to Python 3.9, but Python itself has changed so much since them (esp. with faster CPython) that it's not really a meaningful comparison.

One thing you can do in principle is check different scipy versions by adding e.g. "1.16", "1.17" to the scipy versions in the asv conf. I did so and ran on main to test the different ARPACK implementations, but didn't see a significant difference.

Anyways - not necessarily useful for #8620 given the support window issues, but potentially useful for folks hacking on hits moving forward!

@dschult dschult left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks helpful!
My only comment/question is whether we should use a seed parameter for the construction of the graphs. Would that reduce variability in the timing from run to run?

@rossbar

rossbar commented Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

My only comment/question is whether we should use a seed parameter for the construction of the graphs. Would that reduce variability in the timing from run to run?

Great catch, an oversight on my part! I seeded the graph instances but still see quite a bit of variability (i.e. 70% on one machine, almost 2x on another) particularly for the smallest graph (i.e. barabasi_albert w/ 1000 nodes).

@Peiffap Peiffap left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, just left some inline nits.

Comment thread benchmarks/benchmarks/benchmark_hits.py Resolved
Comment thread benchmarks/benchmarks/benchmark_hits.py Resolved
Comment thread benchmarks/benchmarks/benchmark_hits.py Resolved
@rossbar

rossbar commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

I rebased on main to test out the benchmarking workflow fixups added in #8688 . The good news is things seem to have worked as expected: the benchmarks ran, and the new HITS benchmarks added in this PR were picked up and run properly (indicating that benchmark discovery across in PR branches is working correctly).

None of this has any bearing on whether to add these HITS benchmarks, but it's a nice confirmation the CI benchmarking machinery is working now!

@dschult dschult left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a reason to have the setup method rather than just defining graphs_dict in the class definition (like _graphs)?

Looks good!

@rossbar

rossbar commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Is there a reason to have the setup method rather than just defining graphs_dict in the class definition (like _graphs)?

Probably not - I copied/pasted the benchmark class from benchmark_algorithms and just kept the pattern used there!

@dschult
dschult merged commit 64889eb into networkx:main Jun 28, 2026
43 checks passed
@dschult dschult added this to the 3.7 milestone Jun 28, 2026
toastmt pushed a commit to toastmt/networkx that referenced this pull request Jul 2, 2026
* BENCH: Add hits alg benchmarks.

* MAINT: rm unused random import.

Co-authored-by: Mridul Seth <[email protected]>
Co-authored-by: Dan Schult <[email protected]>

* Apply suggestions from code review

Co-authored-by: Gilles Peiffer <[email protected]>

---------

Co-authored-by: Mridul Seth <[email protected]>
Co-authored-by: Dan Schult <[email protected]>
Co-authored-by: Gilles Peiffer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants