summaryrefslogtreecommitdiff
path: root/networkx/relabel.py
Commit message (Collapse)AuthorAgeFilesLines
* Allow relabel_nodes mapping to have non-node keys that get ignored (#4466)Dan Schult2020-12-191-4/+4
| | | | Any keys in mapping that are not nodes in the graph are now ignored instead of raising a KeyError
* Improve relabel coverage, tweak docstrings (#4299)Stefan van der Walt2020-10-291-1/+1
| | | | | * Add test for unfeasible relabeling * Slightly clarify docstrings
* Format python in docstrings (#4168)Jarrod Millman2020-08-191-5/+5
| | | | | | | | | | | | | | | | | | | * 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>
* relabel_nodes now preserves edges in multigraphs (#4066)Nikos Chan2020-08-141-3/+55
| | | | | | | | | | | * relabel_nodes now preserves edges in multigraphs * fix pep8 and doctest * Add tests that show trouble with inplace edge overwriting * fix errors shown by tests for inplace overwriting Co-authored-by: Dan Schult <dschult@colgate.edu>
* Fix exception causes and messages all over the codebase (#4015)Ram Rachum2020-07-051-4/+4
|
* Fix scipy deprecation warningsJarrod Millman2020-01-031-22/+33
|
* Convert %-format to fstringJarrod Millman2020-01-011-2/+2
|
* Remove boiler plate from top of modulesJarrod Millman2019-11-111-6/+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.
* Update copyrightJarrod Millman2019-03-301-1/+1
|
* Replacing `Return` to `Returns` in docs for functions (#3301)Moradnejad2019-02-181-1/+1
| | | | | | * Fixed problem in documentation view of this function * Replacing `Return` to `Returns` in function docs
* Simplify the Graphview and SubGraphView system (#3073)Dan Schult2018-07-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Simplify the Graphview and SubGraphView system - add tests to show that extensions of base graph classes (only add new functions) should be able to use the Graph.subgraph and Graph.copy methods easily - Remove ReadOnlyGraph class in favor of existing freeze() function - Switch all GraphView classes to generic_graph_view function - Switch all SubGraph classes to subgraph_view function - Introduce deprecated functions that act like the deprecated classes. Still need to: - add docs - add tests - make sure backward compatible and marked as deprecated - remove GraphView and SubGraph construct from rest of codebase - update release docs Fixes #2889 Fixes #2793 Fixes #2796 Fixes #2741 * Ease subclassing for to_(un)directed - add to_directed_class indicator functions to base classes - start deprecating G.fresh_copy - update function.to(un)directed * Remove G.fresh_copy from code replace with __class__ Add deprecation warnings for GraphView classes, ReverseView and SubGraph. Also for fresh_copy function.
* Added clarifying comment about relabelling nodes in situations where … (#2857)Lewis Robbins2018-02-031-0/+4
| | | | | | * Added clarifying comment about relabelling nodes in situations where the order of nodes is important * wrap docstring
* Pep8 fixesJarrod Millman2018-01-201-1/+1
|
* Update copyrightJarrod Millman2018-01-201-1/+1
|
* Remove automatic processing of G.name attribute (#2829)Dan Schult2018-01-141-4/+0
| | | | | | It's too hard to keep G.name consistently updated throughout the codebase. Let users do it. This stops from deprecating G.name altogether, but it is a first step toward that if we decide to go that route.
* Dictionary comprehensions from #1700 merged conflicts (#2768)Dan Schult2017-11-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * use dict comprehensions in kcomponents.py * use dict comprehensions in test_kcomponents * use dict comprehensions in test_kcutsets * use dict comprehensions in test_maxflow * use dict comprehensions in test_maxflow_large_graph * use dict comprehensions in flow/utils.py * use dict comprehensions in weighted.py * use dict comprehensions in graphml.py * use dict comprehensions in nx_pylab.py * use dict comprehensions in relabel.py * use dict comprehensions in assortavity/mixing.py * conform to pep8 guidelines in mixing.py * Minor tweaks to kcomponents to update to v2.0
* Replace __class__ with fresh_copy in G.reverse and elsewhere (#2649)Dan Schult2017-09-071-4/+3
| | | | | Fixes #2648 Noticed hidden errors with G.name in operators.py
* Comply with pep8Jarrod Millman2017-08-171-37/+35
|
* Simplify base classes. (#2604)Dan Schult2017-08-121-3/+3
| | | | | | | | | | * 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.
* Next attempt to meld graphviews with base classes (#2593)Dan Schult2017-08-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | * 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.
* Refactor set_node_attributes() and set_edge_attributes() (#2553)Michael E. Rose2017-07-261-2/+2
| | | | | | | | | | | | | * 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
* Ensure _relabel_copy() respects node order of OrderedGraphs (#2488)Jarrod Millman2017-06-281-28/+30
| | | | | | * Ensure _relabel_copy() respects node order of OrderedGraphs, fixes #2482 * Comply with pep8
* Update relabel_nodes docsDan Schult2017-06-261-3/+8
| | | Fixes #2477
* Move data structure to private names and replace with readonly structures ↵Dan Schult2017-06-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#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
* Handle graph name attribute in relabel_nodesDan Schult2016-05-181-1/+2
| | | | | Fixes #2134 simplifies read_gml handling of "name" as well.
* Modified all add_node, add_edge, and add_edges_from methods.thegreathippo2016-04-261-1/+1
| | | | | | | | I also went through and modified all attr_dict references to either directly assign keywords to node/edge attributes, or use the ** syntax to unpack the dictionaries. The only case of these I couldn't do is networkx.convert.py -- largely because I don't understand how multigraph edges work.
* Clarifies some examples for relabel_nodes().Jeffrey Finkelstein2016-03-221-26/+43
|
* topolgical_sort, lexicographical_topological_sortNeil2015-08-311-1/+1
| | | | | | | | | | | | | | Rewrote topolgical_sort as a generator: * It no longer accepts reverse or nbunch arguments * It is slightly faster. Added lexicographical_topological_sort, which accepts a key. Some tests for topological sort were removed because they relied on CPython's particular dict element ordering. Added utils from more_itertools: * These were necessary for working with the new generators. * "pairwise" is equavalent to zip(some_list, some_list[1:]) -- for generators. * "consume" consumes an iterator.
* Remove degree_iter(),now degree() returns an integer for single node and ↵Mridul Seth2015-06-271-2/+2
| | | | iterator for else
* Remove edges_iter, G.edges() now returns an iterator instead of listMridul Seth2015-06-171-2/+2
|
* Makes Graph.nodes() return iterator instead of listJeffrey Finkelstein2015-06-111-13/+9
| | | | | | | 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.
* Fixes issue #1539 Bug in relabel_nodes for isolated nodesDan Schult2015-05-221-0/+2
|
* bugfix: use ternary operator to replace node with self-loop in-placeIoannis Filippidis2014-10-311-4/+4
| | | because otherwise `old == target and new` with old equal to target will evaluate to new. If new is 0 (a valid integer node), then the conjunction evaluates to False, masking that old is equal to target. The ternary operator implements the selection and avoids this issue.
* MAINT: use reverse=True for some topological_sort callsalex2014-02-181-2/+1
|
* PEP-8 cleanupAric Hagberg2013-08-251-36/+36
|
* Document that node relabling uses consecutive integersAric Hagberg2013-08-251-3/+4
|
* Simplify notes and formatting of code/docsAric Hagberg2013-01-211-36/+31
|
* whitespace cleanupAric Hagberg2013-01-201-25/+25
|
* Set relabel mapping as node attributes.Aric Hagberg2013-01-201-13/+9
| | | | | Use node attribute (specified as "label_attribute") in convert_node_labels_to_integers() instead of adding a mapping dict attribute to the Graph object. Addresses #820
* Fix/adjust/remove/modify tests that depend on dictionary ordering.Aric Hagberg2012-07-081-3/+4
| | | | | | | | | | Addresses #741 There may still be more that need fixing since 1) NumPy and some other optional packages do not yet work with Python3.3 so those tests weren't checked 2) Finding these errors by running the tests is nondeterministic itself (e.g. passes 4 times and fails on the 5th). And inspecting all of the tests by hand is error-prone too.
* Add check for self-loop to fix relabel-in-place fail.Aric Hagberg2012-01-101-6/+8
| | | | Fixes #674
* Fix doc for relabel functions.Aric Hagberg2011-03-271-1/+0
|
* Fix for relabel toposort to work with Python3.Aric Hagberg2011-03-261-1/+2
| | | | Addresses #525
* Add more tests for relabel.Aric Hagberg2011-03-241-14/+8
| | | | Fixes #525
* Add copy=True|False to relabel nodes in place.Aric Hagberg2011-03-221-0/+217
Addreses #525 --HG-- rename : networkx/tests/test_convert.py => networkx/tests/test_relabel.py