summaryrefslogtreecommitdiff
path: root/networkx/readwrite
Commit message (Collapse)AuthorAgeFilesLines
* Use unpacking operator on dicts to prevent constructing intermediate objects ↵DiamondJoseph2023-05-023-15/+8
| | | | (#6040)
* Fix typos (#6620)Harri Nieminen2023-04-044-9/+9
|
* Better default alpha value for viz attributes in gexf writer (#6612)Ross Barnowski2023-04-032-1/+11
| | | | | | | | | | | * Add test that fails with current default ('None') * Update default alpha value. Co-authored-by: Dan Schult <dschult@colgate.edu> --------- Co-authored-by: Dan Schult <dschult@colgate.edu>
* Use generator to limit memory footprint of read_graph6. (#6519)Ross Barnowski2023-03-191-1/+1
|
* Lint using Ruff (#6371)danieleades2023-02-199-61/+78
| | | | | | | | | | | | | | | * 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-144-6/+3
| | | | | * Update developer requirements * Run linter
* Fix docstring heading title. (#6424)Ross Barnowski2023-02-121-4/+4
|
* Add generate / write "network text" (formerly graph_str) (#5602)Jon Crall2023-01-302-202/+1755
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add graph_str Formatted Fix bug in choosing the source Fix test * Fixed issue in choosing source verticies for directed graphs * reasonable working state * Fixed logic issues Fix test, cleanup, formatting more tests, better comments, fix parent labels fix pypy issue Fix format * Fixes based on review * Cleaned up test names * Use open_file decor and remove graph_str * Remove useage of forest_str from doctest * Fix style * style * Update networkx/readwrite/text.py Co-authored-by: Dan Schult <dschult@colgate.edu> * Fixed half sentense * Add max_depth * moved comment position * Describe max depth in algo description * Allow with_labels to be specified as a str * Update networkx/readwrite/text.py Co-authored-by: Mridul Seth <mail@mriduls.com> * Add network text autodoc stub * Add removal note for forest_str --------- Co-authored-by: Dan Schult <dschult@colgate.edu> Co-authored-by: Mridul Seth <mail@mriduls.com>
* DOC: Minor formatting fixups to get rid of doc build warnings. (#6363)Ross Barnowski2023-01-132-2/+2
| | | Minor formatting fixups to get rid of doc build warnings.
* Fix typos in the networkx codebase (#6335)Anurag Bhat2023-01-052-4/+4
| | | | | * Fix_Typos * Commit_Suggestions
* Amount of nodes and edges have mistakes when reading adjlist file (#6132)Alimi Qudirah2022-11-011-0/+13
| | | | | | | | | | | | | | | | | | | | | * fixes #6036 * test load centrality * test dispersion * test dispersion * dispersion test * test dispersion * bug-fixes-for-issue-6088 * deleted * fixes for 5911 * bugfix for 5911
* Update GML parsing/writing to allow empty lists/tuples as node attributes ↵Ross Barnowski2022-10-192-10/+28
| | | | | | | | | | | | | (#6093) * Add failing test for empty list corner case. * Rm test case that rejects empty lists as attributes. * Beef up test by checking full round-trip. * Modify gml parsing to handle empty lists. * Parametrize test: lists and tuples.
* Add missing asserts to tests (#6039)DiamondJoseph2022-10-124-7/+7
| | | Fixes gh-5981: Add missing asserts to tests
* Propose to make new node_link arguments keyword only. (#5928)Ross Barnowski2022-08-171-1/+9
| | | Propose to make new node_link args kwarg only.
* Bump nodelink args deprecation expiration to v3.2 (#5933)Ross Barnowski2022-08-171-6/+6
| | | | | * Bump deprecation expiration for nodelink params to v3.2. * Fixup warnings filter.
* signature change for `node_link` functions: for issue #5787 (#5899)Kevin Brown2022-08-112-44/+232
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * added tests for new signature - kept all the original tests. Tagged the tests to remove after signature change is complete. - leveraged a test from test_cyctoscape.py, checks for warnings. - made new versions of tests that use attrs in the signature. * Verified that the new tests fail. Good. * update signatures with keywords * added warning message * adapted code to use keywords * move test with recwarn fixture outside of class when recwarn was used in a method, got an error. work fine in a function. * add warning to node_link_graph() * update node_link_graph() to use keywords * use recwarn in test to dectect warnings * added deprecation notices to doc strings. Needs version number for when deprecation will happen * added example code from doc string to tests * gave default values to elements of attrs the example code passes a dict with only some of the keywords defined. So the defaults needed to be provided * fixed name conflict * brace in docstring * drop braces in doc string example * Changed namespace to nx in doc string examples * update the examples - show the results of the examples - add more examples of serialization with json * Update doc desc and notes - Add reference to Serialization in the method description. - add a note that the keywords chose for the attributes names must match if the two functions are to be used together * clean up wording * document the version numbers for deprecating deprecate the change in 2.8.6 remove the change in 3.1 * Add note, on using old and new keywords together * Add Deprecation Warning to conftest.py * Add a reminder to remove code & docs in 3.1
* Remove old Appveyor cruft (#5924)Jarrod Millman2022-08-112-4/+4
| | | | | * Remove old Appveyor cruft * Fix Windows issue
* Remove OrderedGraphs (#5813)Jarrod Millman2022-07-125-8/+8
| | | | | | Removes the deprecated OrderedGraph classes. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Dan Schult <dschult@colgate.edu>
* Remove pyyaml dependency (#5763)Jarrod Millman2022-06-213-137/+0
| | | | | | | | * Remove pyyaml dependency * Make mypy happy. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Mridul Seth <seth.mridul@gmail.com>
* Remove gdal dependency (#5766)Jarrod Millman2022-06-163-639/+0
| | | | | | | | * Remove gdal dependency * [skip ci] Rm mention of gdal from roadmap. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Mridul Seth <seth.mridul@gmail.com>
* Remove gpickle (#5773)Jarrod Millman2022-06-163-185/+0
|
* remove old attr keyword from json_graph/tree (#5785)Matt Schwennesen2022-06-162-86/+2
|
* update cytoscape functions to drop old signature (#5784)Dan Schult2022-06-162-88/+2
| | | update cytoscape functions with new signature
* Rm jit.py (#5751)Dilara Tekinoglu2022-06-153-185/+0
| | | Co-authored-by: dtuncturk <dilaramemis@sabanciuniv.edu>
* Use isort with pre-commit to enforce import guidelines (#5659)Mridul Seth2022-06-0232-44/+72
| | | | | * Add isort to pre-commit * Run isort on all python files (except __init__.py ones)
* Fix issue probably-meant-fstring found at https://codereview.doctor (#5574)code-review-doctor2022-04-241-1/+1
|
* Don't use graph6 with directed graphs (#5443) (#5444)Riccardo Bucco2022-03-312-8/+61
| | | | | | | * Don't use graph6 with directed graphs (#5443) * Parametrize graph6 tests * Test graph6 on multigraphs
* Update black (#5438)Mridul Seth2022-03-294-8/+8
| | | | | | | * CI: sync up black dev requirements version with precommit * Run black Co-authored-by: Jarrod Millman <jarrod.millman@gmail.com>
* Deprecate `to_tuple` (#5430)Ross Barnowski2022-03-281-2/+18
| | | | | | | | | * Add _to_tuple private fn to node_link.py. * Deprecate utils.misc.to_tuple. * Add deprecation note. * Add release note.
* Minor improvements from general code readthrough (#5414)Ross Barnowski2022-03-251-1/+14
| | | | | | | | | | | | | * Add deprecated directive to reversed docstring. * Add missing dep directives to shpfiles. * Remove defn of INF sentinel. * typo. * str -> comment in forloop. * STY: appropriate casing for var name.
* Update sparse6 urls to use https (#5424)Ross Barnowski2022-03-251-6/+6
| | | [ci skip]
* Add exception for unconnected graph (#5287)Dimitrios Papageorgiou2022-01-282-0/+7
|
* Update gexf website link in documentation (#5275)Mathieu Bastian2022-01-231-7/+7
| | | Hi, we've recently put the GEXF website again into its own domain http://gexf.net/ so this documentation should be updated. Thanks!
* Compatibility updates from testing with numpy/scipy/pytest rc's (#5226)Ross Barnowski2021-12-122-10/+12
| | | | | | | * Rm deprecated scipy subpkg access. * Use recwarn fixture in place of deprecated pytest pattern. * Rm unnecessary try/except from tests.
* Add Mypy type checking infrastructure (#5127)Ross Barnowski2021-11-173-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Drop Py37 (#5143)Jarrod Millman2021-10-233-115/+8
| | | | | | | | | | | | | | | | | | | * 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-1510-52/+51
| | | | 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.
* More informative GraphML exceptions (#5058)Ross Barnowski2021-09-142-6/+53
| | | | | | | | | * Add tests that fail on uninformative exception. * Raise informative exception when non-supported type used. * Add importorskip to new tests. * Change naming scheme for backward compatibility.
* Add see also refs to de/stringizers in gml docstrings. (#5053)Ross Barnowski2021-09-101-0/+6
|
* Support `comments=None` in read/parse edgelist (#5051)Ross Barnowski2021-09-102-7/+18
| | | | | | | * Add support for comments=None in parse_edgelist. * Update docstrings. * if instead of try/except.
* Style changes (#5022)Dan Schult2021-08-141-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* fix typo (#5008)Xiangyu Xu2021-08-052-2/+2
| | | | | | | | | * fix typo * fix pyyaml typo * Apply changes to other relevant __getattrs__. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Added security warning to gefx parser (#5003)bt-nia2021-08-041-0/+5
| | | | | * Added security warning to gefx parser * apply proposed changes from other pull request.
* added security warning for graphml files (#5004)bt-nia2021-08-041-0/+6
| | | | | | | | | * added security warning for graphml files * Update networkx/readwrite/graphml.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Added security warning to the pickle documentation (#5002)bt-nia2021-08-041-0/+4
| | | | | | | * Added security warning to the pickle documentation This text should warn developers about the risks involved using this format. * add changed proposed from other pull request
* Expand destringizer example in read_gml docstring (#4925)Randy2021-06-281-1/+13
|
* Update read_gml docstring with destringizer ex (#4916)Randy2021-06-221-15/+16
| | | | | | | | | | | | | | | | | * Update read_gml docstring with destringizer ex Responding to issue 4877 by adding a simple destringizer example to the read_gml docstring. * Update doc strings The documentation stated that the code can read data types other than str without specifying a destringizer. While the code can write several other data types, a destringizer is required for any type other than str. The documentation is repeated in the file and was updated in all 5 places: the gml.py module docstring, as well as the read_gml, parse_gml, generate_gml, and write_gml docstrings. Co-authored-by: Randy Weaver <randyweaver@randys-mbp.attlocal.net>
* bugfix-for-issue-4353: modify default edge_id format (#4842)Berlin Cho2021-06-142-5/+158
| | | | Allow selection of an edge attribute to be the edge id when writing GraphML. Adds edge_id_from_attribute kwarg.
* Decode GraphML/yEd shape type (#4694)Attila Nagy2021-06-142-3/+45
| | | | Decode and preserve GraphML/yEd shape type and add tests for description and yworks GenericNode
* DOC: Fix links, use DOI links, wayback machine where required (#4868)Mridul Seth2021-06-081-1/+1
| | | | | | | | | | | * 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>