Commit
1 year ago
gh-37956: faster implementation of method `sage.graphs.generators.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) ``` ### :memo: 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. ### :hourglass: Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: https://github.com/sagemath/sage/pull/37956 Reported by: David Coudert Reviewer(s): David Coudert, Travis Scrimshaw
Author
Release Manager
Loading