summaryrefslogtreecommitdiff
path: root/networkx/drawing/layout.py
Commit message (Collapse)AuthorAgeFilesLines
* Preserve node order in bipartite_layout (#6644)Haoyang Li2023-04-171-3/+3
| | | | | * Keep the original order of the nodes in bipartite_layout * Keep the original order of the nodes in bipartite_layout
* Fix typos (#6620)Harri Nieminen2023-04-041-1/+1
|
* Update pre-commit (#6545)Jarrod Millman2023-03-231-2/+2
|
* Fix typos in the networkx codebase (#6335)Anurag Bhat2023-01-051-1/+1
| | | | | * Fix_Typos * Commit_Suggestions
* Arf layout (#5910)Casper van Elteren2022-08-231-0/+113
| | | | | | | | | | | | | | | | | | | | | * added arf_layout * reference to docstring and comparison to spring layout * rebase to origin main * black re-format * Left aligned docstring text * Cleaned up computation and update variables to new docstring * Updated naming tests. Added input check on arf_layout parameter `a` * Fixed Linter issues for py38 target * Fixed Linter issues for target p38 * linter issue fixed
* Recover order of layers in multipartite_layout when layers are sortable (#5705)Ross Barnowski2022-06-091-2/+7
| | | | | | | | | | | * Add test for sorted layers. * Implement layer sorting when possible. Co-authored-by: Dan Schult <dschult@colgate.edu> * Add test case for non-sortable layers. Co-authored-by: Dan Schult <dschult@colgate.edu>
* Remove redundant py2 numeric conversions (#5661)Mridul Seth2022-05-311-2/+2
| | | | | | | | | * Remove redundant float conversion * Remove redundant int conversion * Use integer division Co-authored-by: Miroslav Šedivý <6774676+eumiro@users.noreply.github.com>
* Replace np.flip with indexing in layouts. (#5623)Ross Barnowski2022-05-111-2/+2
|
* Rm incorrect reference from spiral_layout docstring. (#5503)Ross Barnowski2022-04-081-6/+0
|
* Fix for issue 5212 (#5471)Lukong1232022-04-061-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | * added references * added gallery example * fixed error * fixed error * Update networkx/drawing/layout.py Co-authored-by: Mridul Seth <mail@mriduls.com> * Update networkx/drawing/layout.py Co-authored-by: Mridul Seth <mail@mriduls.com> * added example on edge cover * Revert "added example on edge cover" This reverts commit 27a7277622a45e361a60ddfc1b04b6b18acd6900. * add a link break Co-authored-by: Mridul Seth <mail@mriduls.com>
* Update black (#5438)Mridul Seth2022-03-291-6/+6
| | | | | | | * CI: sync up black dev requirements version with precommit * Run black Co-authored-by: Jarrod Millman <jarrod.millman@gmail.com>
* Fix spiral_layout when equidistant=True (#5354)Anutosh Bhat2022-02-271-4/+8
| | | | | Fixes positioning of first node when equidistant=True. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Use scipy.sparse array datastructure (#5139)Ross Barnowski2022-01-181-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Step 1: use sparse arrays in nx.to_scipy_sparse_matrix. Seems like a reasonable place to start. nx.to_scipy_sparse_matrix is one of the primary interfaces to scipy.sparse from within NetworkX. * 1: Use np.outer instead of mult col/row vectors Fix two instances in modularitymatrix where a new 2D array was being created via an outer product of two \"vectors\". In the matrix case, this was a row vector \* a column vector. In the array case this can be disambiguated by being explicit with np.outer. * Update _transition_matrix in laplacianmatrix module - A few instances of matrix multiplication operator - Add np.newaxis + transpose to get shape right for broadcasting - Explicitly convert e.g. sp.sparse.spdiags to a csr_array. * Update directed_combinitorial_laplacian w/ sparse array. - Wrap spdiags in csr_array and update matmul operators. * Rm matrix-specific code from lgc and hmn modules - Replace .A call with appropriate array semantics - wrap sparse.diags in csr_array. * Change hits to use sparse array semantics. - Replace * with @ - Remove superfluous calls to flatten. * Update sparse matrix usage in layout module. - Simplify lil.getrowview call - Wrap spdiags in csr_array. * lil_matrix -> lil_array in graphmatrix.py. * WIP: Start working on algebraic connectivity module. * Incorporate auth mat varname feedback. * Revert 1D slice and comment for 1D sparse future. * Add TODOs: rm csr_array wrapper around spdiags etc. * WIP: cleanup algebraicconn: tracemin_fiedler. * Typo. * Finish reviewing algebraicconnectivity. * Convert bethe_hessian matrix to use sparse arrays. * WIP: update laplacian. Update undirected laplacian functions. * WIP: laplacian - add comment about _transition_matrix return types. * Finish laplacianmatrix review. * Update attrmatrix. * Switch to official laplacian function. * Update pagerank to use sparse array. * Switch bipartite matrix to sparse arrays. * Check from_scipy_sparse_matrix works with arrays. Modifies test suite. * Apply changes from review. * Fix failing docstring tests. * Fix missing axis for in-place multiplication. * Use scipy==1.8rc2 * Use matrix multiplication * Fix PyPy CI * [MRG] Create plot_subgraphs.py example (#5165) * Create plot_subgraphs.py https://github.com/networkx/networkx/issues/4220 * Update plot_subgraphs.py black * Update plot_subgraphs.py lint plus font_size * Update plot_subgraphs.py added more plots * Update plot_subgraphs.py removed plots from the unit test and added comments * Update plot_subgraphs.py lint * Update plot_subgraphs.py typos fixed * Update plot_subgraphs.py added nodes to the plot of the edges removed that was commented out for whatever reason * Update plot_subgraphs.py revert the latest commit - the line was commented out for a reason - it's broken * Update plot_subgraphs.py fixed node color issue * Update plot_subgraphs.py format fix * Update plot_subgraphs.py forgot to draw the nodes... now fixed * Fix sphinx warnings about heading length. * Update examples/algorithms/plot_subgraphs.py * Update examples/algorithms/plot_subgraphs.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Dan Schult <dschult@colgate.edu> * Add traveling salesman problem to example gallery (#4874) Adds an example of the using Christofides to solve the TSP problem to the example galery. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Fixed inconsistent documentation for nbunch parameter in DiGraph.edges() (#5037) * Fixed inconsistent documentation for nbunch parameter in DiGraph.edges() * Resolved Requested Changes * Revert changes to degree docstrings. * Update comments in example. * Apply wording to edges method in all graph classes. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Compatibility updates from testing with numpy/scipy/pytest rc's (#5226) * Rm deprecated scipy subpkg access. * Use recwarn fixture in place of deprecated pytest pattern. * Rm unnecessary try/except from tests. * Replace internal `close` fn with `math.isclose`. (#5224) * Replace internal close fn with math.isclose. * Fix lines in docstring examples. * Fix Python 3.10 deprecation warning w/ int div. (#5231) * Touchups and suggestions for subgraph gallery example (#5225) * Simplify construction of G with edges rm'd * Rm unused graph attribute. * Shorten categorization by node type. * Simplify node coloring. * Simplify isomorphism check. * Rm unit test. * Rm redundant plotting of each subgraph. * Use new package name (#5234) * Allowing None edges in weight function of bidirectional Dijkstra (#5232) * added following feature also to bidirectional dijkstra: The weight function can be used to hide edges by returning None. * changed syntax for better readability and code duplicate avoidance Co-authored-by: Hohmann, Nikolas <nikolas.hohmann@tu-darmstadt.de> * Add an FAQ about assigning issues. (#5182) * Add FAQ about assigning issues. * Add note about linking issues from new PRs. * Update dev deps (#5243) * Update minor doc issues with tex notation (#5244) * Add FutureWarnings to fns that return sparse matrices - biadjacency_matrix. - bethe_hessian_matrix. - incidence_matrix. - laplacian functions. - modularity_matrix functions. - adjacency_matrix. * Add to_scipy_sparse_array and use it everywhere. Add a new conversion function to preserve array semantics internally while not altering behavior for users. Also adds FutureWarning to to_scipy_sparse_matrix. * Add from_scipy_sparse_array. Supercedes from_scipy_sparse_matrix. * Handle deprecations in separate PR. * Fix docstring examples. Co-authored-by: Mridul Seth <mail@mriduls.com> Co-authored-by: Jarrod Millman <jarrod.millman@gmail.com> Co-authored-by: Andrew Knyazev <andrew.knyazev@ucdenver.edu> Co-authored-by: Dan Schult <dschult@colgate.edu> Co-authored-by: eskountis <56514439+eskountis@users.noreply.github.com> Co-authored-by: Anutosh Bhat <87052487+anutosh491@users.noreply.github.com> Co-authored-by: NikHoh <nikhoh@web.de> Co-authored-by: Hohmann, Nikolas <nikolas.hohmann@tu-darmstadt.de> Co-authored-by: Sultan Orazbayev <contact@econpoint.com> Co-authored-by: Mridul Seth <mail@mriduls.com>
* Compatibility updates from testing with numpy/scipy/pytest rc's (#5226)Ross Barnowski2021-12-121-1/+1
| | | | | | | * Rm deprecated scipy subpkg access. * Use recwarn fixture in place of deprecated pytest pattern. * Rm unnecessary try/except from tests.
* Investigate pre-release test failures (#5208)Ross Barnowski2021-12-031-11/+3
| | | | | | | * Use array ops for distance calculation. Removes for-loops and matmul. * Refactor spiral layout equidist to use arrays.
* Add Mypy type checking infrastructure (#5127)Ross Barnowski2021-11-171-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add minimal mypy configuration file. * Add mypy workflow to GH. * Properly import sentinels from traversal.edgedfs. * mypy doesn't like variables named \"e\". * Rm annotations from single function. * Fix name collisions in test suite. Make sure all tests have unique names. * Rm unused random seed in test setup. * Rm redundant __all__ specification. * Silence mypy error from sum(). Mypy bug? * Fix tsp test instantiation nit. * \"type: ignore\" to suppress conditional fn sigature errors. * Remaining \"type: ignore\" to appease mypy. * Configure mypy to ignore inheritance issues. * Update exclude conf for CI. - Add yaml - Reformat regex containing reportviews * Rm partial annotations from lukes.py. Fixes mypy errors due to unannotated code. * Reorg defaultdict to reduce type: ignore cruft. * Homogenize signatures for fns defined in conditionals. * err as varname only in exception catching. * Fix name collision in Bellman-Ford test suite.
* Bugfix for issue 5123 (#5153)Daniel Haden2021-11-031-1/+1
| | | | | | | | | * fixed bug in multipartite_layout so subset labels can be non-numeric * Added non-numeric partition label test to test_multipartite_layout. * moved multipartite non-numeric partition label test outside of main test class Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Change exception varname e to err (#5130)Dan Schult2021-10-151-8/+8
| | | | A more descriptive variable name for exceptions. This reduces local var naming conflicts when \`e\` is used e.g. to represent edges as a loop variable.
* Consistent return type in dictionary output of rescale_layout and ↵Casper van Elteren2021-10-141-5/+6
| | | | | | | | | | | | | | | | | rescale_layout_dict (#5091) * changed tuple to np.array * changed return to zip * modified unittest to match rescale_layout_dict return type * modified doctest rescale_layout_dict * added import statement to doctest; test pass * Add release note about change in return type. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Deprecate `random_state` decorator (#5055)Ross Barnowski2021-09-121-5/+5
| | | | | | | | | | | | | | | | | * Reorganize aliases and deprecate random_state. * Rm internal uses of random_state. * Update tests. Rm tests or rename to use np_random_state. * Update reference guide. * Update deprecations.rst. * Remove preserve_random_state from refguide. * Add deprecation to release notes.
* spring_layout: ignore 'fixed' nodes not in the graph nodes (#4867)Danylo Ulianych2021-06-061-1/+2
| | | | | | | * spring_layout: ignore 'fixed' nodes not in the graph nodes * add api change to release notes Co-authored-by: Dan Schult <dschult@colgate.edu>
* switch alias direction of spring_layout and fruchterman_reingold_layout (#4820)Dan Schult2021-05-191-3/+4
|
* Refactor bipartite and multipartite layout (#4653)Dimitrios Papageorgiou2021-03-081-61/+35
| | | Reduce duplication in source code
* DOC: Switch from napoleon to numpydoc sphinx extension (#4447)Ross Barnowski2020-12-121-3/+5
| | | | | | | * Setup for numpydoc. * Add to doc requirements. * Replace napoleon with numpydoc in conf.py. * DOC: Fixups from numpydoc.
* Standard imports (#4401)Jarrod Millman2020-12-071-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | * Standardize pytest imports * Standardize numpy/scipy imports * Document import style * Fix * More * Fix matplotlib imports * Revert changes to tests * Motivate import policy Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Fix missed imports * Standard np.testing use Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Simplify importsJarrod Millman2020-09-151-5/+1
|
* add rescale_layout_dict to change scale of the layout_dicts (#4154)Dan Schult2020-08-141-0/+41
| | | | merge #3146 which came from unknown repository closes #3146
* Fix planar_layout docstring (#4097)Christoph Deil2020-07-211-6/+0
| | | Remove duplicated Parameters section in docstring
* Format w/ blackJarrod Millman2020-07-101-86/+96
|
* Implemented multipartite_layout (#3815)Jose Pinilla2020-07-101-1/+96
| | | | | | | | | | | | | * Implemented multipartite_layout * Added test. * Remove left over `max_layer` in multipartite_layout * Multipartite Layout Example * Update examples/drawing/plot_multipartite_graph.py Co-authored-by: Jarrod Millman <jarrod.millman@gmail.com>
* Fixed typo in kamada_kawai_layout docstring (#4059)farhanbhoraniya2020-07-091-1/+1
|
* Remove unused imports (#3855)Alex Henrie2020-07-061-1/+1
| | | | | | | | | * Remove unused imports * remove more unused import statements found by pyflakes * move import of random outside of networkx.utils Co-authored-by: Dan Schult <dschult@colgate.edu>
* Fix exception causes and messages all over the codebase (#4015)Ram Rachum2020-07-051-10/+10
|
* fix initializer for kamada_kawai_layout (networkx #3658) (#3782)Kelly Boothby2020-01-201-1/+5
| | | | | | | | | | | | | * fixed high-dimensional initializer for kamada_kawai_layout (networkx #3658) * added tests for kamada_kawai 3d * increased test coverage of kamada_kawai_layout * fixed empty-graph oversight in kamada_kawai_layout * removed unused variable vpos from smoke tests Fixes #3658
* Fix scaling of single node shells in shall_layout (#3764)Dan Schult2019-12-281-14/+21
| | | | | | | | | | | | * Fix scaling of single node shells in shall_layout Also add a feature: rotation of initial angle for each shell controlled by new argument "rotate" Add a test to check this fix Update for PEP8 * apease the codecov check Fixes #3753
* Remove boiler plate from top of modulesJarrod Millman2019-11-111-12/+0
| | | | | | | | | The copyright and author stuff is not necessary, out-of-date, and inconsistent. It takes up visual space and is a pain to police everyone doing the same thing on the top of the module. Git handles authorship in a comprehensive and authoritative way. The LICENSE.txt file applies to all project code.
* Fix more documentation issues with exceptionsJarrod Millman2019-11-091-1/+2
|
* Fix typo: Laplacion -> Laplacian (#3689)Don Kirkby2019-10-241-1/+1
| | | Thanks for the great library! Here's a little typo fix.
* Skip doctests when missing dependenciesJarrod Millman2019-10-211-7/+0
|
* Use pytest for doctestJarrod Millman2019-10-121-10/+4
|
* Keep shells with 1 node away from origin in shell_layout (#3629)Dan Schult2019-10-031-2/+5
| | | | Fixes #3188 also fix some pycodestyle
* Resolve many documentation issues (#3611)Dan Schult2019-09-301-7/+22
| | | | | | | | | | | | * Fixes #3498 Adds docs to BFS and DFS functions referring to each other * Fixes #3463 to add warning to closeness centrality * Fixes #3469 by adding a link to the miles datafile. * Fixes #3489 allowing scale=None and adding docs * Fixes #3473 by adding example to migration_guide_from_1.x_to_2.0.rst
* Remove future imports needed by Py2Jarrod Millman2019-09-181-1/+0
|
* Add spiral layout for graph drawing (#3534)Michael Fedell2019-09-051-1/+84
| | | | | | | | | | | | | | | | | * Add spiral layout for graph drawing New method in layout will arrange nodes of a graph in a spiral layout with variable compactness. Nodes may be positioned with equal angles (increasing separation further from center), or equidistant (decreasing angle further from center) * Add sprial_layout to __all__ for import * Import numpy direct to spiral_layout * unit tests and small tweaks * spiral layout documentation
* Fix spring_layout bug with fixed nodes (#3415)Dan Schult2019-05-021-2/+9
| | | | | | | | | * Make spring_layout raise exception if fixed nodes specified and no pos-dict specified * Check that any fixed nodes have specified positions in input pos-dict Note: spring_layout is also fruchterman_reingold_layout. Before this, fixed nodes not in the pos-dict were assigned random positions.
* Update copyrightJarrod Millman2019-03-301-1/+1
|
* Planar drawing algorithm. (#3125)Johannes Schulte2019-03-271-0/+64
| | | | | | | | Implements a method that assigns each node in a planar graph a position such that its edges do not intersect. Co-authored-by: David Kraeutmann <kane@kane.cx> Co-authored-by: Johannes Schulte <johannes.bernhard.schulte@rwth-aachen.de> Co-authored-by: Yassin Bahloul <yassin.bahloul@rwth-aachen.de> Co-authored-by: Dominik Meier <dominik.meier@rwth-aachen.de>
* Replacing `Return` to `Returns` in docs for functions (#3301)Moradnejad2019-02-181-1/+1
| | | | | | * Fixed problem in documentation view of this function * Replacing `Return` to `Returns` in function docs
* Added documentation for spectral layout (#2971) (#3292)Jens P2019-01-091-0/+5
| | | | | | | * Added documentation for spectral layout (#2971) * Refined documentation for spectral layout (#2971) Fixes #2971
* Removed internal use of deprecated np.matrix type. (#3109)Neil2018-08-031-8/+3
|