summaryrefslogtreecommitdiff
path: root/examples
Commit message (Collapse)AuthorAgeFilesLines
* Add Greedy Coloring Example to Gallery (#6647)Vanshika Mishra2023-05-021-0/+35
| | | | | | | | | | | | | | | * plot_greedy_coloring_Example * suggestions incorporated * fix error * fixed error * Minor formatting tweaks. --------- Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Add Lowest Common Ancestor example to Gallery (#6542)Navya Agarwal2023-04-101-0/+48
|
* Fix typos (#6620)Harri Nieminen2023-04-041-1/+1
|
* Add community detection example to Gallery (#6526)Navya Agarwal2023-03-281-0/+79
| | | | | | | * Add community-detection example * Fix plot layout * Create subplot layout
* 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>
* Update pre-commit (#6545)Jarrod Millman2023-03-233-3/+3
|
* Lint using Ruff (#6371)danieleades2023-02-195-17/+17
| | | | | | | | | | | | | | | * 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-146-7/+8
| | | | | * Update developer requirements * Run linter
* Gallery example for Maximum Independent Set (#5563)stanyas2023-02-131-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Update mayavi2_spring.py trial commit * Example map for GSoC * Changing errors in the example graph file * Rename example_map.py to example_map_2.py * style change to map code * Trial-map * Undo mayavi example change. * Mv example to gallery and use spx-gallery naming scheme. * Add docstring to MIS gallery example. * Simplify example. * Make node coloring more clear. --------- Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* DOC: Minor formatting fixups to get rid of doc build warnings. (#6363)Ross Barnowski2023-01-131-2/+2
| | | Minor formatting fixups to get rid of doc build warnings.
* Fix typos in the networkx codebase (#6335)Anurag Bhat2023-01-054-6/+8
| | | | | * Fix_Typos * Commit_Suggestions
* Fix typo in readme file (#6312)Tina Oberoi2023-01-051-1/+1
| | | Co-authored-by: Tina <tina@Tinas-MacBook-Air.local>
* Reenable geospatial examples (#6252)Jarrod Millman2022-12-014-0/+0
|
* Circular center node layout (#6114)Douglas K. G. Araujo2022-10-261-0/+20
| | | | | | | | | | | | | | | | | | | | | * center_node positioned according to param center * code formatting * Reverted to files in main * Adds example of custom node position * fixes spaces in layout.py * Update examples/drawing/plot_center_node.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * clearer comment on custom node position Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Replace .A call with .toarray for sparse array in example. (#6106)Ross Barnowski2022-10-191-1/+1
|
* Fix failing example due to mpl 3.6 colorbar. (#5994)Ross Barnowski2022-09-211-1/+1
|
* See matplotlb 3.6rc1 failure (#5937)Jarrod Millman2022-08-211-1/+1
| | | | | | | | | | | * See matplotlb 3.6rc1 failure * replace use of private class method to allow mpl v3.6 to work. * ensure ax exists before calling colorbar * Undo matplotlib pin Co-authored-by: Dan Schult <dschult@colgate.edu>
* Update precommit hooks (#5923)Jarrod Millman2022-08-091-1/+1
|
* 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.
* Clean up from PR #5779 (#5841)Jarrod Millman2022-07-054-0/+0
|
* 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 deprecated function nx.info (#5759)Mridul Seth2022-06-211-1/+1
| | | | | | | | | | * 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>
* Remove redundant py2 numeric conversions (#5661)Mridul Seth2022-05-313-3/+3
| | | | | | | | | * Remove redundant float conversion * Remove redundant int conversion * Use integer division Co-authored-by: Miroslav Šedivý <6774676+eumiro@users.noreply.github.com>
* added edge labels in weighted graph (#5521)Nikita Sharma2022-04-121-1/+4
| | | | | | | | | | | | | | | | | | | | | * examples * examples * examples * Example changed * improved styling * revised * edge labels * improved styling * spacing * error testing
* 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>
* More numpy.matrix cleanups for NX2.7 (#5319)Ross Barnowski2022-02-121-1/+1
| | | | | | | | | | | | | | | | | | | * Fix return type in docstring of internal function. * Rm explicit mention of numpy matrix from class docstrings. * Fix return type of floyd_warshall_numpy docstring. * Remove mention of numpy matrix from code comment. * Fix simrank similarity internal docstring. * Rm explicit mention of matrix in favor of 2D array. * Update to_networkx_graph array exception wording. * Remove extraneous mention of numpy matrix. * Don't print array in exception message.
* Touchups and suggestions for subgraph gallery example (#5225)Ross Barnowski2021-12-171-109/+21
| | | | | | | | | | | | | | | * Simplify construction of G with edges rm'd * Rm unused graph attribute. * Shorten categorization by node type. * Simplify node coloring. * Simplify isomorphism check. * Rm unit test. * Rm redundant plotting of each subgraph.
* Add traveling salesman problem to example gallery (#4874)eskountis2021-12-121-0/+52
| | | | | Adds an example of the using Christofides to solve the TSP problem to the example galery. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* [MRG] Create plot_subgraphs.py example (#5165)Andrew Knyazev2021-12-121-0/+258
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Create plot_subgraphs.py https://github.com/networkx/networkx/issues/4220 * Update plot_subgraphs.py black * Update plot_subgraphs.py lint plus font_size * Update plot_subgraphs.py added more plots * Update plot_subgraphs.py removed plots from the unit test and added comments * Update plot_subgraphs.py lint * Update plot_subgraphs.py typos fixed * Update plot_subgraphs.py added nodes to the plot of the edges removed that was commented out for whatever reason * Update plot_subgraphs.py revert the latest commit - the line was commented out for a reason - it's broken * Update plot_subgraphs.py fixed node color issue * Update plot_subgraphs.py format fix * Update plot_subgraphs.py forgot to draw the nodes... now fixed * Fix sphinx warnings about heading length. * Update examples/algorithms/plot_subgraphs.py * Update examples/algorithms/plot_subgraphs.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Dan Schult <dschult@colgate.edu>
* 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.
* Style changes (#5022)Dan Schult2021-08-143-18/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Changes to rst files to make doctests pass (#4947)Dan Schult2021-07-071-2/+2
| | | | | | | | | | | | | | | | | | | * rst double colons for example code * add nx. prefix to doctest function calls * Remove one line from 1->2 migration rst file the line shows code that works for 1.x *and* 2.x. But it no longer works for all v2.x code. Readers should just use the next line of code, so no reason to keep this in the file. * capture output from subplot and rename DiGraph as DG in introduction.rst * skip running the entire test suite as an example in old_release_log.rst * doctest of examples * remove changes to nexp files
* Fixes #4275 - Add comment to parallel betweenness example (#4926)Alex Korbonits2021-06-281-1/+5
| | | | | | | * Add comment about single core CI/CD showing slower parallel output in example script. * less specific estimate of speedup Co-authored-by: Dan Schult <dschult@colgate.edu>
* Doc/fix 403 error drawing custom icons (#4906)Ross Barnowski2021-06-164-12/+23
| | | | | | | | | | | | * Add local copies of custom node icon pngs. * Update example to use local images. * Force FancyArrowPatch to respect tgt distances. min/max_target_distance kwargs are only supported by FancyArrowPatch. Force drawing with FAPs and add comment explaining how/why. * Add seed to layout for reproducibility.
* DOC: Fix links, use DOI links, wayback machine where required (#4868)Mridul Seth2021-06-083-4/+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>
* adds implementation of SNAP summarization algorithm (#4463)Douglas Fenstermacher2021-05-171-0/+108
| | | | | | | | | | | * adds implementation of SNAP summarization algorithm Thanks to dschult and rossbar for many much-needed recommendations for refining and optimizing the implementation * Seed layouts for snap gallery examples. Make sure the layouts are reproducible. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* fix urllib import (#4793)Xiangyu Xu2021-05-142-3/+3
| | | | | * fix urllib import * update urllib import
* make plots less dense, enable plotting for igraph (#4791)Mridul Seth2021-05-141-11/+18
| | | Make igraph plotting example render in gallery
* Remove mayavi and cartopy dependencies (#4800)Jarrod Millman2021-05-131-0/+0
|
* imread(url) is deprecated, use pillow + urllib to load image from URL (#4790)Mridul Seth2021-05-111-2/+5
|
* Gallery Example: Drawing custom node icons on network using MPL (#4633)Alex Walker2021-05-111-0/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Added images to the generate graph * Cleaned up comments * Added comment for node addition * Ross's suggestion Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Ross's suggestion Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Ross's suggestion Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Ross's suggestion Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * revised code * added comment * Update examples/drawing/plot_mpl_annotations.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update examples/drawing/plot_mpl_annotations.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Rename plot_mpl_annotations.py to plot_custom_node_icons.py Co-authored-by: Alex <a.c.walker@student.tudelft.nl> Co-authored-by: Sharwin Bobde <31354242+sharwinbobde@users.noreply.github.com> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Sharwin Bobde <bsharwin@gmail.com>
* Make main default branch (and remove gitwash) (#4649)Jarrod Millman2021-03-047-7/+7
|
* Correct and update Atlas example (#4635)Dan Schult2021-02-261-32/+17
| | | | | | | | | | | | * Correct and update Atlas example An email from Philip Boalch points out that the previous code didn't include graph number 208 and used a `could_be_isomorphic` fast routine which returned incorrect results. The correct number of connected graphs with 6 or fewer nodes is 142. * adjust docstring to explain how 142 and cited sequence relate
* Remove unnecessary node_list from gallery example (#4505)Jarrod Millman2021-01-141-1/+1
|
* Gallery support for pygraphviz examples (#4464)Ross Barnowski2021-01-0414-95/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add pygraphviz image scraper to doc config. * pgz gallery example - switch to agraph.draw * Move pygraphviz examples out to demo img scraper. * TEMP: point to pgz with scraper for CI. * Add support for comments in requirements files. * TEMP: remove extra deps from setup.py. Just to get CI running with un-deployed pygraphviz. * Two graphviz categories: layout and drawing. * Update deps to pgv1.7rc1. * Revert removal of key from 2fb3101 * Add pygraphviz to intersphinx mapping. Update intersphinx links and internal links to drawing modules. * Add links for drawing functionality. pygraphviz via intersphinx + write_dot.
* Update geospatial readme (#4504)Jarrod Millman2020-12-311-10/+207
|
* JavaScript example: fix link (#4450)Sebastiaan Lokhorst2020-12-121-1/+1
|