summaryrefslogtreecommitdiff
path: root/examples/graph
Commit message (Collapse)AuthorAgeFilesLines
* Add example script for mst (#6525)Purvi Chaurasia2023-03-231-0/+50
| | | | | | | | | | | | | | | | | | | * Fix negative edge cycle function raising exception for empty graph and added relevant test function * Unresolved change * Added example script for generating mst * unresolved changes * update plot_mst.py * Fixed typo Co-authored-by: Dan Schult <dschult@colgate.edu> --------- Co-authored-by: Dan Schult <dschult@colgate.edu>
* Lint using Ruff (#6371)danieleades2023-02-191-1/+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>
* Update developer requirements (#6429)Jarrod Millman2023-02-142-1/+2
| | | | | * Update developer requirements * Run linter
* Fix typos in the networkx codebase (#6335)Anurag Bhat2023-01-051-1/+3
| | | | | * Fix_Typos * Commit_Suggestions
* Gallery example: Morse code alphabet as a prefix tree (#5867)Ross Barnowski2022-07-151-0/+96
| | | | | * Add Morse trie encoding example to gallery. * Clarify explanation.
* Modify DAG example to show topological layout. (#5835)Ross Barnowski2022-06-302-54/+42
|
* Add gallery example visualizing DAG with multiple layouts (#5432)0ddoe_s2022-06-241-0/+54
| | | | | | Show how a simple DAG looks when visualized with various available layouts. Co-authored-by: Dan Schult <dschult@colgate.edu> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Add Triad example plot (#5528)0ddoe_s2022-06-241-0/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add files via upload * Delete from drawing folder * Added in Graphs Folder * Renamed and edited file * Update examples/graph/plot_triad_types.py Co-authored-by: Mridul Seth <mail@mriduls.com> * Update examples/graph/plot_triad_types.py Co-authored-by: Mridul Seth <mail@mriduls.com> * Update examples/graph/plot_triad_types.py Co-authored-by: Mridul Seth <mail@mriduls.com> * updated the plot * Applied black * Adjusted Brackets * More updates to Plot * Removed brackets * put back fig.tight_layout(), rebase on main, reword, reorder edges Co-authored-by: Mridul Seth <mail@mriduls.com> Co-authored-by: Dan Schult <dschult@colgate.edu>
* Remove redundant py2 numeric conversions (#5661)Mridul Seth2022-05-311-1/+1
| | | | | | | | | * Remove redundant float conversion * Remove redundant int conversion * Use integer division Co-authored-by: Miroslav Šedivý <6774676+eumiro@users.noreply.github.com>
* Style changes (#5022)Dan Schult2021-08-142-11/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-081-2/+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>
* fix urllib import (#4793)Xiangyu Xu2021-05-141-2/+2
| | | | | * fix urllib import * update urllib import
* Make main default branch (and remove gitwash) (#4649)Jarrod Millman2021-03-042-2/+2
|
* Refactor gallery (#4422)Jarrod Millman2020-12-062-25/+1
| | | | | | | | | | | | | | | * Add external directory * Move Javascript and JIT * Remove application section * Consolidate and move pygraphviz examples * Clean up imports * Reorder * Fix subclass examples
* Use str dunder (#4412)Jarrod Millman2020-12-033-5/+3
|
* Add words graph plot (#4409)Jarrod Millman2020-12-021-2/+20
|
* Don't import nx from networkx (#4403)Jarrod Millman2020-12-013-3/+3
|
* Add seeds to gallery examples for reproducibility (#4276)Ross Barnowski2020-10-243-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Seed layout basic/plot_properties. * Seed simple path example * Switch node cmap example to deterministic layout * Seed layout in edge_colormap example * Seed graph gen and layout in ego_graph example * Seed random_geometric_graph example. * Seed layout and pad axes w/ tight_layout. * Seed and modify colors for directed example. * Seeded graph gen and layout * Switch to plasma colormap for better contrast on light bgnd * Seed layout and tight_layout sampson example * Seed and pad axes for unix email example * Seed graph gen and layout for erdos_renyi example * Seed graph gen and layout of degree_seq example * Seed layout of football example * Seed layout for krackhardt centrality example * Seed davis club example * Seed and use np alias in blockmodel example * Seed beam search example. * Seed random graph in eigenval example * Seed heavy metal layout and pad axes * Use deterministic layout for rgraph example * Seed layout for printgraph example. * Add seed to antigraph example. * Use single rng seed value. For examples with multiple uses of rng's (e.g. one for generating a random graph, and another for layout) use a single integer value as the seed for both. * Remove unnecessary submodule paths from examples.
* Format w/ black==20.8b1Jarrod Millman2020-10-061-1/+1
|
* Format w/ blackJarrod Millman2020-07-101-1/+1
|
* Handle kwds explicitly in draw_networkx (#4033)Jeremias Traub2020-07-052-2/+1
| | | | | | | * Handle kwds explicitly in draw_networkx; fix kwds in examples * fix PEP8 issues Fixes #4020
* Upgrade to Py36 syntaxJarrod Millman2020-01-012-2/+2
| | | | $ find examples -name \*.py -exec pyupgrade --py36-plus {} \;
* Add links to data filesJarrod Millman2019-11-163-38/+29
|
* Update examplesJarrod Millman2019-11-119-171/+86
|
* PEP8 fixes to testsJarrod Millman2019-10-181-0/+1
|
* Fix sphinx errors And add links to single_source_dijkstra in docs for ↵Dan Schult2019-10-071-0/+0
| | | | | | | | | | dijkstra_path/length (#3638) * Add links to single_source_dijkstra in docs for dijkstra_path/length Fixes #3618 * Fix errors in sphinx build
* Remove future imports needed by Py2Jarrod Millman2019-09-181-2/+0
|
* Fix exampleJarrod Millman2019-04-041-4/+2
|
* Ensure sphinx-gallery tries running all the examplesJarrod Millman2019-04-043-0/+0
| | | | It only runs scripts starting w/ plot_ by default.
* Update copyrightJarrod Millman2019-03-308-8/+8
|
* Fix examplesJarrod Millman2018-11-141-7/+3
|
* Update copyrightJarrod Millman2018-01-208-8/+8
|
* Improve plots (#2579)Jarrod Millman2017-08-042-2/+16
| | | Improve plots
* Remove is_valid_degree_sequence deprecated in 2013Jarrod Millman2017-07-251-1/+1
| | | | See b93017c17.
* Update copyrightJarrod Millman2017-07-251-1/+1
|
* Refactor examples (#2527)Jarrod Millman2017-07-219-61/+75
| | | | | | | | | | | | * Fix unix_email and plot more examples * Fix doctest * Fix more examples * Fix AntiGraph.degree generator error in examples * Style/consistency changes and plot more examples
* Flatten doc hierarchy (#2520)Jarrod Millman2017-07-172-11/+11
| | | | | | | | * Silence some sphinx warnings * Update structure of documentation See https://github.com/networkx/networkx/pull/2054
* Fix sphinx (#2517)Jarrod Millman2017-07-1710-110/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Ensure valid rst file * Edit text * Update README and package docstring * Add myself as a contributor * Update gitwash * Fix warnings/errors except citations/footnotes * Remove old note about 3.0 incompatibility * Remove stale ref to gh-pages * Create top-level tools directory (standard practice) * Use sphinx-gallery extension for examples * Sphinx-gallery generates images for `plot_` examples * Comply with pep8 * Don't save figures
* Remove duplicate files, fixes #2046 (#2487)Jarrod Millman2017-06-265-370/+0
|
* PyDot support reverted from "pydotplus" to "pydot"leycec2016-10-061-2/+2
| | | | | | | Support for the long-obsolete "pydotplus" fork has been reverted back to the well-maintained parent "pydot" project, fixing #2235. All "nx_pydot" functions now explicitly require pydot >= 1.2.3, which broke backwards API compatibility and resolved long-standing Python 2.x issues. Sanity is restored.
* Change calls to add_edge method to pass values as keywords rather than a dictthegreathippo2016-04-261-1/+1
| | | | | | I missed a few of these in my last pass, largely because they didn't invoke attr_dict directly -- but rather, passed a dictionary object (enclosed in {}).
* Adjusts imports in drawing with graphviz for v2.0Dan Schult2016-01-1111-47/+52
| | | | | Also adjusts examples and docs Cherry-pick from #1930
* Examples and doc changesDan Schult2016-01-112-39/+41
|
* Update copyrightsMridul Seth2016-01-013-3/+3
|
* Update examples for iterator edges and nodes methodsDan Schult2015-10-041-1/+1
| | | | | This will help with readthedocs make_gallery #1667 These are solely due to the switch to our 2.0 API
* Update examples directoryMridul Seth2015-07-012-2/+2
|
* Fix copyrightsJGab2015-04-213-3/+3
|
* Remove references to pyparsingysitu2014-10-121-5/+0
|
* Remove Python 3 incompatible print statementMichael Sproul2014-06-281-3/+1
|
* Explicitly import graph atlasAric Hagberg2014-03-281-3/+2
|