summaryrefslogtreecommitdiff
path: root/networkx/classes/function.py
Commit message (Collapse)AuthorAgeFilesLines
* Lint using Ruff (#6371)danieleades2023-02-191-4/+1
| | | | | | | | | | | | | | | * 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>
* Add clear edges method to the list of methods to be frozen by the nx.… (#6190)Adam Richardson2022-11-151-0/+1
| | | | | * 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
* Minor docstring touchups and test refactor for `is_path` (#5967)Ross Barnowski2022-09-081-7/+5
| | | | | | | | | | | | | | | * 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-061-1/+6
| | | | | | 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>
* Remove deprecated function nx.info (#5759)Mridul Seth2022-06-211-46/+0
| | | | | | | | | | * 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>
* Use isort with pre-commit to enforce import guidelines (#5659)Mridul Seth2022-06-021-3/+2
| | | | | * Add isort to pre-commit * Run isort on all python files (except __init__.py ones)
* replace induced_subgraph example with directly relevant example (#5576)Brian A. Heckman2022-04-251-2/+4
|
* 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
* Deprecate info (#5341)Jarrod Millman2022-02-191-0/+9
|
* Drop Py37 (#5143)Jarrod Millman2021-10-231-1/+1
| | | | | | | | | | | | | | | | | | | * Drop Py37 * XML serialization issue * Use math.comb Co-authored-by: Simone Gasperini <simone.gasperini2@studio.unibo.it> * Run pyupgrade --py38-plus * Run black * More documentation * Deprecate euclidean Co-authored-by: Simone Gasperini <simone.gasperini2@studio.unibo.it>
* Change exception varname e to err (#5130)Dan Schult2021-10-151-2/+2
| | | | 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.
* Update black (#4814)Jarrod Millman2021-05-181-3/+3
|
* Fix docstrings and remove unused variables (#4501)Andrea Tomassilli2021-01-091-0/+2
| | | | Co-authored-by: Dan Schult <dschult@colgate.edu> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* DOC: Switch from napoleon to numpydoc sphinx extension (#4447)Ross Barnowski2020-12-121-1/+1
| | | | | | | * Setup for numpydoc. * Add to doc requirements. * Replace napoleon with numpydoc in conf.py. * DOC: Fixups from numpydoc.
* Test and document missing nodes/edges in set_{node/edge}_attributes (#4346)Ross Barnowski2020-11-131-0/+19
| | | | | | | | | | | | | | | | * TST: parametrize set_node_attributes test. * TST: Add test to improve set_node_attribute coverage. * TST: parametrize set_edge_attribute tests. * TST: add test for set_edge_attributes w/ missing edges. * Add tests for missing edges in values dict. * Add examples to set_{node/edge}_attributes docstrings. Add examples illustrating the silent ignoring of nodes/edges in the values dict that are not in G.
* Add nx.info to str dunder for graph classes (#4241)Ross Barnowski2020-10-091-17/+8
| | | | | | | | | | * Modify graph __str__ to return nx.info. Returns the result of nx.info(self) instead of only the instance name. * TST: Modify tests for new str dunder. * MAINT: move graph summary to __str__ from info
* MAINT: Update nx.info (#4193)Andrew Eckart2020-10-011-18/+12
| | | | | Report name, number of nodes, and number of edges of a graph. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Format python in docstrings (#4168)Jarrod Millman2020-08-191-34/+33
| | | | | | | | | | | | | | | | | | | * Format code w/ black * Format docstrings w/ black * Manual cleanup * Tell pytest to ignore planned deprecations * Don't call plt.show during testing * Another known deprecation * DOC: rm duplicate line from docstring example * Minor cleanup Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Remove unnecessary nx imports from doctests (#4163)Jarrod Millman2020-08-161-3/+0
| | | Co-authored-by: Dan Schult <dschult@colgate.edu>
* Add function to calculate path cost for a specified path (#4069)Danny Niquette2020-07-261-1/+64
| | | | | | | | | | | | | | | | | | | | | | | * Began writing function for specified path cost and associated tests * Cleaned up formatting and finished writing test * Made minor changes as suggested in PR comment. Name changes and syntax changes * polished up and wrote tests for is_path, adjusted tests to include Digraph and MultiDiGraph, added sphinx shorthand in docs * Fixed most pep8 warnings (excluding line too long) * Updated docstring and fixed is_path to have lower memory footprint * minor tweaks to allow rebase * Add credits for contributor * Run black Co-authored-by: DNiquette16 <Dniquette16@gmail.com> Co-authored-by: Dan Schult <dschult@colgate.edu> Co-authored-by: Jarrod Millman <jarrod.millman@gmail.com>
* Allow G.remove_edges_from(nx.selfloops_edges(G)) (#4080)Dan Schult2020-07-201-1/+1
|
* Format w/ blackJarrod Millman2020-07-101-46/+91
|
* Remove trailing spacesJarrod Millman2020-07-101-1/+1
|
* Fixing docs for nx.info(), along with necessary tests (#3893)Pradeep Reddy Raamana2020-04-061-1/+15
| | | | | | | | | | | * documenting the behaviour correctly * adding tests to lock the behaviour * PEP * one-line docstring * pep
* Upgrade to Py36 syntaxJarrod Millman2020-01-011-2/+2
| | | | find networkx -name \*.py -exec pyupgrade --py36-plus {} \;
* Convert %-format to fstringJarrod Millman2020-01-011-11/+10
|
* Remove boiler plate from top of modulesJarrod Millman2019-11-111-10/+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.
* Remove unused importsJarrod Millman2019-10-181-4/+0
|
* Document subgraph_view (#3627)Anton Lodder2019-10-081-12/+6
| | | Fixes #3625
* fix to_directed function (#3599)Salim BELHADDAD2019-09-241-1/+1
| | | The `as_view=True` argument is missing so the function returns a deepcopy instead of a view.
* Remove future imports needed by Py2Jarrod Millman2019-09-181-1/+0
|
* Update copyrightJarrod Millman2019-03-301-1/+1
|
* Replacing `Return` to `Returns` in docs for functions (#3301)Moradnejad2019-02-181-16/+16
| | | | | | * Fixed problem in documentation view of this function * Replacing `Return` to `Returns` in function docs
* adding support for singleton in add_path and add_star (#3285)Tanay Gahlot2019-01-021-2/+12
| | | | | | | | | | Fixes #3277 * adding support for singleton in add_path and add_star * adding test cases for singleton * adding test cases that cover the try-except loop for add_star and add_cycle
* fix frozen function (#3279)Eyal2018-12-241-1/+1
| | | | frozen should have kwargs otherwise when calling a frozen graph method with a keyword you get a TypeError : frozen() got an unexpected keyword argument ..
* replace deprecated fresh_copy with __class__ (#3278)Antoine Prouvost2018-12-241-1/+1
|
* Simplify the Graphview and SubGraphView system (#3073)Dan Schult2018-07-201-36/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Simplify the Graphview and SubGraphView system - add tests to show that extensions of base graph classes (only add new functions) should be able to use the Graph.subgraph and Graph.copy methods easily - Remove ReadOnlyGraph class in favor of existing freeze() function - Switch all GraphView classes to generic_graph_view function - Switch all SubGraph classes to subgraph_view function - Introduce deprecated functions that act like the deprecated classes. Still need to: - add docs - add tests - make sure backward compatible and marked as deprecated - remove GraphView and SubGraph construct from rest of codebase - update release docs Fixes #2889 Fixes #2793 Fixes #2796 Fixes #2741 * Ease subclassing for to_(un)directed - add to_directed_class indicator functions to base classes - start deprecating G.fresh_copy - update function.to(un)directed * Remove G.fresh_copy from code replace with __class__ Add deprecation warnings for GraphView classes, ReverseView and SubGraph. Also for fresh_copy function.
* Update docs for G.copy and set_*_attributes. (#3024)Dan Schult2018-06-191-10/+17
| | | | | | | | | | | | | | | | | | | | | | * Update docs for G.copy and set_*_attributes. Fixes #2899 and #2859 * fix tutorial and docs of to_*directed Fixes #2849 * fix docs for asyn_fluidc Fixes #2845 * Allow seed to change in connected_watts_strogatz_graph Also update docs. Fixes #2809 * Add tests for exceptions to asyn_fluidc * Add tests for random graphs
* Remove cyclic reference in G.root_graph (#3014)Dan Schult2018-06-161-7/+7
| | | | | | | | * Remove a second cyclic reference in G.root_graph Related to #3011 and #2885 and maybe #2793 * Add tests for memory leaks due to copy()
* Update docs for set_node-edge_attributes per #2916 (#2920)Dan Schult2018-04-021-0/+6
|
* Misc. typos (#2872)luzpaz2018-02-141-3/+3
| | | | | | | | | | Found via `codespell -q 3 -I ../networkx-whitelist.txt` where whitelist consisted of: ``` ans childs iff nd te ```
* Corrected some variable names in documentation. (#2860)Mads Jensen2018-01-311-0/+6
|
* Update copyrightJarrod Millman2018-01-201-1/+1
|
* change variable names to avoid kwargs clobber (#2824)Dan Schult2018-01-101-16/+16
| | | | | | | I didn't change functions defined in tests. I also left drawing routines as is at least for now. Addresses #1582 Fixes #1583
* fix add_path to add the first node when the length of the given node list is oneSanghack Lee2017-11-181-1/+7
|
* Fix links (#2663)Jarrod Millman2017-09-111-2/+2
| | | | | | * Fix links * Comply with pep8
* Replace __class__ with fresh_copy in G.reverse and elsewhere (#2649)Dan Schult2017-09-071-1/+1
| | | | | Fixes #2648 Noticed hidden errors with G.name in operators.py
* Unravel subgraph chains (#2635)Dan Schult2017-08-261-2/+25
| | | | | | | | | | | | * Shortcut chains of subgraph views in common cases. Turns out the general case of chains of subgraph views is hard to make a shortcut for. So this only does the common case of node induced subgraphs of subgraphs. * Add tests for subgraph chains * Add more tests of chains of subgraphs
* Update docsJarrod Millman2017-08-181-1/+1
|