| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
* Run linter
|
| |
|
|
|
| |
* 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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
| |
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
| |
* 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>
|
| |
|
|
|
| |
* Add isort to pre-commit
* Run isort on all python files (except __init__.py ones)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
| |
|
|
|
|
|
| |
* Raise ValueError if None is added as a node.
Removed some tests that checked that errors raised when None was a node.
* update tutorial to make a stronger statement about None
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Refactor testing utilities
Change `assert_edges_equal`, `assert_graphs_equal`, and `assert_nodes_equal`
to be more pytest-idiomatic.
For example, `assert_edges_equal` becomes the Boolean function `edges_equal`
and then the assert is done the testing file
(i.e., `assert edges_equal(edges1, edges2)`).
This also makes these utility functions useful in nontesting situations
where you want to compare edges, but not raise an exception based on the result.
* Move testing utility functions
* Use new testing utilities
* Deprecate assert_*_equal testing utilities
* Document node, edge, and graph equality helper functions
* text nits.
* Update networkx/tests/test_convert_pandas.py
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Update networkx/readwrite/tests/test_sparse6.py
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Update networkx/readwrite/tests/test_graph6.py
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Update networkx/generators/tests/test_classic.py
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Update networkx/algorithms/tree/tests/test_operations.py
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Update networkx/algorithms/tree/tests/test_coding.py
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Update networkx/algorithms/tests/test_dag.py
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Update networkx/algorithms/minors/tests/test_contraction.py
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* add short equality description to docstring
* Suppress known warnings
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Co-authored-by: Dan Schult <dschult@colgate.edu>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#4351)
* TST: Improve coverage of restricted_view.
Refactor original test into two parametrized tests that cover all
graph types.
* TST: Break up selfloop edges test into smaller tests.
Refactors test_selfloops into four smaller tests, each focused on
specific behavior.
* TST: improve coverage of selfloop_edges.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
| |
|
|
|
| |
Report name, number of nodes, and number of edges of a graph.
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
| |
* documenting the behaviour correctly
* adding tests to lock the behaviour
* PEP
* one-line docstring
* pep
|
| |
|
|
| |
find networkx -name \*.py -exec pyupgrade --py36-plus {} \;
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
| | |
|
| |
|
|
|
|
|
|
|
|
| |
* move selfloop methods out of graph classes into function.py
* replace G.node with G.nodes. fix Pickle of views
* Replace G.edge with G.edges
* Add a few lines of docs for release realted to this PR.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Update code to prepare for melding graphviews
* Meld graphviews into graph classes
* Cleanup subgraph calling sign. and remove duplicate code
* Add some tests for raising exceptions
* update edge_kcomponents to avoid readonly views.
* Add root_graph attribute and tests
Update tests for root_graph as well as fresh_copy.
I left fresh_copy as an attribute even with root_graph
because a view might switch the data structure of the
view from directed to undirected. Going to the root_graph.__class__
may not give you what you need to create a graph like the view.
Fresh_copy gives a null graph with the directed/multi type of that
view or graph.
|
| |
|
|
|
|
|
|
|
|
| |
* Remove default setting of G.name in generators.
I left them for Atlas.py and small.py as the seemed to be useful for
telling which graph is which when creating many.
Fixes #1906
* Fix expected outcomes on tests re G.name
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
* make set_node_attriutes() work with any kind of container
* switch arguments in docstring and adapt comments
* Make set_edge_attributes() with any kind of container
* Update release notes with #2553 set/get_node/edge_attributes
* Update package codebase with API change for set_*_attributes
Fixes #2343
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add minimal docstrings
* Add note about ordered graph variants
* Mention ordered variant in `See Also` section
* Comply with pep8
* Replace reference to LogGraph with PrintGraph
LogGraph was a reference to a graph that logged each mutation.
That's what PrintGraph does and is provided in the examples directory.
* Do not claim OrderedGraphs maintain the order of adding edges
* Remove OrderedGraph examples and minor cleanup for Sphinx
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#2475)
* Dont assume iterators for nodes/edges/degrees (prep for views)
* Add graph view classes for nodes/edges/degree
* Add right set operations (not present in python3.3 KeysView
* Add nodes before adding edges so python36 tests work
By only adding edges, the nodes were added in order (0,1,3,2)
and with the ordered nature of python3.6 dicts the tests failed.
Could also fix by using nodelist on each call to to_convert_...
* weighted graph convert tests testing empty graphs
The edge iterator was exhausted for source before being used for dest
* allow DegreeView to include case of nbunch
* Make node/edge/degree properties of Graph
* View contains fix and Viewers can return self. More tests
* Add more tests including one for #2347
* Add nbunch tests and pep8
* Rename to EdgeView and EdgeDataView
* docs tweaks and pep8
* fix up nodeDataView contains. Add and clean up tests.
* Change the graph attributes to read-only properties
* Reframe views code and extend _node to all networkx (still need
examples)
* Clean up and pep8 for view changes
* ername AtlasViews, simplify code and add docstrings
* Make G[u] return a view, and catch some doc bugs
* Update views to use _node,_adj. Add len to EdgeDataView
* minor adjustments to example subclass/printgraph
|
| |
|
|
|
| |
Fix ordering and ambiguity in base class tests.
The conversion of multidigraphs to multigraphs is ambigious since the ordering can determin the number of resulting edges. E.g. the multidigraph [(1,2),(2,1),(2,1)] could result in the multigraph [(1,2)] or [(2,1),(2,1)].
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
| |
iterator for else
|
| | |
|
| |
|
|
|
|
|
| |
Previously `Graph.nodes()` returned a list of nodes and
`Graph.nodes_iter()` returned an iterator over nodes. With this commit,
the former function now returns an iterator and the latter no longer
exists.
|
| | |
|
| |
|
|
| |
Also add unit tests for corner cases.
|
| |
|
|
|
|
|
|
| |
List of changes:
- Rename function to is_weighted()
- Remove unnecessary variable
- Fix code allignment on documentation
- Remove unnecessary else statement
|
| | |
|
| | |
|