summaryrefslogtreecommitdiff
path: root/networkx/algorithms/flow
Commit message (Collapse)AuthorAgeFilesLines
* Fix negative edge cycle function raising exception for empty graph (#6473)Purvi Chaurasia2023-03-111-1/+1
| | | | * Fix negative edge cycle function raising exception for empty graph and added relevant test function * Comment out capacity_scaling test
* Lint using Ruff (#6371)danieleades2023-02-194-10/+10
| | | | | | | | | | | | | | | * 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-1/+0
| | | | | * Update developer requirements * Run linter
* Fix typos in the networkx codebase (#6335)Anurag Bhat2023-01-051-1/+1
| | | | | * Fix_Typos * Commit_Suggestions
* Update pytest (#6165)Jarrod Millman2022-11-011-1/+1
|
* Tested boykov_kolmogorov and dinitz with cutoff (#6104)Paula Pérez Bianchi2022-10-201-1/+10
|
* Update which flow functions support the cutoff argument (#6085)Paula Pérez Bianchi2022-10-192-29/+21
| | | | | | | | | | There was an internal list of functions that was out-of-date with the flow functions which prevented the cutoff parameter being used with many of the flow functions despite being valid. This list has been removed and replaced with explicit reference to the one remaining flow function that doesn't support cutoff. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Remove gpickle (#5773)Jarrod Millman2022-06-163-4/+14
|
* Use isort with pre-commit to enforce import guidelines (#5659)Mridul Seth2022-06-0210-29/+51
| | | | | * Add isort to pre-commit * Run isort on all python files (except __init__.py ones)
* Use sets instead of lists for collecting flowfuncs in tests. (#5589)Ross Barnowski2022-04-271-6/+6
|
* Update black (#5438)Mridul Seth2022-03-291-1/+1
| | | | | | | * CI: sync up black dev requirements version with precommit * Run black Co-authored-by: Jarrod Millman <jarrod.millman@gmail.com>
* Add Mypy type checking infrastructure (#5127)Ross Barnowski2021-11-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Style changes (#5022)Dan Schult2021-08-142-17/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add greedy algorithm for solving TSP Many problems of Combinational Optimization can be represented as graphs. These problems have enormous significance in many aspects of science, but there are not any algorithms to solve some of them in polynomial time. However many, heuristic and metaheuristic algorithms have been published over the past years in order to solve / approximate the solutions to these problems. The purpose of this commit is to add implementation of such algorithms for solve one of the most famous problems of Combinational Optimizations, Travelling Salesman Problem (TSP). A greedy algorithm has been implemented at the moment for this reason. "applications" package has been created which include modules that represent a problem. Each module contains several algorithms for solving the specific problem. At this commit, tsp.py module is added which contains greedy_tsp() function; a implementation of a greedy algorithm. * Fix example error * Trivial changes List of changes: Removal of unnesecary _is_weighted() function Improvements on documentation * Add applications package to setup.py file * Change output of greedy algorithm Algorithm's output is a list of nodes now * Add simulated annealing algorithm Add a metaheuristic local search algorithm for solving TSP * Minor changes * Fix example doc errors * Compatible with python 3 * Move tsp module to algorithms package * Code improvements * Handle small graphs and fix doc examples * Documentation changes and rename variables * Adds Threshold Accepting algorithm for TSP * Implemented maximal matching of minimal weight and created test suite. * Removed useless print * Implemented Christofides. * Coding was missing * Add more general traveling_salesman_problem using christofides Also reconfigure import structure and remove min_weight_matching from module since it is now in matching.py * Add new functions to the docs and minor typos * pep8 fixes * fix pep8 and change .gitignore * Add tests of the approximation namespace update docs in approximation/__init__.py * Fix is_matching to check if edges in G. Other tweaks: doc changes and put not_implemented_for on find_matching functions * Improve is_matching selfloop handling and expand tests * Move tsp to approximation directory. Apply black. * Move tsp tests to approximation tests folder * Attempt to bring tsp up to current code. * commit pep8 that my black didnt change, but pep8speaks did find. ?? * tweak a few things and run black * combine #4083 and #3585 into traveling_salesman.py * Match chistofides output to other tsp functions and adjust calling syntax of tests tweak docs tweak see also section * Put big-O complexity in in-line math env. Prevents sphinx from trying to do variable substitution between pipes. * Minor touchups to christofides docstring. * RST touchups to tsp module docstring. * Rm extra string from tsp module. * Docstring touchups for traveling_salesman_problem. * rst fixups for greedy_tsp docstring. * rst formatting for simulated annealing docstring. * More math in-lining for simulated annealing docstring. * rst and minor grammatical fixes to TA docstring. * Fix path-finding and test all methods for tsp function * the refactoring was incomplete. Now maybe is - Add tests of TSP with all methods. - Refactor tests to match simulated_annealing tests and threshold tests. - Unify treatment of weight so unweighted edges use default weight 1. weight now defaults to "weight" with a default value of 1. - Rename tolerance to max_iterations (tolerance is used for error bound) - Rename iterations to N_inner (each iteration takes this many inner loops) - Introduce idioms like `pairwise` and `cycle.copy()` (over cycle[:]) - Allow passthrough of method kwargs for traveling_salesman_problem Still need to: - add test of case where path is more than one edge less that cycle (incomplete_graph) - require cycle input (maybe make default list(G)??) - consider the complexity claims in the doc_strings * More api changes to TSP functions - `chritofides` now allows (and ignores) selfloops - `move` can be a function as well as "1-1" and "1-0" - `method` for traveling_salesman_problem must have 2 arguments instead of passing kwargs. User must "curry" to set parameters - changed doc_string typos in matching.py * Add test to check that cycle=False can remove many edges * Change init_cycle api to require input from user The idea is to make the user specify the initial cycle to start from rather than relying on the programmers default of a greedy algorithm. To easy usage, I check for a string "greedy" as a shortcut. * Update docs with more correct complexity info. * Check for complete graph now more efficient and selfloops ignored * merge is_matching changes * New Networkx changes * Stub for Asadpour. Needed to create GSoC PR * Update to integrate changes from main * Added function stubs and draft docstrings for the Asadpour algorithm * Skeleton classes and methods for tree iterators * Attempting to set up basic tests for MST of a partition * testing * I'm not entirly sure how the commit hook works... * Moved iterators into the correct files to maintain proper codebase visibility * Including Black reformat * Revert "Merge branch 'networkx:main' into main" This reverts commit 0616a2331adfcc02976d305937aa52272ed48266, reversing changes made to 1ea769371f54c4c6f9a51f860caf4a60aef7d094. * Trying to merge again * Attempting to merge (4) * Now passes all tests except test_namespace_alias in /tests/test_import.py * Everything should FINALLY pass (I wipped my networkx dir and re-download from upstream) * reinstall the pre-commit hook * Grabbing black reformats * Working on debugging ascent method plus black reformats * Ascent method terminating, but at non-optimal solution * minor edits * Fixed termination condition, still given non-optimal result * Minor bugfix, still non-optimal result * Fixed subtle bug in find_epsilon() * Cleaned code and tried something which didn't work * Modified the ArborescenceIterator to accept init partition * Black formats * Branch and bound returning optimal solution * Working Ascent method, code needs cleaning * black formatting changes * Performance tweaks and testing fractional answers * Fixed test bug, I hope * Asadpour output for ascent method * Fixed numpy imports crashing pypi tests * Removed branch and bound method. One unit test misbehaving * Added asymmetric fractional test for the ascent method * Removed printn statements and tweaked final test to be more asymmetric * Draft of spanning_tree_distribution * Black changes * Changed HK to only report on the support of the answer * Fixed contraction bug by changing to MultiGraph. Problem with prob > 1 * Black reformats * Fixed pypi test error * Further testing of dist fix * Can sample spanning trees * Developing test for sampling spanning tree * Changed sample_spanning_tree test to Chi squared test * Tweaked signifiance level * Found true minimum sample size * fixed typo * untested implementation of asadpour_tsp * Fixed issue reading flow_dict * Fixed runtime errors in asadpour_tsp * black reformats * Adding test cases * documentation update * Fixed rounding error with tests * One new test and check * Documentation update for the iterators * Attempting to fix class documentation * Pull out the style changes into a separate branch * fix mixed history * more Co-authored-by: Thodoris Sotiropoulos <theosotr@windowslive.com> Co-authored-by: Luca Cappelletti <cappelletti.luca94@gmail.com> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: mjschwenne <mjschwenne@gmail.com>
* DOC: Fix links, use DOI links, wayback machine where required (#4868)Mridul Seth2021-06-082-3/+3
| | | | | | | | | | | * Fix links, use DOI links, wayback machine where required * Add nx-guides to intersphinx mapping. * Replace external mpl link w/ intersphinx. * Update mpl intersphinx mapping. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Use pytest.approx (#4827)Jarrod Millman2021-05-211-2/+1
| | | | | * Use pytest.approx * Deprecate almost_equal
* restructured networksimplex.py and added test_networksimplex.py (#4685)Harshal Dupare2021-05-192-305/+768
| | | | | | | | | | | | | | | | | | | | | | * restructured networksimplex.py and added test_networksimplex.py * formatting changed * formatting changed * formatting changed * removed extra underscore * added fixture in test_networksimplex.py * formatting changed * initilized -> initialized. * fix typo in comment Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Dan Schult <dschult@colgate.edu>
* Replace generate_unique_node internally where not needed (#4537)Dan Schult2021-01-171-2/+0
| | | | | | | | | | | | | | | | | | Relates to #4224 Relates to #4454 All internal uses of generate_unique_node are better served using more specific methods to choose a node. Two uses end up finding an unused node by counting down from -1 until the integer is not a node. I'm not sure that justifies a utility function to do that so I haven't implemented one, but we could make one (or a graph method) with api: `generated_unused_node(G)` or maybe `G.find_unused_node()`. I like the idiom: ```python node = -1 while node in G: node -= 1 ```
* Correct networkxsimplex docstring re: multigraphDan Schult2020-12-121-2/+2
|
* Remove xml import checks (#4393)Jarrod Millman2020-11-262-8/+8
|
* Format w/ black==20.8b1Jarrod Millman2020-10-067-70/+43
|
* Format python in docstrings (#4168)Jarrod Millman2020-08-1911-201/+209
| | | | | | | | | | | | | | | | | | | * 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-169-13/+0
| | | Co-authored-by: Dan Schult <dschult@colgate.edu>
* Format w/ blackJarrod Millman2020-07-1013-743/+845
|
* Remove trailing spacesJarrod Millman2020-07-101-1/+1
|
* Update string formatJarrod Millman2020-01-013-39/+46
| | | | | | | | | find -name "*py" | xargs grep -n '" % ' find -name "*py" | xargs grep -n '"\.format(' find -name "*py" | xargs grep -n "' %" find -name "*py" | xargs grep -n 'msg % ' find -name "*py" | xargs grep -n ' %d ' find -name "*py" | xargs grep -n '\.format('
* Upgrade to Py36 syntaxJarrod Millman2020-01-015-20/+19
| | | | find networkx -name \*.py -exec pyupgrade --py36-plus {} \;
* Convert %-format to fstringJarrod Millman2020-01-015-10/+10
|
* Refactor testsJarrod Millman2019-11-192-0/+3
|
* Update styleJarrod Millman2019-11-192-66/+65
|
* Remove superfluous encoding informationJarrod Millman2019-11-1112-12/+0
|
* Remove boiler plate from top of modulesJarrod Millman2019-11-1111-70/+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 old Python 2 codeJarrod Millman2019-11-101-9/+0
|
* Fix documentation issues for exceptions in a few placesSøren Fuglede Jørgensen2019-11-091-2/+2
|
* PEP8 fixesJarrod Millman2019-10-187-13/+13
|
* PEP8 fixes to testsJarrod Millman2019-10-184-11/+11
|
* Replace eq_, ok_ with assertJarrod Millman2019-10-122-12/+9
|
* Replace nose.raises with pytest.raises context managerJarrod Millman2019-10-121-7/+7
|
* Replace nose.assert_raises with pytest.raisesJarrod Millman2019-10-122-42/+43
|
* reduce warnings for deprecated functionsDan Schult2019-10-121-2/+2
|
* Remove unused importsJarrod Millman2019-10-122-2/+2
|
* Convert nose.tools.assert_* functions into assertsJarrod Millman2019-10-124-147/+137
|
* First round of pytest fixesStefan van der Walt2019-10-121-0/+0
|
* Add last 7 lines of Gomory-hu algorithm Fixes #3293 (#3614)Dan Schult2019-10-011-3/+11
| | | Fixes #3293
* Update copyrightJarrod Millman2019-03-303-3/+3
|
* Replacing `Return` to `Returns` in docs for functions (#3301)Moradnejad2019-02-182-7/+7
| | | | | | * Fixed problem in documentation view of this function * Replacing `Return` to `Returns` in function docs
* Added gomory hu testIssa Moradnejad2019-01-121-0/+11
|
* Fix several DeprecationWarning: invalid escape sequence (#3284)Mickaël Schoentgen2019-01-082-2/+2
| | | | | | | | * Fix several DeprecationWarning: invalid escape sequence Signed-off-by: Mickaël Schoentgen <contact@tiger-222.fr> * Restore docstring of generalized_degree()
* stop infinite loop in min_cost_flow (#3029)Dan Schult2018-06-282-1/+14
| | | Fixes #2906
* Misc. typos (#2872)luzpaz2018-02-142-6/+6
| | | | | | | | | | Found via `codespell -q 3 -I ../networkx-whitelist.txt` where whitelist consisted of: ``` ans childs iff nd te ```
* Deleted a duplicated test_random_graph in bipartite.tests.test_genera… (#2790)Mads Jensen2018-02-021-1/+1
| | | | | | | | | | | | | | | | | | * Deleted a duplicated test_random_graph in bipartite.tests.test_generators * Renamed test_multigraphs_equal to test_multidigraphs_equal in test_utils * Deleted a duplicated test_adjlist_digraph in test_adjlists in readwrite-tests * Renamed a bunch of duplicated test names. * Deleted a duplicate TestEdgelist.test_edgelist_digraph. * Renamed a duplicate TestOpenFileDecorator.test_writer_kwarg_path. * Fix the broken tests that used to be hidden by duplicate name * Change list to sorted in test for py3.4 and py3.5