Repository navigation
back port: generic NetworkX '<name>_layout' layouts - #43030
Merged
Merged
Conversation
|
Documentation preview for this PR (built with commit 4739967; changes) is ready! 🎉 |
dimpase
force-pushed
the
graphs/netwokx_layouts
branch
from
October 23, 2026 00:06
03106e5 to
4739967
Compare
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Oct 27, 2026
sagemathgh-43030: back port: generic NetworkX '<name>_layout' layouts This is a back port of passagemath/passagemath#2693. It provides access to layout methods of NetworkX. For instance ```sage sage: import networkx as nx sage: G = graphs.PetersenGraph() sage: pos = nx.kamada_kawai_layout(G.networkx_graph()) G.plot(pos=pos) ``` can now be done as ```sage sage: G = graphs.PetersenGraph() sage: G.plot(layout='kamada_kawai') ``` This PR adds method `layout_networkx` that takes as an input the name of a networkx layout and calls the correct method. The layouts can also be accessed via methods `plot` and `layout`. ```sage sage: G.plot(layout='kamada_kawai') sage: G.layout('kamada_kawai') {0: (0.5451030292151609, -0.6871287549350156), 1: (0.9697074521819642, 0.2991504179239621), 2: (0.44373004519448467, 0.926367292534036), 3: (-0.5585232389843457, 0.8620312293856005), 4: (-0.49740545350471793, -0.19968189731452146), 5: (-0.45277609856742673, -0.7511824689728754), 6: (-0.018824402522943536, 0.29314732071879973), 7: (0.5188539214937454, -0.1344405019393949), 8: (-1.0, 0.1727126671526057), 9: (0.05013474549407914, -0.7809753045531966)} ``` ### 📝 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. - [x] 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#43030 Reported by: David Coudert Reviewer(s):
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a back port of passagemath/passagemath#2693.
It provides access to layout methods of NetworkX.
For instance
can now be done as
This PR adds method
layout_networkxthat takes as an input the name of a networkx layout and calls the correct method.The layouts can also be accessed via methods
plotandlayout.📝 Checklist
⌛ Dependencies