summaryrefslogtreecommitdiff
path: root/networkx/classes
Commit message (Collapse)AuthorAgeFilesLines
* Handle weights as `distance=` in testing dispatch (#6671)Erik Welch2023-05-131-0/+3
| | | | | | | | * Handle weights as `distance=` in testing dispatch * fix `test_intersection` This change was suggested here: https://github.com/python-graphblas/graphblas-algorithms/pull/62#issuecomment-1531810715
* Allow multiple graphs for `@nx._dispatch` (#6628)Jim Kitchen2023-04-251-38/+74
| | | | | | | | | | | | | * Allow multiple graphs for nx._dispatch A new `graphs` keyword is added. For the case of two graphs named `G` and `H` as the first to arguments in `foo`, the new spelling is @nx._dispatch(graphs="G,H") def foo(G, H, other_arg, **kwargs): ... * Use better default "G" for graphs kwarg * fix
* Test dispatching via nx-loopback backend (#6536)Jim Kitchen2023-03-282-2/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add tests for nx._dispatch decorator The dispatch functionality is used to delegate graph computations to a different backend. Because those backends are not part of NetworkX, testing the dispatching feature was not originally added, relying instead on the other backends (e.g. graphblas-algorithms) to verify the dispatch functionality is working. This change creates a "loopback" backend where NetworkX dispatches to itself for the sole purpose of exercising the dispatching machinery. In one incarnation, various tests are augmented to use the LoopbackGraph family and force loopback dispatching to occur as normal usage would. A second incarnation forces *all* tests to run in dispatch mode but use of a different _dispatch decorator. This mode is triggered for all of pytest, so it must be tested by the CI system specifically. * Update CI to hopefully run dispatching auto tests * Formatting * More formatting fixes * Better comments explaining dispatching tests
* Fix len operation of UnionAtlas (#6478)Dan Schult2023-03-142-3/+3
|
* tweak `test_override_dispatch` to allow G keyword (#6499)Erik Welch2023-03-131-1/+7
| | | | | | | | | | | This is a simple follow-up to #6471, and, as in that PR, this fix is short term. We would like to find a more elegant, robust solution (probably after nx 3.1). I sometimes forget there are two versions of `_dispatch`, and this PR fixes the one that gets used when `NETWORKX_GRAPH_CONVERT` environment variable is set. NetworkX does not yet test `test_override_dispatch`, so it's not easy to add a test, but it gets used by external backends such as `graphblas_algorithms`. Ideally, we should test this in NetworkX, which will require calling subprocess in a test with an environment variable set.
* Ignore weakrefs when testing for memory leak (#6466)Erik Welch2023-03-111-1/+14
| | | | | * Ignore weakrefs when testing for memory leak * Add educational comments about gc and weakrefs
* Allow first argument to be passed as kwarg in dispatcher (#6471)Dan Schult2023-03-112-1/+21
| | | | | * tweak _dispatch to allow func(G=G) pattern in signature Co-authored-by: Erik Welch <erik.n.welch@gmail.com>
* Lint using Ruff (#6371)danieleades2023-02-1912-130/+117
| | | | | | | | | | | | | | | * lint and fix using ruff * add flake8-pie lints * remove useless import alias * bump version * bump deps --------- Co-authored-by: daniel.eades <daniel.eades@hotmail.com>
* Update developer requirements (#6429)Jarrod Millman2023-02-141-2/+2
| | | | | * Update developer requirements * Run linter
* DOC: Minor formatting fixups to get rid of doc build warnings. (#6363)Ross Barnowski2023-01-131-21/+18
| | | Minor formatting fixups to get rid of doc build warnings.
* Fix typos in the networkx codebase (#6335)Anurag Bhat2023-01-051-1/+1
| | | | | * Fix_Typos * Commit_Suggestions
* Fix docstrings (#6329)Jarrod Millman2023-01-042-4/+4
|
* fix warnings for make doctest (#6323)Dan Schult2023-01-042-2/+4
|
* doc: update documentation when providing an iterator over current graph to ↵Sultan Orazbayev2022-12-123-0/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | add/remove_edges_from. (#6268) * doc for add_edges_from * doc for digraph * doc for multigraph * multigraph.add_nodes_from returns keylist * update docs for graph - edges * doc update: graph.add_nodes_from * doc update: graph.remove_nodes_from * doc update: graph.add_edges_from * doc update: rewording for graph.add_edges_from * doc update: graph.add_weighted_edges_from rewording * doc update: digraph updated as graph * doc update: digraph minor sync * doc update: multigraph same as graph * Update graph.py * Update digraph.py * Update multigraph.py
* Add clear edges method to the list of methods to be frozen by the nx.… (#6190)Adam Richardson2022-11-152-0/+14
| | | | | * Add clear edges method to the list of methods to be frozen by the nx.freeze function * Change tests to create new graph instead of using class attribute
* Di graph edges doc fix (#6108)nsengaw4c2022-11-142-4/+13
| | | | | | | | | | | | | | | * Improve documentation for the View classes * space removed * use G instead of g * update the line a few above to in_edges : InEdgeView or InEdgeDataView * Minor tweaks to docstring, update summary. * Apply similar changes to MultiDiGraph.in_edges docstring. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Add ThinGraph example to Multi*Graph doc_strings (#6160)nsengaw4c2022-11-092-0/+42
|
* plugin based backend infrastructure to use multiple computation backends (#6000)Mridul Seth2022-11-082-0/+225
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Wrappers classes to dispatch to a backend * Rework the backend dispatching - Use __networkx_plugin__=name to find graph-like objects instead of subclassing - Add PluginInfo to smooth over differences in importlib.metadata across python versions - Add dispatch behavior override via environment variable to aid in testing plugins * Dispatch more algorithms and improve auto-test capabilities * Allow dispatcher decorator without a name - Name is taken from the decorated function - Raise error if backend doesn't implement a decorated function which is called - Check for duplicate names for dispatching algorithms * Make sphinx pick up backend docs * make black happy * Rename decorator to _dispatch as it's experimental * A few more dispatched functions * Make convert to and from methods for auto-testing - Rename `convert` to `convert_from_nx` - Add `convert_to_nx` function These will allow backends to return native objects when dispatching, but provide a mechanism to convert the result to the type expected by NetworkX tests for the auto-test plugin mechanism. * More dispatching * Include name with `convert_**_nx` methods * Remove known plugin names This check is not needed, as any plugin can register itself in the entry points section. The dispatching and auto-testing explicitly specify the plugin to use, so there is no need to hardcode the options. These were originally included for security, but any malicious actor would simply use one of the valid names, so having a hardcoded list does not actually provide any meaningful security. * Add `dispatchname` to dispatchable functions Co-authored-by: Jim Kitchen <jim22k@gmail.com> Co-authored-by: Erik Welch <erik.n.welch@gmail.com>
* Update pytest (#6165)Jarrod Millman2022-11-012-12/+12
|
* Improve test coverage for digraph class (#6130)Alimi Qudirah2022-10-271-0/+4
| | | | | | | | | | | | | | | | | | | | | * fixes #6036 * test load centrality * test dispersion * test dispersion * dispersion test * test dispersion * bug-fixes-for-issue-6088 * deleted * bugfix for issue 6109 * deleting unrelated commits
* Improve test coverage for multidigraph class (#6131)Alimi Qudirah2022-10-271-0/+4
| | | | | | | | | | | | | | | | | | | * fixes #6036 * test load centrality * test dispersion * test dispersion * dispersion test * test dispersion * bug-fixes-for-issue-6088 * deleted * fixes-for-6119
* Improve test coverage for graph class (#6105)Alimi Qudirah2022-10-251-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fixes #6036 * test load centrality * test dispersion * test dispersion * dispersion test * test dispersion * bug-fixes-for-issue-6088 * deleted * bug-fix-for-issue-6092 * bugfix-for-issue-6088 * bugfix-for-issue-6088 * bugfix-for-issue-6088 * bugfix-for-issue-6102 * bugfix-for-issue-6102 * bugfix-for-issue-6102
* Improve test coverage for multigraph class (#6101)Alimi Qudirah2022-10-211-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | * fixes #6036 * test load centrality * test dispersion * test dispersion * dispersion test * test dispersion * bug-fixes-for-issue-6088 * deleted * bug-fix-for-issue-6092 * bugfix-for-issue-6088 * bugfix-for-issue-6088 * bugfix-for-issue-6088 * bugfix-issue-6088
* Use scipy.sparse array datastructure (#6037)Jarrod Millman2022-10-125-6/+5
| | | | | | | | | | | | | | * Use scipy.sparse array datastructure * Add reminder to rm wrapper when scipy adds creation fns. * Rm mention of np matrix from code comment. * Update networkx/algorithms/bipartite/matrix.py Co-authored-by: Stefan van der Walt <sjvdwalt@gmail.com> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Stefan van der Walt <sjvdwalt@gmail.com>
* Minor docstring touchups and test refactor for `is_path` (#5967)Ross Barnowski2022-09-082-19/+15
| | | | | | | | | | | | | | | * Touch up docstring. * Condense conditional. * Minor refactor of ispath test - parametrize and rm redundant. * Add release note. * Update networkx/classes/function.py Co-authored-by: Dan Schult <dschult@colgate.edu> Co-authored-by: Dan Schult <dschult@colgate.edu>
* Change is_path to return False when node not in G instead of raising ↵pmlpm19862022-09-062-1/+10
| | | | | | exception (#5943) Formerly, is_path raised a KeyError when one of the nodes in the input path was not actually in G. This PR modifies the function so that it returns False in this case instead of raising an exception.
* Updated networkx/classes/function.py . Solves Issue #5463 (#5474)0ddoe_s2022-08-231-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Updated networkx/classes/function.py * Reformatted using black * Update networkx/classes/function.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/classes/function.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/classes/function.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Applying style manually Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Apply style manually Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Added example * Updated * Update case of multigraph and case of using G.edges to set H * format doc_string example Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Dan Schult <dschult@colgate.edu>
* Add cache reset for when G._node is changed (#5894)Dan Schult2022-07-252-0/+28
|
* Attempt to reverse slowdown from hasattr needed for cached_property (#5836)Dan Schult2022-07-167-26/+117
| | | | | | | | | | | | | | | | | * Automate reset of cache for _adj,_pred,_succ * Make G._adj a data descriptor that resets G.adj when needed. * update places in the code where both G._succ and G._adj are changed This is no longer needed since G._succ and G._adj are synced during __set__ * testing hasattr(G, `_adj`) no longer ensures an instance. * Make mypy happy * Switch to hardcode attribute names in the data descriptors * Improve doc_strings for the data descriptors
* Move factory attributes to the class instead of instance. (#5850)Dan Schult2022-07-154-16/+0
| | | Move factory attributes to the class instead of instance. ?speedup?
* Update tests in base class and simple rename in convert.py (#5848)Dan Schult2022-07-152-10/+52
|
* Remove OrderedGraphs (#5813)Jarrod Millman2022-07-129-284/+4
| | | | | | Removes the deprecated OrderedGraph classes. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Dan Schult <dschult@colgate.edu>
* Remove deprecated function nx.info (#5759)Mridul Seth2022-06-213-79/+2
| | | | | | | | | | * Remove deprecated function nx.info * remove functions from TOC * replace print(nx.info(G)) with print(G) in example Co-authored-by: Dan Schult <dschult@colgate.edu> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Remove copy methods for Filter* coreviews (#5776)Mridul Seth2022-06-212-183/+0
|
* Touchups to MG and MDG edges docstrings. (#5708)Ross Barnowski2022-06-092-16/+20
|
* Some more changes to make pytest-randomly happy (#5719)Mridul Seth2022-06-091-1/+5
| | | | | * Compare edges without worrying about order to work with pytest-randomly * add another revert to make pytest randomly pass
* Update multigraph docstrings to reflect `remove_edges_from` behavior. (#5699)Ross Barnowski2022-06-082-8/+44
| | | | | | | | | * Update MG docstring to reflect rm_edges_from behavior. Also adds example. * Update remove_edge docstring in MG and MDG. * Fix MDG examples.
* Another catch by pytest-randomly (#5685)Mridul Seth2022-06-021-1/+1
|
* Use isort with pre-commit to enforce import guidelines (#5659)Mridul Seth2022-06-0218-40/+51
| | | | | * Add isort to pre-commit * Run isort on all python files (except __init__.py ones)
* Update subgraph views tests to pass with out of order execution (#5683)Mridul Seth2022-06-021-2/+10
|
* Fix __setstate__ for OutEdgeView subclasses, read _adjdict from state (#5657)Mridul Seth2022-05-202-4/+33
| | | | | * Fix __setstate__ for OutEdgeView subclasses, read _adjdict from state * add a test to check cacheing and slots work together
* Cache edges, degree, adj properties of Graph classes (#5614)Dan Schult2022-05-118-28/+71
| | | | * Make all graph properties cached properties * one test function is not needed due to test inheritance
* Cache `nodes` property on Graph (#5600)Stefan van der Walt2022-05-082-7/+7
|
* Update .degree() docs: outdated return type (#5529)Brit2022-04-284-27/+16
| | | | | | Fix the return type and description for the `degree` method in the docstrings of all the graph classes. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* replace induced_subgraph example with directly relevant example (#5576)Brian A. Heckman2022-04-251-2/+4
|
* Fixed wrong dict factory usage on MultiDiGraph (#5456)FabianBall2022-04-044-1/+75
| | | | | | | | | * Fixed the issue that the wrong dict factory on a MultiDiGraph was used for edge attributes (edge_key_dict_factory instead of edge_attr_dict_factory) Extended tests to typecheck the dict factories and added a test that incorporates custom dict factories on a MultiDiGraph * Mypy ignore inferred types in MDG subclass. Co-authored-by: Fabian Ball <fabian@codagio.de> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Correct typo in docstring (int -> float) (#5398)Sultan Orazbayev2022-03-181-2/+2
| | | | | | | | | * Correct typo in docstring (int -> float) This is based on https://stackoverflow.com/q/71494698/10693596 * Update function.py * Update function.py
* Multigraph docs update (#5389)Peter Mawhorter2022-03-141-49/+89
| | | | | | | | | | | | | | | | | | | | | * Updated MultiDiGraph documentation to include more examples of actually using parallel edges, and fixed references to things like G[u, v] where G[u, v, k] is required for a MultiDigraph. Have not made parallel changes in MultiGraph which should maybe also be made? Docs tests pass on my end; no code outside of comments was changed. -Peter Mawhorter * Updated docs for MultiGraph to add more multigraph-specific examples and fix a few places where untested examples were wrong. -Peter Mawhorter * [DOC] fix typo * add the right amount of separators Co-authored-by: Mridul Seth <mail@mriduls.com>
* Updated MultiDiGraph documentation to include more examples of actually (#5387)Peter Mawhorter2022-03-141-25/+48
| | | | | | | | | using parallel edges, and fixed references to things like G[u, v] where G[u, v, k] is required for a MultiDigraph. Have not made parallel changes in MultiGraph which should maybe also be made? Docs tests pass on my end; no code outside of comments was changed. -Peter Mawhorter
* Fix missing backticks (#5381)Matthias Bussonnier2022-03-093-6/+6
| | | | | * Fix missing backticks * one more backticks