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
faster implementation of method sage.graphs.generators.families.BalancedTree
#37956
Conversation
Documentation preview for this PR (built with commit e8f0782; changes) is ready! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these changes can be ignored if you prefer as they are either tangential or micro-optimizations. Once changed or ignored, you can set a positive review.
I have implemented all proposed changes. Thanks. |
Thank you. |
…tors.families.BalancedTree` We propose a direct implementation of the graph generator `BalancedTree` that is faster than the previous method using networkx. Before (using networkx) ``` sage: %timeit G = graphs.BalancedTree(3, 5) 550 µs ± 1.17 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) sage: %timeit G = graphs.BalancedTree(3, 7) 5.33 ms ± 37.5 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) sage: %timeit G = graphs.BalancedTree(4, 5) 2.13 ms ± 18.4 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) sage: %timeit G = graphs.BalancedTree(4, 7) 54.5 ms ± 278 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) ``` With this PR ``` sage: %timeit G = graphs.BalancedTree(3, 5) 157 µs ± 809 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each) sage: %timeit G = graphs.BalancedTree(3, 7) 1.44 ms ± 4.94 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) sage: %timeit G = graphs.BalancedTree(4, 5) 569 µs ± 6.78 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) sage: %timeit G = graphs.BalancedTree(4, 7) 9.52 ms ± 61.6 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#37956 Reported by: David Coudert Reviewer(s): David Coudert, Travis Scrimshaw
…tors.families.BalancedTree` We propose a direct implementation of the graph generator `BalancedTree` that is faster than the previous method using networkx. Before (using networkx) ``` sage: %timeit G = graphs.BalancedTree(3, 5) 550 µs ± 1.17 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) sage: %timeit G = graphs.BalancedTree(3, 7) 5.33 ms ± 37.5 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) sage: %timeit G = graphs.BalancedTree(4, 5) 2.13 ms ± 18.4 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) sage: %timeit G = graphs.BalancedTree(4, 7) 54.5 ms ± 278 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) ``` With this PR ``` sage: %timeit G = graphs.BalancedTree(3, 5) 157 µs ± 809 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each) sage: %timeit G = graphs.BalancedTree(3, 7) 1.44 ms ± 4.94 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) sage: %timeit G = graphs.BalancedTree(4, 5) 569 µs ± 6.78 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) sage: %timeit G = graphs.BalancedTree(4, 7) 9.52 ms ± 61.6 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#37956 Reported by: David Coudert Reviewer(s): David Coudert, Travis Scrimshaw
We propose a direct implementation of the graph generator
BalancedTree
that is faster than the previous method using networkx.Before (using networkx)
With this PR
📝 Checklist
⌛ Dependencies