Technical Documentation: networkx/networkx
ℹ️ Provenance: Multi-Tier Ingestion · CodeWiki Reference
Overview (`benchmarks/README.md`)
NetworkX ASV Benchmarks
NetworkX uses asv to monitor for
performance regressions and evaluate proposals for improved performance.
Available benchmarks are available in the benchmarks/benchmarks subdirectory
and are loosely organized/named to reflect either the algorithms or data structures
that they focus on.
The two most generic sets of benchmarks are:
benchmarks_classes.py: This covers benchmarks for performance of core
NetworkX classes (Graph,DiGraph,MultiGraph,MultiDiGraph).
We test performance of basic graph operations (add_node,add_edge,subgraph
and others). Code that touches the core classes should run these benchmarks
to make sure if there is a performance hit or gain.benchmark_algorithms.py: This runs a tiny subset of algorithms which cover
different parts of our codebase. We use graphs with different density, and a
real world dataset from SNAP datasets to run the algorithms.
There are many other algorithms captured in other files/benchmarking classes
within the suite.
Setup and configuration
Benchmarking runs are controlled by the asv.conf.json configuration file.
For a full listing of configuration options, see
the asv documentation
Typically, the most important configuration options for a successful ASV
configuration are:
environment_typewhich controls the environment management tool used
by ASV,pythons, specifying which version(s) of Python will be used during
benchmarking, andmatrixwhich dictates what dependencies (and their versions) will be
tested against.
When using `environment_type: "virtualenv"`, it is recommended to limit the
`pythons` field to only those versions of Python that are installed on the
system.By default, asv.conf.json uses the "rattler" environment type with"pythons": ["3.12", "3.13", "3.14"]. asv provisions each interpreter (and the
soft dependencies) from conda-forge usingpy-rattler — the same solver pixi is built
on — so all three versions are benchmarked from a single environment, with no
conda binary required.
The matrix field dictates which optional dependencies will be installed in the
benchmarking environment.
To get an accurate picture of NetworkX performance with "default" soft dependencies
installed, be sure to include numpy and scipy in this listing.
To evaluate pure-Python code branches, remove the dependencies from matrix.
Some benchmarks themselves depend on `numpy`, `scipy` and/or `pandas`; so removing
dependencies may cause some benchmarks to be skipped.The benchmark configuration lives in asv.conf.json (rattler backend, Python
3.12/3.13/3.14, with the default soft dependencies numpy/scipy/pandas
installed into each environment).
To switch to built-in environment management:
"environment_type": "virtualenv"To limit the benchmarking run to a single version of Python:
"pythons": ["3.13"]Running with pixi
pyproject.toml defines a single benchmark environment (the rattler harness;
asv provisions 3.12/3.13/3.14 itself):
# Python 3.12/3.13/3.14 with the default soft deps (one command, three versions)
pixi run -e benchmark benchmark-runIn CI, .github/workflows/benchmark.yml runs this on pull requests labeledrun:benchmark.
Running the benchmark suite
The commands below call asv directly; run them inside the benchmarking
environment (e.g. pixi run -e benchmark asv ...) or use the pixi tasks shown
above (benchmark-run, benchmark-continuous).
To run the benchmark on the current HEAD commit:
asv runRun the benchmark to compare two commits:
asv continuous base_commit_hash test_commit_hashThe --bench flag can be used to limit a run to a subset of benchmarks.
For example, the following will only run the algorithm benchmarks for performance
comparison between two commits:
asv continuous --bench AlgorithmBenchmarks <sha1> <sha2>The same pattern can be used to specify individual benchmarks:
asv continuous --bench AlgorithmBenchmarks.time_pagerank <sha1> <sha2>To know more visit - https://asv.readthedocs.io/en/stable/commands.html
Overview (`requirements/README.md`)
pip requirements files
Index
These files are generated by tools/generate_requirements.py from pyproject.toml.
benchmarking.txt
Requirements for benchmarkingdefault.txt
Default requirementsextra.txt
Optional requirements that may require extra steps to installexample.txt
Requirements for gallery examplestest.txt
Requirements for running test suitetest-extras.txt
Additional pytest plugins for advanced testing featuresdoc.txt
Requirements for building the documentation (see../doc/)developer.txt
Requirements for developersrelease.txt
Requirements for making releases
Examples
Installing requirements
$ pip install -U -r requirements/default.txtRunning the tests
$ pip install -U -r requirements/default.txt
$ pip install -U -r requirements/test.txtOverview (`doc/_static/README.md`)
wget https://raw.githubusercontent.com/networkx/branding/main/logo/networkx_favicon.svg
inkscape -w 16 -h 16 -o 16.png networkx_favicon.svg
inkscape -w 32 -h 32 -o 32.png networkx_favicon.svg
inkscape -w 48 -h 48 -o 48.png networkx_favicon.svg
convert 16.png 32.png 48.png favicon.ico
Doc README (`doc/README.rst`)
We use Sphinx for generating the API and reference documentation.
Pre-built versions can be found at
https://networkx.org/for both the stable and the latest (i.e., development) releases.
Instructions
After installing NetworkX and its dependencies, install the Python
packages needed to build the documentation by entering the root
directory and executing::
pip install -r requirements/doc.txt
Building the example gallery additionally requires the dependencies
listed in ``requirements/extra.txt`` and ``requirements/example.txt``::
pip install -r requirements/extra.txt
pip install -r requirements/example.txt
To build the HTML documentation, enter ``doc/`` and execute::
make html
This will generate a ``build/html`` subdirectory containing the built
documentation. If the dependencies in ``extra.txt`` and ``example.txt``
are **not** installed, build the HTML documentation without generating
figures by using::
make html-noplot
To build the PDF documentation, enter::
make latexpdf
You will need to have LaTeX installed for this.
.. note:: ``sphinx`` supports many other output formats. Type ``make`` without
any arguments to see all the built-in options.
---
### Doc Backends (`doc/backends.md`)
---
jupytext:
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.13.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
name: python3
---
# Backends
```{currentmodule} networkx
```
The following backends are known to work with the current stable release of
NetworkX.
Backends need not be listed here in order to work, and there may be many
backends that NetworkX developers don't know about. You should be able to
install the backend, enable the backend using the `backend=...` keyword arg,
the `NETWORKX_BACKEND_PRIORITY` environment variable, or the config setting
`nx.config.backend_priority="..."` as described in the
[Tutorial](#using-networkx-backends).
See the documentation for a particular backend for a description of
the NetworkX functions it provides, how to install it, and any special
backend-specific configurations it supports.
```{list-table}
:header-rows: 1
* - Name
- Description
* - [nx-parallel](https://github.com/networkx/nx-parallel)
- Parallelized implementations of various NetworkX functions using joblib
* - [nx-cugraph](https://rapids.ai/nx-cugraph)
- GPU acceleration using RAPIDS cuGraph and NVIDIA GPUs
* - [nx-arangodb](https://github.com/arangodb/nx-arangodb)
- Seamlessly adds ArangoDB as a persistence layer to NetworkX graphs
* - [nx-neptune](https://github.com/awslabs/nx-neptune)
- Seamlessly offload computation workloads to AWS Neptune Analytics service
```
---
### Doc Index (`doc/index.rst`)
.. _contents:
Software for Complex Networks
=============================
.. only:: html
:Release: |version|
:Date: |today|
NetworkX is a Python package for the creation, manipulation, and study
of the structure, dynamics, and functions of complex networks.
It provides:
- tools for the study of the structure and
dynamics of social, biological, and infrastructure networks;
- a standard programming interface and graph implementation that is suitable
for many applications;
- a rapid development environment for collaborative, multidisciplinary
projects;
- support for algorithm acceleration and additional features through
third-party backends;
- an interface to existing numerical algorithms and code written in C,
C++, and FORTRAN; and
- the ability to painlessly work with large nonstandard data sets.
With NetworkX you can load and store networks in standard and nonstandard data
formats, generate many types of random and classic networks, analyze network
structure, build network models, design new network algorithms, draw networks,
and much more.
Citing
------
To cite NetworkX please use the following publication:
Aric A. Hagberg, Daniel A. Schult and Pieter J. Swart,
`"Exploring network structure, dynamics, and function using NetworkX"
<http://conference.scipy.org.s3-website-us-east-1.amazonaws.com/proceedings/scipy2008/paper_2/>`_,
in
`Proceedings of the 7th Python in Science Conference (SciPy2008)
<http://conference.scipy.org.s3-website-us-east-1.amazonaws.com/proceedings/scipy2008/index.html>`_,
Gäel Varoquaux, Travis Vaught, and Jarrod Millman (Eds),
(Pasadena, CA USA), pp. 11--15, Aug 2008
.. only:: html
`PDF <http://conference.scipy.org.s3-website-us-east-1.amazonaws.com/proceedings/scipy2008/paper_2/full_text.pdf>`_
`BibTeX <http://conference.scipy.org.s3-website-us-east-1.amazonaws.com/proceedings/scipy2008/paper_2/reference.bib>`_
Audience
--------
The audience for NetworkX includes mathematicians, physicists, biologists,
computer scientists, and social scientists. Good reviews of the science of
complex networks are presented in Albert and Barabási [BA02]_, Newman
[Newman03]_, and Dorogovtsev and Mendes [DM03]_. See also the classic texts
[Bollobas01]_, [Diestel97]_ and [West01]_ for graph theoretic results and
terminology. For basic graph algorithms, we recommend the texts of Sedgewick
(e.g., [Sedgewick01]_ and [Sedgewick02]_) and the survey of Brandes and
Erlebach [BE05]_.
Python
------
Python is a powerful programming language that allows simple and flexible
representations of networks as well as clear and concise expressions of network
algorithms. Python has a vibrant and growing ecosystem of packages that
NetworkX uses to provide more features such as numerical linear algebra and
drawing. In order to make the most out of NetworkX you will want to know how
to write basic programs in Python. Among the many guides to Python, we
recommend the `Python documentation <https://docs.python.org/3/>`_ and the text
by Alex Martelli [Martelli03]_.
License
-------
.. include:: ../LICENSE.txt
Bibliography
------------
.. [BA02] R. Albert and A.-L. Barabási, "Statistical mechanics of complex
networks", Reviews of Modern Physics, 74, pp. 47-97, 2002.
https://arxiv.org/abs/cond-mat/0106096
.. [Bollobas01] B. Bollobás, "Random Graphs", Second Edition,
Cambridge University Press, 2001.
.. [BE05] U. Brandes and T. Erlebach, "Network Analysis:
Methodological Foundations", Lecture Notes in Computer Science,
Volume 3418, Springer-Verlag, 2005.
.. [Diestel97] R. Diestel, "Graph Theory", Springer-Verlag, 1997.
http://diestel-graph-theory.com/index.html
.. [DM03] S.N. Dorogovtsev and J.F.F. Mendes, "Evolution of Networks",
Oxford University Press, 2003.
.. [Martelli03] A. Martelli, "Python in a Nutshell", O'Reilly Media
Inc, 2003.
.. [Newman03] M.E.J. Newman, "The Structure and Function of Complex
Networks", SIAM Review, 45, pp. 167-256, 2003.
http://epubs.siam.org/doi/abs/10.1137/S003614450342480
.. [Sedgewick02] R. Sedgewick, "Algorithms in C: Parts 1-4:
Fundamentals, Data Structure, Sorting, Searching", Addison Wesley
Professional, 3rd ed., 2002.
.. [Sedgewick01] R. Sedgewick, "Algorithms in C, Part 5: Graph Algorithms",
Addison Wesley Professional, 3rd ed., 2001.
.. [West01] D. B. West, "Introduction to Graph Theory", Prentice Hall,
2nd ed., 2001.
.. toctree::
:maxdepth: 1
:hidden:
install
tutorial
backends
reference/index
auto_examples/index
developer/index
release/index
---
### Doc Tutorial (`doc/tutorial.md`)
---
jupytext:
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.13.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
name: python3
---
# Tutorial
```{currentmodule} networkx
```
This guide can help you start working with NetworkX.
## Creating a graph
Create an empty graph with no nodes and no edges.
```{code-cell}
import networkx as nx
G = nx.Graph()
```
By definition, a {class}`Graph` is a collection of nodes (vertices) along with
identified pairs of nodes (called edges, links, etc). In NetworkX, nodes can
be any {py:term}`hashable` object e.g., a text string, an image, an XML object,
another Graph, a customized node object, etc.
```{note}
Python's `None` object is not allowed to be used as a node. It
determines whether optional function arguments have been assigned in many
functions.
```
## Nodes
The graph `G` can be grown in several ways. NetworkX includes many
{doc}`graph generator functions <reference/generators>` and
{doc}`facilities to read and write graphs in many formats <reference/readwrite/index>`.
To get started though we'll look at simple manipulations. You can add one node
at a time,
```{code-cell}
G.add_node(1)
```
or add nodes from any {py:term}`iterable` container, such as a list
```{code-cell}
G.add_nodes_from([2, 3])
```
You can also add nodes along with node
attributes if your container yields 2-tuples of the form
`(node, node_attribute_dict)`:
```{code-cell}
G.add_nodes_from([(4, {"color": "red"}), (5, {"color": "green"})])
```
Node attributes are discussed further {ref}`below <attributes>`.
Nodes from one graph can be incorporated into another:
```{code-cell}
H = nx.path_graph(10)
G.add_nodes_from(H)
```
`G` now contains the nodes of `H` as nodes of `G`.
In contrast, you could use the graph `H` as a node in `G`.
```{code-cell}
G.add_node(H)
```
The graph `G` now contains `H` as a node. This flexibility is very powerful as
it allows graphs of graphs, graphs of files, graphs of functions and much more.
It is worth thinking about how to structure your application so that the nodes
are useful entities. Of course you can always use a unique identifier in `G`
and have a separate dictionary keyed by identifier to the node information if
you prefer.
```{note}
You should not change the node object if the hash depends on its contents.
```
## Edges
`G` can also be grown by adding one edge at a time,
```{code-cell}
G.add_edge(1, 2)
e = (2, 3)
G.add_edge(*e) # unpack edge tuple*
```
by adding a list of edges,
```{code-cell}
G.add_edges_from([(1, 2), (1, 3)])
```
or by adding any {term}`ebunch` of edges. An _ebunch_ is any iterable
container of edge-tuples. An edge-tuple can be a 2-tuple of nodes or a 3-tuple
with 2 nodes followed by an edge attribute dictionary, e.g.,
`(2, 3, {'weight': 3.1415})`. Edge attributes are discussed further
{ref}`below <attributes>`.
```{code-cell}
G.add_edges_from(H.edges)
```
There are no complaints when adding existing nodes or edges. For example,
after removing all nodes and edges,
```{code-cell}
G.clear()
```
we add new nodes/edges and NetworkX quietly ignores any that are
already present.
```{code-cell}
G.add_edges_from([(1, 2), (1, 3)])
G.add_node(1)
G.add_edge(1, 2)
G.add_node("spam") # adds node "spam"
G.add_nodes_from("spam") # adds 4 nodes: 's', 'p', 'a', 'm'
G.add_edge(3, 'm')
```
At this stage the graph `G` consists of 8 nodes and 3 edges, as can be seen by:
```{code-cell}
G.number_of_nodes()
```
```{code-cell}
G.number_of_edges()
```
```{note}
The order of adjacency reporting (e.g., {meth}`G.adj <networkx.Graph.adj>`,
{meth}`G.successors <networkx.DiGraph.successors>`,
{meth}`G.predecessors <networkx.DiGraph.predecessors>`) is the order of
edge addition. However, the order of G.edges is the order of the adjacencies
which includes both the order of the nodes and each
node's adjacencies. See example below:
```
```{code-cell}
DG = nx.DiGraph()
DG.add_edge(2, 1) # adds the nodes in order 2, 1
DG.add_edge(1, 3)
DG.add_edge(2, 4)
DG.add_edge(1, 2)
assert list(DG.successors(2)) == [1, 4]
assert list(DG.edges) == [(2, 1), (2, 4), (1, 3), (1, 2)]
```
## Examining elements of a graph
We can examine the nodes and edges. Four basic graph properties facilitate
reporting: `G.nodes`, `G.edges`, `G.adj` and `G.degree`. These
are set-like views of the nodes, edges, neighbors (adjacencies), and degrees
of nodes in a graph. They offer a continually updated read-only view into
the graph structure. They are also dict-like in that you can look up node
and edge data attributes via the views and iterate with data attributes
using methods `.items()`, `.data()`.
If you want a specific container type instead of a view, you can specify one.
Here we use lists, though sets, dicts, tuples and other containers may be
better in other contexts.
```{code-cell}
list(G.nodes)
```
```{code-cell}
list(G.edges)
```
```{code-cell}
list(G.adj[1]) # or list(G.neighbors(1))
```
```{code-cell}
G.degree[1] # the number of edges incident to 1
```
One can specify to report the edges and degree from a subset of all nodes
using an {term}`nbunch`. An _nbunch_ is any of: `None` (meaning all nodes),
a node, or an iterable container of nodes that is not itself a node in the
graph.
```{code-cell}
G.edges([2, 'm'])
```
```{code-cell}
G.degree([2, 3])
```
### Access patterns
Both nodes and edges can be accessed either as attributes, e.g. `G.nodes` or
`G.edges`, or as callables e.g. `G.nodes()` or `G.edges()`.
The attribute-like access pattern is most convenient when setting/modifying node or
edge data:
```{code-cell}
G.nodes["spam"]["color"] = "blue"
G.edges[(1, 2)]["weight"] = 10
```
While the callable pattern is useful for inspecting node or edge attributes
(and edge keys for multigraphs):
```{code-cell}
G.edges(data=True)
```
```{code-cell}
G.nodes(data="color")
```
See the [section on attributes](attributes) for details.
## Removing elements from a graph
One can remove nodes and edges from the graph in a similar fashion to adding.
Use methods
{meth}`Graph.remove_node`,
{meth}`Graph.remove_nodes_from`,
{meth}`Graph.remove_edge`
and
{meth}`Graph.remove_edges_from`.
Removing a node also removes its incident edges:
```{code-cell}
G.remove_node(2)
G.remove_nodes_from("spam")
```
```{code-cell}
list(G.nodes)
```
```{code-cell}
list(G.edges)
```
Removing a specific edge only affects that edge:
```{code-cell}
G.remove_edge(1, 3)
```
```{code-cell}
list(G.nodes)
```
```{code-cell}
list(G.edges)
```
## Using the graph constructors
Graph objects do not have to be built up incrementally - data specifying
graph structure can be passed directly to the constructors of the various
graph classes.
When creating a graph structure by instantiating one of the graph
classes you can specify data in several formats.
```{code-cell}
G.add_edge(1, 2)
H = nx.DiGraph(G) # create a DiGraph using the connections from G
list(H.edges())
```
```{code-cell}
edgelist = [(0, 1), (1, 2), (2, 3)]
H = nx.Graph(edgelist) # create a graph from an edge list
list(H.edges())
```
```{code-cell}
adjacency_dict = {0: (1, 2), 1: (0, 2), 2: (0, 1)}
H = nx.Graph(adjacency_dict) # create a Graph dict mapping nodes to nbrs
list(H.edges())
```
## What to use as nodes and edges
You might notice that nodes and edges are not specified as NetworkX
objects. This leaves you free to use meaningful items as nodes and
edges. The most common choices are numbers or strings, but a node can
be any hashable object (except `None`), and an edge can be associated
with any object `x` using `G.add_edge(n1, n2, object=x)`.
As an example, `n1` and `n2` could be protein objects from the RCSB Protein
Data Bank, and `x` could refer to an XML record of publications detailing
experimental observations of their interaction.
We have found this power quite useful, but its abuse
can lead to surprising behavior unless one is familiar with Python.
If in doubt, consider using {func}`~relabel.convert_node_labels_to_integers` to obtain
a more traditional graph with integer labels.
## Accessing edges and neighbors
In addition to the views {attr}`Graph.edges`, and {attr}`Graph.adj`,
access to edges and neighbors is possible using subscript notation.
```{code-cell}
G = nx.Graph([(1, 2, {"color": "yellow"})])
G[1] # same as G.adj[1]
```
```{code-cell}
G[1][2]
```
```{code-cell}
G.edges[1, 2]
```
You can get/set the attributes of an edge using subscript notation
if the edge already exists.
```{code-cell}
G.add_edge(1, 3)
G[1][3]['color'] = "blue"
G.edges[1, 2]['color'] = "red"
G.edges[1, 2]
```
Fast examination of all (node, adjacency) pairs is achieved using
`G.adjacency()`, or `G.adj.items()`.
Note that for undirected graphs, adjacency iteration sees each edge twice.
```{code-cell}
FG = nx.Graph()
FG.add_weighted_edges_from([(1, 2, 0.125), (1, 3, 0.75), (2, 4, 1.2), (3, 4, 0.375)])
for n, nbrs in FG.adj.items():
for nbr, eattr in nbrs.items():
wt = eattr['weight']
if wt < 0.5: print(f"({n}, {nbr}, {wt:.3})")
```
Convenient access to all edges is achieved with the edges property.
```{code-cell}
for (u, v, wt) in FG.edges.data('weight'):
if wt < 0.5:
print(f"({u}, {v}, {wt:.3})")
```
(attributes)=
## Adding attributes to graphs, nodes, and edges
Attributes such as weights, labels, colors, or whatever Python object you like,
can be attached to graphs, nodes, or edges.
Each graph, node, and edge can hold key/value attribute pairs in an associated
attribute dictionary (the keys must be hashable). By default these are empty,
but attributes can be added or changed using `add_edge`, `add_node` or direct
manipulation of the attribute dictionaries named `G.graph`, `G.nodes`, and
`G.edges` for a graph `G`.
### Graph attributes
Assign graph attributes when creating a new graph
```{code-cell}
G = nx.Graph(day="Friday")
G.graph
```
Or you can modify attributes later
```{code-cell}
G.graph['day'] = "Monday"
G.graph
```
### Node attributes
Add node attributes using `add_node()`, `add_nodes_from()`, or `G.nodes`
```{code-cell}
G.add_node(1, time='5pm')
G.add_nodes_from([3], time='2pm')
G.nodes[1]
```
```{code-cell}
G.nodes[1]['room'] = 714
G.nodes.data()
```
Note that adding a node to `G.nodes` does not add it to the graph, use
`G.add_node()` to add new nodes. Similarly for edges.
### Edge Attributes
Add/change edge attributes using `add_edge()`, `add_edges_from()`,
or subscript notation.
```{code-cell}
G.add_edge(1, 2, weight=4.7 )
G.add_edges_from([(3, 4), (4, 5)], color='red')
G.add_edges_from([(1, 2, {'color': 'blue'}), (2, 3, {'weight': 8})])
G[1][2]['weight'] = 4.7
G.edges[3, 4]['weight'] = 4.2
```
The special attribute `weight` should be numeric as it is used by
algorithms requiring weighted edges.
## Directed graphs
The {class}`DiGraph` class provides additional methods and properties specific
to directed edges, e.g.,
{attr}`DiGraph.out_edges`, {attr}`DiGraph.in_degree`,
{meth}`DiGraph.predecessors`, {meth}`DiGraph.successors` etc.
To allow algorithms to work with both classes easily, the directed versions of
{meth}`neighbors <DiGraph.neighbors>` is equivalent to
{meth}`successors <DiGraph.successors>` while {attr}`DiGraph.degree` reports the sum
of {attr}`DiGraph.in_degree` and {attr}`DiGraph.out_degree` even though that may
feel inconsistent at times.
```{code-cell}
DG = nx.DiGraph()
DG.add_weighted_edges_from([(1, 2, 0.5), (3, 1, 0.75)])
DG.out_degree(1, weight='weight')
```
```{code-cell}
DG.degree(1, weight='weight')
```
```{code-cell}
list(DG.successors(1))
```
```{code-cell}
list(DG.neighbors(1))
```
Some algorithms work only for directed graphs and others are not well
defined for directed graphs. Indeed the tendency to lump directed
and undirected graphs together is dangerous. If you want to treat
a directed graph as undirected for some measurement you should probably
convert it using {meth}`Graph.to_undirected` or with
```{code-cell}
H = nx.Graph(G) # create an undirected graph H from a directed graph G
```
## Multigraphs
NetworkX provides classes for graphs which allow multiple edges
between any pair of nodes. The {class}`MultiGraph` and
{class}`MultiDiGraph`
classes allow you to add the same edge twice, possibly with different
edge data. This can be powerful for some applications, but many
algorithms are not well defined on such graphs.
Where results are well defined,
e.g., {meth}`MultiGraph.degree` we provide the function. Otherwise you
should convert to a standard graph in a way that makes the measurement
well defined.
```{code-cell}
MG = nx.MultiGraph()
MG.add_weighted_edges_from([(1, 2, 0.5), (1, 2, 0.75), (2, 3, 0.5)])
dict(MG.degree(weight='weight'))
```
```{code-cell}
GG = nx.Graph()
for n, nbrs in MG.adjacency():
for nbr, edict in nbrs.items():
minvalue = min([d['weight'] for d in edict.values()])
GG.add_edge(n, nbr, weight = minvalue)
nx.shortest_path(GG, 1, 3)
```
## Graph generators and graph operations
In addition to constructing graphs node-by-node or edge-by-edge, they
can also be generated by
### 1. Applying classic graph operations, such as:
```{eval-rst}
.. autosummary::
~classes.function.subgraph
~algorithms.operators.binary.union
~algorithms.operators.binary.disjoint_union
~algorithms.operators.product.cartesian_product
~algorithms.operators.binary.compose
~algorithms.operators.unary.complement
~classes.function.create_empty_copy
~classes.function.to_undirected
~classes.function.to_directed
```
### 2. Using a call to one of the classic small graphs, e.g.,
```{eval-rst}
.. autosummary::
~generators.small.petersen_graph
~generators.small.tutte_graph
~generators.small.sedgewick_maze_graph
~generators.small.tetrahedral_graph
```
### 3. Using a (constructive) generator for a classic graph, e.g.,
```{eval-rst}
.. autosummary::
~generators.classic.complete_graph
~algorithms.bipartite.generators.complete_bipartite_graph
~generators.classic.barbell_graph
~generators.classic.lollipop_graph
```
like so:
```{code-cell}
K_5 = nx.complete_graph(5)
K_3_5 = nx.complete_bipartite_graph(3, 5)
barbell = nx.barbell_graph(10, 10)
lollipop = nx.lollipop_graph(10, 20)
```
### 4. Using a stochastic graph generator, e.g,
```{eval-rst}
.. autosummary::
~generators.random_graphs.erdos_renyi_graph
~generators.random_graphs.watts_strogatz_graph
~generators.random_graphs.barabasi_albert_graph
~generators.random_graphs.random_lobster_graph
```
like so:
```{code-cell}
er = nx.erdos_renyi_graph(100, 0.15)
ws = nx.watts_strogatz_graph(30, 3, 0.1)
ba = nx.barabasi_albert_graph(100, 5)
red = nx.random_lobster_graph(100, 0.9, 0.9)
```
### 5. Reading a graph stored in a file using common graph formats
NetworkX supports many popular formats, such as edge lists, adjacency lists,
GML, GraphML, LEDA and others.
```{code-cell}
nx.write_gml(red, "path.to.file")
mygraph = nx.read_gml("path.to.file")
```
For details on graph formats see {doc}`/reference/readwrite/index`
and for graph generator functions see {doc}`/reference/generators`
## Analyzing graphs
The structure of `G` can be analyzed using various graph-theoretic
functions such as:
```{code-cell}
G = nx.Graph()
G.add_edges_from([(1, 2), (1, 3)])
G.add_node("spam") # adds node "spam"
list(nx.connected_components(G))
```
```{code-cell}
sorted(d for n, d in G.degree())
```
```{code-cell}
nx.clustering(G)
```
Some functions with large output iterate over (node, value) 2-tuples.
These are easily stored in a `dict` structure if you desire.
```{code-cell}
sp = dict(nx.all_pairs_shortest_path(G))
sp[3]
```
See {doc}`/reference/algorithms/index` for details on graph algorithms
supported.
## Floating point considerations
Many NetworkX algorithms work with numeric values, such as edge weights. Once
your input contains floating point numbers,
**all results are inherently approximate** due to the limited precision of
floating point arithmetic. This is especially true for algorithms such as
shortest-path, flows, cuts, minimum-spanning, etc. Basically any time a min or
max value is computed.
For example:
```{code-cell}
import networkx as nx
tiny = 5e-17
G = nx.DiGraph()
G.add_edge('A', 'B', weight=0.1)
G.add_edge('B', 'C', weight=0.1)
G.add_edge('C', 'D', weight=0.1)
G.add_edge('A', 'D', weight=0.3 + tiny)
path = nx.shortest_path(G, source='A', target='D', weight='weight')
print(path)
```
Even though `A -> B -> C -> D` has a total weight of `0.3`, the direct edge
`A -> D` with `0.3 + 1e-17` is selected. This demonstrates that algorithms
treat floating point numbers as exact, so very small differences can change the
outcome.
Floating point arithmetic can produce unintuitive results because certain
values, such as `0.3`, cannot be represented exactly in binary. For example:
```{code-cell}
0.1 + 0.1 + 0.1 > 0.3
```
In general, when using floating point numbers in NetworkX, you should expect
results to be approximate rather than exact. Multiplying weights by a large
number and converting them to integers can help reduce some subtle comparison
issues, but it does not fully eliminate them. NetworkX does not automatically
apply tolerances in numeric comparisons.
Below is a version of the previous example using the recommended technique with
different precision tolerances.
```{code-cell}
for precision in [16, 17]:
path = nx.shortest_path(
G,
source='A',
target='D',
weight=lambda u, v, d: int(d['weight'] * 10 ** precision)
)
print(f"With {precision} precision digits, path is {path}")
```
(using-networkx-backends)=
## Using NetworkX backends
NetworkX can be configured to use separate third-party backends to improve
performance and add functionality. Backends are optional, installed separately,
and can be enabled either directly in the user's code or through environment
variables.
Several backends are available to accelerate NetworkX--often
significantly--using GPUs, parallel processing, and other optimizations, while
other backends add additional features such as graph database
integration. Multiple backends can be used together to compose a NetworkX
runtime environment optimized for a particular system or use case.
```{note}
Refer to the {doc}`/backends` section to see a list of available backends known
to work with the current stable release of NetworkX.
```
NetworkX uses backends by **_dispatching_** function calls at runtime to
corresponding functions provided by backends, either **automatically** via
configuration variables, or **explicitly** by hard-coded arguments to functions.
### Automatic dispatch
Automatic dispatch is possibly the easiest and least intrusive means by which a
user can use backends with NetworkX code. This technique is useful for users
that want to write portable code that runs on systems without specific
backends, or simply want to use backends for existing code without
modifications.
The example below configures NetworkX to automatically dispatch to a backend
named `fast_backend` for all NetworkX functions that `fast_backend` supports.
- If `fast_backend` does not support a NetworkX function used by the
application, the default NetworkX implementation for that function will be
used.
- If `fast_backend` is not installed on the system running this code, an
exception will be raised.
```{code-block}
bash$> NETWORKX_BACKEND_PRIORITY=fast_backend python my_script.py
```
```{code-block}
:caption: my_script.py
import networkx as nx
G = nx.karate_club_graph()
pr = nx.pagerank(G) # runs using backend from NETWORKX_BACKEND_PRIORITY, if set
```
The equivalent configuration can be applied to NetworkX directly to the code
through the NetworkX `config` global parameters, which may be useful if
environment variables are not suitable. This will override the corresponding
environment variable allowing backends to be enabled programmatically in Python
code. However, the tradeoff is slightly less portability as updating the
backend specification may require a small code change instead of simply
updating an environment variable.
```{code-cell}
:tags: [skip-execution]
nx.config.backend_priority = ["fast_backend"]
pr = nx.pagerank(G)
```
Automatic dispatch using the `NETWORKX_BACKEND_PRIORITY` environment variable
or the `nx.config.backend_priority` global config also allows for the
specification of multiple backends, ordered based on the priority which
NetworkX should attempt to dispatch to.
The following examples both configure NetworkX to dispatch functions first to
`fast_backend` if it supports the function, then `other_backend` if
`fast_backend` does not, then finally the default NetworkX implementation if no
backend specified can handle the call.
```{code-block}
bash$> NETWORKX_BACKEND_PRIORITY="fast_backend,other_backend" python my_script.py
```
```{code-cell}
:tags: [skip-execution]
nx.config.backend_priority = ["fast_backend", "other_backend"]
```
````{tip}
NetworkX includes debug logging calls using Python's standard logging
mechanism. These can be enabled to help users understand when and how backends
are being used.
To enable debug logging only in NetworkX modules:
```{code-block}
import logging
_l = logging.getLogger("networkx")
_l.addHandler(_h:=logging.StreamHandler())
_h.setFormatter(logging.Formatter("%(levelname)s:NetworkX:%(message)s"))
_l.setLevel(logging.DEBUG)
```
or to enable it globally:
```{code-block}
logging.basicConfig(level=logging.DEBUG)
```
````
### Explicit dispatch
Backends can also be used explicitly on a per-function call basis by specifying
a backend using the `backend=` keyword argument. This technique not only
requires that the backend is installed, but _also_ requires that the backend
implement the function, since NetworkX will not fall back to the default NetworkX
implementation if a backend is specified with `backend=`.
This is possibly the least portable option, but has the advantage that NetworkX
will raise an exception if `fast_backend` cannot be used, which is useful for
users that require a specific implementation. Explicit dispatch can also
provide a more interactive experience and is especially useful for
demonstrations, experimentation, and debugging.
```{code-cell}
:tags: [skip-execution]
pr = nx.pagerank(G, backend="fast_backend")
```
### Advanced dispatching options
The NetworkX dispatcher allows users to use backends for NetworkX code in very
specific ways not covered in this tutorial. Refer to the
{doc}`/reference/backends` reference section for details on topics such as:
- Control of how specific function types (algorithms vs. generators) are
dispatched to specific backends
- Details on automatic conversions to/from backend and NetworkX graphs for
dispatch and fallback
- Caching graph conversions
- Explicit backend graph instantiation and dispatching based on backend graph
types
- and more...
## Drawing graphs
NetworkX is not primarily a graph drawing package but basic drawing with
Matplotlib as well as an interface to use the open source Graphviz software
package are included. These are part of the {doc}`networkx.drawing <reference/drawing>`
module and will be imported if possible.
First import Matplotlib's plot interface (pylab works too)
```{code-cell}
import matplotlib.pyplot as plt
```
To test if the import of `~networkx.drawing.nx_pylab` was successful draw `G`
using one of
```{code-cell}
G = nx.petersen_graph()
subax1 = plt.subplot(121)
nx.draw(G, with_labels=True, font_weight='bold')
subax2 = plt.subplot(122)
nx.draw_shell(G, nlist=[range(5, 10), range(5)], with_labels=True, font_weight='bold')
```
when drawing to an interactive display. Note that you may need to issue a
Matplotlib
```python
plt.show()
```
command if you are not using matplotlib in interactive mode.
```{code-cell}
options = {
'node_color': 'black',
'node_size': 100,
'width': 3,
}
subax1 = plt.subplot(221)
nx.draw_random(G, **options)
subax2 = plt.subplot(222)
nx.draw_circular(G, **options)
subax3 = plt.subplot(223)
nx.draw_spectral(G, **options)
subax4 = plt.subplot(224)
nx.draw_shell(G, nlist=[range(5,10), range(5)], **options)
```
You can find additional options via {func}`~drawing.nx_pylab.draw_networkx` and
layouts via the {mod}`layout module<networkx.drawing.layout>`.
You can use multiple shells with {func}`~drawing.nx_pylab.draw_shell`.
```{code-cell}
G = nx.dodecahedral_graph()
shells = [[2, 3, 4, 5, 6], [8, 1, 0, 19, 18, 17, 16, 15, 14, 7], [9, 10, 11, 12, 13]]
nx.draw_shell(G, nlist=shells, **options)
```
To save drawings to a file, use, for example
```pycon
>>> nx.draw(G)
>>> plt.savefig("path.png")
```
This function writes to the file `path.png` in the local directory. If Graphviz and
PyGraphviz or pydot, are available on your system, you can also use
`networkx.drawing.nx_agraph.graphviz_layout` or
`networkx.drawing.nx_pydot.graphviz_layout` to get the node positions, or write
the graph in dot format for further processing.
```pycon
>>> from networkx.drawing.nx_pydot import write_dot
>>> pos = nx.nx_agraph.graphviz_layout(G)
>>> nx.draw(G, pos=pos)
>>> write_dot(G, 'file.dot')
```
See {doc}`/reference/drawing` for additional details.
## NX-Guides
If you are interested in learning more about NetworkX, graph theory and network analysis
then you should check out {doc}`nx-guides <nx-guides:index>`. There you can find tutorials,
real-world applications and in-depth examinations of graphs and network algorithms.
All the material is official and was developed and curated by the NetworkX community.
---
### Doc Static Version Switcher.Json (`doc/_static/version_switcher.json`)
[
{
"name": "latest",
"version": "latest",
"url": "https://networkx.org/documentation/latest/"
},
{
"name": "3.7 (stable)",
"version": "3.7",
"url": "https://networkx.org/documentation/stable/",
"preferred": true
},
{
"name": "3.6.1",
"version": "3.6.1",
"url": "https://networkx.org/documentation/networkx-3.6.1/"
},
{
"name": "3.6",
"version": "3.6",
"url": "https://networkx.org/documentation/networkx-3.6/"
},
{
"name": "3.5",
"version": "3.5",
"url": "https://networkx.org/documentation/networkx-3.5/"
},
{
"name": "3.4.2",
"version": "3.4.2",
"url": "https://networkx.org/documentation/networkx-3.4.2/"
},
{
"name": "3.4.1",
"version": "3.4.1",
"url": "https://networkx.org/documentation/networkx-3.4.1/"
},
{
"name": "3.4",
"version": "3.4",
"url": "https://networkx.org/documentation/networkx-3.4/"
},
{
"name": "3.3",
"version": "3.3",
"url": "https://networkx.org/documentation/networkx-3.3/"
},
{
"name": "3.2.1",
"version": "3.2.1",
"url": "https://networkx.org/documentation/networkx-3.2.1/"
},
{
"name": "3.2",
"version": "networkx-3.2",
"url": "https://networkx.org/documentation/networkx-3.2/"
}
]
---
### Doc Developer About Us (`doc/developer/about_us.rst`)
About Us
========
NetworkX was originally written by Aric Hagberg, Dan Schult, and Pieter Swart,
and has been developed with the help of many others. Thanks to everyone who has
improved NetworkX by contributing code, bug reports (and fixes), documentation,
and input on design, features, and the future of NetworkX.
.. include:: teams.inc
Contributors
------------
If you are a NetworkX contributor, please feel free to
open an `issue <https://github.com/networkx/networkx/issues/new>`_ or
submit a `pull request <https://github.com/networkx/networkx/compare/>`_
to add your name to the bottom of the list.
- Aric Hagberg, GitHub: `hagberg <https://github.com/hagberg>`_
- Dan Schult, GitHub: `dschult <https://github.com/dschult>`_
- Pieter Swart
- Katy Bold
- Hernan Rozenfeld
- Brendt Wohlberg
- Jim Bagrow
- Holly Johnsen
- Arnar Flatberg
- Chris Myers
- Joel Miller
- Keith Briggs
- Ignacio Rozada
- Phillipp Pagel
- Sverre Sundsdal
- Ross M. Richardson
- Eben Kenah
- Sasha Gutfriend
- Udi Weinsberg
- Matteo Dell'Amico
- Andrew Conway
- Raf Guns
- Salim Fadhley
- Fabrice Desclaux
- Arpad Horvath
- Minh Van Nguyen
- Willem Ligtenberg
- Loïc Séguin-C.
- Paul McGuire
- Jesus Cerquides
- Ben Edwards
- Jon Olav Vik
- Hugh Brown
- Ben Reilly
- Leo Lopes
- Jordi Torrents, GitHub: `jtorrents <https://github.com/jtorrents>`_
- Dheeraj M R, GitHub: `dheerajrav <https://github.com/dheerajrav>`_
- Franck Kalala
- Simon Knight
- Conrad Lee
- Sérgio Nery Simões
- Robert King
- Nick Mancuso
- Brian Cloteaux
- Alejandro Weinstein
- Dustin Smith
- Mathieu Larose
- Romain Fontugne
- Vincent Gauthier
- chebee7i, GitHub: `chebee7i <https://github.com/chebee7i>`_
- Jeffrey Finkelstein
- Jean-Gabriel Young, GitHub: `jg-you <https://github.com/jgyou>`_
- Andrey Paramonov, http://aparamon.msk.ru
- Mridul Seth, GitHub: `MridulS <https://github.com/MridulS>`_
- Thodoris Sotiropoulos, GitHub: `theosotr <https://github.com/theosotr>`_
- Konstantinos Karakatsanis, GitHub: `k-karakatsanis <https://github.com/k-karakatsanis>`_
- Ryan Nelson, GitHub: `rnelsonchem <https://github.com/rnelsonchem>`_
- Niels van Adrichem, GitHub: `NvanAdrichem <https://github.com/NvanAdrichem>`_
- Michael E. Rose, GitHub: `Michael-E-Rose <https://github.com/Michael-E-Rose>`_
- Jarrod Millman, GitHub: `jarrodmillman <https://github.com/jarrodmillman>`_
- Andre Weltsch
- Lewis Robbins
- Mads Jensen, GitHub: `atombrella <https://github.com/atombrella>`_
- Edward L. Platt, `elplatt <https://elplatt.com>`_
- James Owen, GitHub: `leamingrad <https://github.com/leamingrad>`_
- Robert Gmyr, GitHub: `gmyr <https://github.com/gmyr>`_
- Mike Trenfield
- Jon Crall, GitHub: `Erotemic <https://github.com/Erotemic>`_
- Issa Moradnejad, GitHub: `Moradnejad <https://github.com/Moradnejad>`_, LinkedIn: `Issa Moradnejad <https://linkedin.com/in/moradnejad/>`_
- Brian Kiefer, GitHub: `bkief <https://github.com/bkief>`_
- Julien Klaus
- Peter C. Kroon, GitHub: `pckroon <https://github.com/pckroon>`_
- Weisheng Si, GitHub: `ws4u <https://github.com/ws4u>`_
- Haakon H. Rød, GitLab: `haakonhr <https://gitlab.com/haakonhr>`_, `<https://haakonhr.gitlab.io>`_
- Efraim Rodrigues, GitHub: `efraimrodrigues <https://github.com/efraimrodrigues>`_, LinkedIn: `efraim-rodrigues <https://linkedin.com/in/efraim-rodrigues/>`_
- Erwan Le Merrer
- Søren Fuglede Jørgensen, GitHub: `fuglede <https://github.com/fuglede>`_
- Salim BELHADDAD, LinkedIn: `salymdotme <https://www.linkedin.com/in/salymdotme/>`_
- Jangwon Yie, GitHub: `jangwon-yie <https://github.com/jangwon-yie>`_, LinkedIn: `jangwon-yie-a7960065 <https://www.linkedin.com/in/jangwon-yie-a7960065/>`_
- ysitu
- Tomas Gavenciak
- Luca Baldesi
- Yuto Yamaguchi
- James Clough
- Minas Gjoka
- Drew Conway
- Alex Levenson
- Haochen Wu
- Erwan Le Merrer
- Alex Roper
- P C Kroon
- Christopher Ellison
- D. Eppstein
- Federico Rosato
- Aitor Almeida
- Ferran Parés
- Christian Olsson
- Fredrik Erlandsson
- Nanda H Krishna
- Nicholas Mancuso
- Fred Morstatter
- Ollie Glass
- Rodrigo Dorantes-Gilardi
- Pranay Kanwar
- Balint Tillman
- Diederik van Liere
- Ferdinando Papale
- Miguel Sozinho Ramalho
- Brandon Liu
- Nima Mohammadi
- Jason Grout
- Jan Aagaard Meier
- Henrik Haugbølle
- Piotr Brodka
- Sasha Gutfraind
- Alessandro Luongo
- Huston Hedinger
- Oleguer Sagarra
- Kazimierz Wojciechowski, GitHub: `kazimierz-256 <https://github.com/kazimierz-256>`_, LinkedIn: `wojciechowski-kazimierz <https://linkedin.com/in/wojciechowski-kazimierz/>`_
- Gaetano Pietro Paolo Carpinato, GitHub: `Carghaez <https://github.com/Carghaez>`_, LinkedIn: `gaetanocarpinato <https://linkedin.com/in/gaetanocarpinato/>`_
- Arun Nampally, GitHub: `arunwise <https://github.com/arunwise>`_, LinkedIn: `arun-nampally-b57845b7 <https://www.linkedin.com/in/arun-nampally-b57845b7/>`_
- Ryan Duve
- Shashi Prakash Tripathi, GitHub: `itsshavar <https://github.com/itsshavar>`_, LinkedIn: `itsshashitripathi <https://www.linkedin.com/in/itsshashitripathi/>`_
- Danny Niquette
- James Trimble, GitHub: `jamestrimble <https://github.com/jamestrimble>`_
- Matthias Bruhns, GitHub: `mbruhns <https://github.com/mbruhns>`_
- Philip Boalch
- Matt Schwennesen, GitHub: `mjschwenne <https://github.com/mjschwenne>`_
- Andrew Knyazev, GitHub: `lobpcg <https://github.com/lobpcg>`_, LinkedIn: `andrew-knyazev <https://www.linkedin.com/in/andrew-knyazev>`_
- Luca Cappelletti, GitHub: `LucaCappelletti94 <https://github.com/LucaCappelletti94>`_
- Sultan Orazbayev, GitHub: `SultanOrazbayev <https://github.com/SultanOrazbayev>`_, LinkedIn: `Sultan Orazbayev <https://www.linkedin.com/in/sultan-orazbayev/>`_
- Paolo Boldi, Github: `https://github.com/boldip`
- Davide D'Ascenzo, Github: `https://github.com/kidara`
- Flavio Furia, Github: `https://github.com/flaviofuria`
- Sebastiano Vigna, Github: `https://github.com/vigna`
- Aaron Zolnai-Lucas, GitHub: `aaronzo <https://github.com/aaronzo>`_, LinkedIn: `aaronzolnailucas <https://www.linkedin.com/in/aaronzolnailucas/>`_
- Erik Welch, GitHub: `eriknw <https://github.com/eriknw>`_, LinkedIn: `eriknwelch <https://www.linkedin.com/in/eriknwelch/>`_
- Mohamed Rezk, Github: `mohamedrezk122 <https://github.com/mohamedrezk122>`_
- Orion Sehn, GitHub: `OrionSehn <https://github.com/OrionSehn>`_
- Berlin Cho, GitHub: `berlincho <https://github.com/berlincho>`_
- Alejandro Candioti, GitHub: `amcandio <https://github.com/amcandio>`_, LinkedIn: <https://www.linkedin.com/in/amcandio/>
A supplementary (but still incomplete) list of contributors is given by the
list of names that have commits in ``networkx``'s
`git <http://git-scm.com>`_ repository. This can be obtained via::
git log --raw | grep "^Author: " | sort | uniq
A historical, partial listing of contributors and their contributions to some
of the earlier versions of NetworkX can be found
`here <https://github.com/networkx/networkx/blob/886e790437bcf30e9f58368829d483efef7a2acc/doc/source/reference/credits_old.rst>`_.
Support
-------
NetworkX acknowledges support from the following organizations:
- `Center for Nonlinear Studies <http://cnls.lanl.gov>`_, Los Alamos National
Laboratory, PI: Aric Hagberg
- `Open Source Programs Office <https://developers.google.com/open-source/>`_,
Google
- `Complexity Sciences Center <http://csc.ucdavis.edu/>`_, Department of
Physics, University of California-Davis, PI: James P. Crutchfield
- `Center for Complexity and Collective Computation <http://c4.discovery.wisc.edu>`_,
Wisconsin Institute for Discovery, University of Wisconsin-Madison,
PIs: Jessica C. Flack and David C. Krakauer
- `Colgate University <https://www.colgate.edu/>`_
- `California Institute of Technology <https://www.caltech.edu/>`_
- `Berkeley Institute for Data Science <https://bids.berkeley.edu/>`_
- `NVIDIA Corporation <https://www.nvidia.com/>`_
NetworkX acknowledges the following financial support:
- Google Summer of Code via Python Software Foundation (2013, 2015),
NumFOCUS (2021-2024)
- U.S. Army Research Office grant W911NF-12-1-0288
- DARPA Physical Intelligence Subcontract No. 9060-000709
- NSF Grant No. PHY-0748828
- John Templeton Foundation through a grant to the Santa Fe Institute to
study complexity
- U.S. Army Research Laboratory and the U.S. Army Research Office under
contract number W911NF-13-1-0340
- Chan Zuckerberg Initiative Essential Open Source Software for Science
EOSS2-0000000066 and EOSS4-0000000138
- Wellcome Trust via CZI, Wellcome and Kavli EOSS Cycle 6 (EOSS6-000000368)
---
### Doc Developer Core Developer (`doc/developer/core_developer.rst`)
.. _core_dev:
Core Developer Guide
====================
As a core developer, you should continue making pull requests
in accordance with the :ref:`contributor_guide`.
You are responsible for shepherding other contributors through the review process.
You should be familiar with our :ref:`mission_and_values`.
You also have the ability to merge or approve other contributors' pull requests.
Much like nuclear launch keys, it is a shared power: you must merge *only after*
another core developer has approved the pull request, *and* after you yourself have carefully
reviewed it. (See `Reviewing`_ and especially `Merge Only Changes You
Understand`_ below.) To ensure a clean git history, use GitHub's
`Squash and Merge <https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/merging-a-pull-request#merging-a-pull-request-on-github>`__
feature to merge, unless you have a good reason not to do so.
Reviewing
---------
Pre-Merge RequirementsAll pull requests should meet the following criteria before merging into main:
- Have at least two approvals from reviewers on the maintainers or triage team.
- Have one of the
type: <https://github.com/networkx/networkx/labels?q=type>_
labels applied prior to merge.
The two approvals requirement applies to PRs originating from external contributors.
If the PR submitter is a maintainer, then careful review from another maintainer
is sufficient to meet the "two reviews" threshold.
The type: labels are used to automatically categorize and generate the
release notes; therefore one of these labels must be applied for the release
notes to be generated properly.
The rule-of-thumb is the first approver is responsible for applying the
label, but anyone with at least triaging permissions is welcome to apply atype: label.
How to Conduct A Good Review
*Always* be kind to contributors. Nearly all of NetworkX is
volunteer work, for which we are tremendously grateful. Provide
constructive criticism on ideas and implementations, and remind
yourself of how it felt when your own work was being evaluated as a
novice.
NetworkX strongly values mentorship in code review. New users
often need more handholding, having little to no git
experience. Repeat yourself liberally, and, if you don’t recognize a
contributor, point them to our development guide, or other GitHub
workflow tutorials around the web. Do not assume that they know how
GitHub works (e.g., many don't realize that adding a commit
automatically updates a pull request). Gentle, polite, kind
encouragement can make the difference between a new core developer and
an abandoned pull request.
When reviewing, focus on the following:
1. **API:** The API is what users see when they first use
NetworkX. APIs are difficult to change once released, so
should be simple, `functional
<https://en.wikipedia.org/wiki/Functional_programming>`__ (i.e. not
carry state), consistent with other parts of the library, and
should avoid modifying input variables. Please familiarize
yourself with the project's :ref:`deprecation_policy`.
2. **Documentation:** Any new feature should have a gallery
example that not only illustrates but explains it.
3. **The algorithm:** You should understand the code being modified or
added before approving it. (See `Merge Only Changes You
Understand`_ below.) Implementations should do what they claim,
and be simple, readable, and efficient.
4. **Tests:** All contributions to the library *must* be tested, and
each added line of code should be covered by at least one test. Good
tests not only execute the code, but explores corner cases. It is tempting
not to review tests, but please do so.
Other changes may be *nitpicky*: spelling mistakes, formatting,
etc. Do not ask contributors to make these changes, and instead
make the changes by `pushing to their branch
<https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/committing-changes-to-a-pull-request-branch-created-from-a-fork>`__,
or using GitHub’s `suggestion
<https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/commenting-on-a-pull-request>`__
`feature
<https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request>`__.
(The latter is preferred because it gives the contributor a choice in
whether to accept the changes.)
Our default merge policy is to squash all PR commits into a single
commit. Users who wish to bring the latest changes from ``main``
into their branch should be advised to merge, not to rebase. Even
when merge conflicts arise, don’t ask for a rebase unless you know
that a contributor is experienced with git. Instead, rebase the branch
yourself, force-push to their branch, and advise the contributor on
how to force-pull. If the contributor is no longer active, you may
take over their branch by submitting a new pull request and closing
the original. In doing so, ensure you communicate that you are not
throwing the contributor's work away! You should use GitHub's
``Co-authored-by:`` keyword for commit messages to credit the
original contributor.
Please add a note to a pull request after you push new changes; GitHub
may not send out notifications for these.
Merge Only Changes You UnderstandLong-term maintainability is an important concern. Code doesn't
merely have to work, but should be understood by multiple core
developers. Changes will have to be made in the future, and the
original contributor may have moved on.
Therefore, do not merge a code change unless you understand it. Ask
for help freely: we have a long history of consulting community
members, or even external developers, for added insight where needed,
and see this as a great learning opportunity.
While we collectively "own" any patches (and bugs!) that become part
of the code base, you are vouching for changes you merge. Please take
that responsibility seriously.
Closing issues and pull requests
Sometimes, an issue must be closed that was not fully resolved. This can be
for a number of reasons:
- the person behind the original post has not responded to calls for
clarification, and none of the core developers have been able to reproduce
their issue; - fixing the issue is difficult, and it is deemed too niche a use case to
devote sustained effort or prioritize over other issues; or - the use case or feature request is something that core developers feel
does not belong in NetworkX,
among others. Similarly, pull requests sometimes need to be closed without
merging, because:
- the pull request implements a niche feature that we consider not worth the
added maintenance burden; - the pull request implements a useful feature, but requires significant
effort to bring up to NetworkX's standards, and the original
contributor has moved on, and no other developer can be found to make the
necessary changes; or - the pull request makes changes that do not align with our values, such as
increasing the code complexity of a function significantly to implement a
marginal speedup,
among others.
All these may be valid reasons for closing, but we must be wary not to alienate
contributors by closing an issue or pull request without an explanation. When
closing, your message should:
- explain clearly how the decision was made to close. This is particularly
important when the decision was made in a community meeting, which does not
have as visible a record as the comments thread on the issue itself; - thank the contributor(s) for their work; and
- provide a clear path for the contributor or anyone else to appeal the
decision.
These points help ensure that all contributors feel welcome and empowered to
keep contributing, regardless of the outcome of past contributions.
Further resources
As a core member, you should be familiar with community and developer
resources such as:
- Our :ref:
contributor_guide - Our :ref:
code_of_conduct PEP8 <https://www.python.org/dev/peps/pep-0008/>__ for Python stylePEP257 <https://www.python.org/dev/peps/pep-0257/>__ and theNumPy documentation guide <https://numpy.org/doc/stable/docs/howto_document.html>__
for docstrings. (NumPy docstrings are a superset of PEP257. You
should read both.)- The NetworkX
tag on StackOverflow <https://stackoverflow.com/questions/tagged/networkx>__ - Our
mailing list <http://groups.google.com/group/networkx-discuss/>__
You are not required to monitor all of the social resources.
Doc Developer Deprecations (`doc/developer/deprecations.rst`)
Deprecations
.. _deprecation_policy:
Policy
If the behavior of the library has to be changed, a deprecation cycle must be
followed to warn users.
A deprecation cycle is not necessary when:
- adding a new function, or
- adding a new keyword argument to the end of a function signature, or
- fixing buggy behavior
A deprecation cycle is necessary for any breaking API change, meaning a
change where the function, invoked with the same arguments, would return a
different result after the change. This includes:
- changing the order of arguments or keyword arguments, or
- adding arguments or keyword arguments to a function, or
- changing the name of a function, class, method, etc., or
- moving a function, class, etc. to a different module, or
- changing the default value of a function's arguments.
Usually, our policy is to put in place a deprecation cycle over two minor
releases (e.g., if a deprecation warning appears in 2.3, then the functionality
should be removed in 2.5). For major releases we usually require that all
deprecations have at least a 1-release deprecation cycle (e.g., if 3.0 occurs
after 2.5, then all removed functionality in 3.0 should be deprecated in 2.5).
Note that these 1- and 2-release deprecation cycles for major and minor
releases is not a strict rule and in some cases, the developers can agree on a
different procedure upon justification (like when we can't detect the change,
or it involves moving or deleting an entire function for example).
Procedure
To set up a function for deprecation:
Use a deprecation warning to warn users. For example::
textmsg = "curly_hair is deprecated and will be removed in v3.0. Use sum() instead." warnings.warn(msg, DeprecationWarning)Add a warnings filter to
networkx/conftest.py::textwarnings.filterwarnings( "ignore", category=DeprecationWarning, message=<start of message> )Add a reminder to
doc/developer/deprecations.rstfor the team
to remove the deprecated functionality in the future. For example:.. code-block:: rst
- In
utils/misc.pyremovegenerate_unique_nodeand related tests.
- In
.. note::
To reviewers: make sure the merge message has a brief description of the
change(s) and if the PR closes an issue add, for example, "Closes #123"
where 123 is the issue number.
Todo
Make sure to review networkx/conftest.py after removing deprecated code.
Version 3.8
* Remove ``maybe_regular_expander`` from ``networkx.generators.expanders``.
* In ``algorithms/approximation/steinertree.py`` remove ``metric_closure`` and related tests.
Version 3.9- Remove
bfs_predecessorsfromnetworkx.algorithms.traversal.breadth_first_searcph. - Remove the
p2gmodule fromnetworkx.readwrite.
Doc Developer Index (`doc/developer/index.rst`)
.. _developer:
Developer
.. only:: html
:Release: |version|
:Date: |today|.. toctree::
:maxdepth: 2
about_us
code_of_conduct
values
contribute
projects
new_contributor_faq
core_developer
release
deprecations
roadmap
nxeps/index
Doc Developer New Contributor Faq (`doc/developer/new_contributor_faq.rst`)
.. _contributing_faq:
New Contributor FAQ
A collection of frequently-asked questions by newcomers to
open-source development and first-time contributors to NetworkX.
Q: I'm new to open source and would like to contribute to NetworkX. How do I get started?
To contribute to NetworkX, you will need three things:
- The source code
- A development environment
- An idea of what you'd like to contribute
Steps 1 & 2 are covered extensively in :ref:Development Workflow <dev_workflow>.
There is no generic answer for step 3. There are many ways that NetworkX can
be improved, from adding new algorithms, improving existing algorithms,
improving the test suite (e.g. increasing test coverage), and improving the
documentation.
The "best" way to find a place to start is to follow your own personal
interests!
That said, a few places to check for ideas on where to get started:
The issue tracker <https://github.com/networkx/networkx/issues>_ lists
known bugs and feature requests.- The
Algorithms discussion_ includes a listing of algorithms that users
would like to have but that are not yet included in NetworkX.
.. _Algorithms discussion: https://github.com/networkx/networkx/discussions/categories/algorithms
Q: I've found an issue I'm interested in, can I have it assigned to me?
NetworkX doesn't typically assign issues to contributors. If you find an issue
or feature request on the issue tracker that you'd like to work on, you should
first check the issue thread to see if there are any linked pull requests.
If not, then feel free to open a new PR to address the issue - no need
to ask for permission - and don't forget to reference the issue number in the PR
comments so that others know you are now working on it!
Q: How do I contribute an example to the Gallery?
The example gallery is great place to contribute, particularly if you have an
interesting application or visualization that uses NetworkX.
The gallery is generated using :doc:sphinx-gallery <sphinx-gallery:index>
from Python scripts stored in the examples/ directory.
For instance, let's say I'd like to contribute an example of visualizing acomplete graph <networkx.generators.classic.complete_graph> using acircular layout <networkx.drawing.layout.circular_layout>.
Assuming you have already followed the procedure for
:ref:setting up a development environment <dev_workflow>, start by
creating a new branch:
.. code-block:: bash
git checkout -b complete-graph-circular-layout-example
.. note:: It's generally a good idea to give your branch a descriptive name so
that it's easy to remember what you are working on.
Now you can begin work on your example. Sticking with the circular layout idea,
you might create a file in examples/drawing called plot_circular_layout.py
with the following contents::
import networkx as nx
import matplotlib.pyplot as plt
G = nx.complete_graph(10) # A complete graph with 10 nodes
nx.draw_networkx(G, pos=nx.circular_layout(G))
.. note:: It may not be clear where exactly an example belongs. Our circular
layout example is very simple, so perhaps it belongs in examples/basic.
It would also make sense for it to be in examples/drawing since it deals
with visualization. Don't worry if you're not sure: questions like this will
be resolved during the review process.
At this point, your contribution is ready to be reviewed. You can make the
changes on your complete-graph-circular-layout-example branch visible to
other NetworkX developers bycreating a pull request__.
__ PR_
.. seealso:: The :ref:developer guide <dev_workflow> has more details on
creating pull requests.
Q: I want to work on a specific function. How do I find it in the source code?
Assuming you have followed the instructions for
:ref:setting up the development workflow <dev_workflow>, there are several
ways of determining where the in the source code a particular function or
class is defined.
For example, let's say you are interested in making a change to the~networkx.drawing.layout.kamada_kawai_layout function, so you need to know
where it is defined. In an IPython terminal, you can use ? --- the source file is
listed in the File: field:
.. code-block:: ipython3
In [1]: import networkx as nx
In [2]: nx.kamada_kawai_layout?
.. code-block:: text
Signature:
Docstring:
File: ~/networkx/networkx/drawing/layout.py
Type: function
Command line utilities like grep or git grep are also very useful.
For example, from the NetworkX source directory:
.. code-block:: bash
$ grep -r "def kamada_kawai_layout" .
./networkx/drawing/layout.py:def kamada_kawai_layout(
Q: What is the policy for deciding whether to include a new algorithm?
There is no official policy setting explicit inclusion criteria for new
algorithms in NetworkX. New algorithms are more likely to be included if they
have been published and are cited by others. More important than number of
citations is how well proposed additions fit the project :ref:mission_and_values.
Testing is also an important factor in determining whether algorithms
should be included. Proposals that include thorough tests which illustrate
expected behavior are much easier to review, and therefore likely to progress more rapidly.
.. note::
Thorough does not mean exhaustive. The quality of unit tests is much
more important than quantity. Thorough tests should address questions like:
- Does the algorithm support different graph types (undirected, directed,
multigraphs)? - How does the algorithm behave with disconnected inputs and graphs which
contain self-loops? - Are there explicit test cases outlined in the literature which can be
incorporated in the test suite?
Doc Developer Projects (`doc/developer/projects.rst`)
Mentored Projects
This page maintains a list of mentored project ideas that contributors can work
on if they are interested in contributing to the NetworkX project. Feel free to
suggest any other idea if you are interested on theNetworkX GitHub discussions page <https://github.com/networkx/networkx/discussions>__
These ideas can be used as projects for Google Summer of Code, Outreachy,
NumFOCUS Small Development Grants and university course/project credits (if
your university allows contribution to open source for credit). Mentee/contributors
participating under NetworkX organisation would be expected to share their weekly
work updates and get feedback in a 1-hr weekly meetings. If this isn't feasible for
the contributor we can discuss further to figure something else out.
If you are a professor interested in having your class develop tools
and contribute the results to NetworkX, we welcome your submissions!
We encourage you to consider rewriting/improving existing functions
as a potential source of projects. Working off of and
improving existing tools involves reading, evaluating and writing code,
rather than just writing new code. We also encourage them to review each
other's PRs. You can have students submit their PRs to your personal fork,
discuss, review, etc in an environment conducive to mentoring and learning.
Once their branch is ready to merge, it can be submitted to the main NetworkX
repository. This will help keep in-class discussions separate from the
broader NetworkX review process, making both more manageable and readable.
Feel free to reach out to use as you plan these activities.
Creating a cookie-cutter backend repository in NetworkX
Abstract: NetworkX has recently incorporated a backend
plugin <https://en.wikipedia.org/wiki/Plug-in_(computing)>__
system based onPython entry-points <https://packaging.python.org/en/latest/specifications/entry-points/>__.
This project aims to develop a template backend repository to help developers
create their own NetworkX backends with ease. The template will clearly distinguish
between the mandatory, optional, and additional features/requirements that a NetworkX
backend package needs to have. We expect this template backend to be forked by the
developers, and then they would only have to add their backend implementation for the
algorithms they want to support at the designated places, and they would not have to
care about setting up all the other aspects of a backend unless they want to enable
or adopt any of the optional or additional functionalities of a backend. You can start by:looking at
nx-j4f <https://github.com/Schefflera-Arboricola/nx-j4f>__
(a dummy backend) andnx-parallel <https://github.com/networkx/nx-parallel>__
(a simple backend) for inspiration.reading and understanding :ref:
backendsand :ref:configsdocumentation.
Feel free to ask questions or open an issue if you find something hard to understand,
as the above documentations are not that well-written.Recommended Skills: Python, willingness to roll up your sleeves and dig deep
and understand the dispatching mechanism in NetworkX, and ability to take feedback
and iterate on your work.Expected Outcome: A "ready-to-fork" and comprehensive backend template in the
NetworkX organization.Expected time commitment: ~350 hours project
Complexity: Medium
Interested Mentors:
@Schefflera-Arboricola <https://github.com/Schefflera-Arboricola>,@dschult <https://github.com/dschult/>
Adding embarrassingly parallel graph algorithms in nx-parallel
Abstract:
nx-parallel <https://github.com/networkx/nx-parallel>__ is a NetworkX
backend that usesjoblib <https://joblib.readthedocs.io/en/latest/index.html>__ for
implementing parallel graph algorithms. Currently, only some of the NetworkXalgorithms are implemented in nx-parallel <https://github.com/networkx/nx-parallel?tab=readme-ov-file#algorithms-in-nx-parallel>.
We expect the contributor to findembarrassingly parallel <https://en.wikipedia.org/wiki/Embarrassingly_parallel>
graph algorithms from the :ref:wide variety of graph algorithms <Algorithms>
implemented in NetworkX and then write their parallel implementations in nx-parallel.
You can start by looking at:the implementations of existing algorithms in nx-parallel for inspiration.
Joblib docs:
Embarrassingly parallel for loops <https://joblib.readthedocs.io/en/latest/parallel.html>__
Find more details in
Issue#82 <https://github.com/networkx/nx-parallel/issues/82>__.Recommended Skills: Python, willingness to roll up your sleeves and dig deep
and understand nx-parallel's infrastructure, and ability to take feedback and
iterate on your work.Expected Outcome: 3 parallel graph algorithms (~175 hours), or 7 (~350 hours),
implemented in nx-parallel.Complexity: Medium
Interested Mentors:
@Schefflera-Arboricola <https://github.com/Schefflera-Arboricola>,@dschult <https://github.com/dschult/>
Pedagogical Interactive Notebooks for Algorithms Implemented in NetworkX
Abstract: NetworkX has a :ref:
wide variety of algorithms <Algorithms>
implemented. Even though the algorithms are well documented, explanations of
the ideas behind the algorithms are often missing and we would like to
collect these, write Jupyter notebooks to elucidate these ideas and explore
the algorithms experimentally, and publish the notebooks at
https://github.com/networkx/notebooks. The goal is to gives readers a
deeper outlook behind standard network science and graph theory algorithms
and encourage them to delve further into the topic.Recommended Skills: Python, Jupyter notebooks, graph algorithms.
Expected Outcome: A collection of Interactive Jupyter notebooks which
explain and explore network algorithms to readers and users of NetworkX.
For example, see this notebook on
:doc:Geometric Generator Models <nx-guides:content/generators/geometric>Complexity: Depending on the algorithms you are interested to work on.
Interested Mentors:
@rossbar <https://github.com/rossbar/>,@Schefflera-Arboricola <https://github.com/Schefflera-Arboricola>Expected time commitment: This project can be either a medium project (~175 hours)
or a large project (~350 hours). The contributor is expected to contribute 2-3
pedagogical interactive notebooks for the medium duration project and 4-5 notebooks
for the long duration project.
Incorporate a Python library for ISMAGs isomorphism calculations
Abstract: A team from Sandia Labs has converted the original java implementation of
the ISMAGS isomorphism routines to Python. They have invited us to incorporate that
code into NetworkX if we are interested. We'd like someone to learn the ISMAGS code
we currently provide, and the code from this new library and figure out what the
best combination is to include in NetworkX moving forward. That could be two separate
subpackages of tools, or more likely a combination of the two sets of code, or a
third incantation that combines good features from each.Recommended Skills: Python, graph algorithms.
Expected Outcome: A plan for how to best incorporate ISMAGS into NetworkX along
with code to do that incorporation.Interested Mentors:
@dschult <https://github.com/dschult/>,@rossbar <https://github.com/rossbar/>Expected time commitment: This project will be a full time 10 week project (~350 hrs).
Centrality Atlas
Abstract: The goal of this project would be to produce a comprehensive review
of network centrality measures.
Centrality is a central concept in network science and has many applications
across domains. NetworkX provides many functions for measuring
various types of :doc:network centrality</reference/algorithms/centrality>.
The individual centrality functions are typically well-described by their
docstrings (though there's always room for improvement!); however, there
currently is no big-picture overview of centrality.
Furthermore, many of the centrality measures are closely related, but there is
no documentation that describes these relationships.Recommended Skills: Python, literature review, technical writing
Expected Outcome: An executable document that provides an overview and applications
of network centrality measures. Potential outputs include (but are not limited
to): an article fornx-guides(see above) and/or an example gallery for centrality
measures.Interested Mentors:
@dschult <https://github.com/dschult/>,@rossbar <https://github.com/rossbar/>,@Schefflera-Arboricola <https://github.com/Schefflera-Arboricola>__Expected time commitment: Variable, though a high-quality review article would
be expected to take several months of dedicated research (~350 hours).
Completed Projects
Revisiting and expanding nx-parallel_- Program: Google Summer of Code 2024
- Contributor:
@Schefflera-Arboricola <https://github.com/Schefflera-Arboricola>__ - Link to Proposal:
GSoC 2024: Revisiting and expanding nx-parallel <https://github.com/networkx/archive/blob/main/proposals-gsoc/GSoC-2024-Revisiting-and-expanding-nx-parallel.pdf>_
Unifying the Visualization Interface for NetworkX- Program: Funded by a grant from CZI (Chan-Zuckerberg Initiative) 2024
- Contributor:
@mjschwenne <https://github.com/mjschwenne>__ - Summary: Refactored existing draw functions to a single function with all drawing
attributes stored in the NetworkX Graph object.
VF2++ algorithm for graph isomorphism_- Program: Google Summer of Code 2022
- Contributor:
@kpetridis24 <https://github.com/kpetridis24/>__ - Link to Proposal:
GSoC 2022: VF2++ Algorithm <https://github.com/networkx/archive/blob/main/proposals-gsoc/GSoC-2022-VF2plusplus-isomorphism.pdf>_
Louvain community detection algorithm_- Program: Google Summer of Code 2021
- Contributor:
@z3y50n <https://github.com/z3y50n/>__ - Link to Proposal:
GSoC 2021: Community Detection Algorithms <https://github.com/networkx/archive/blob/main/proposals-gsoc/GSoC-2021-Community-Detection-Algorithms.pdf>__
Asadpour algorithm for directed travelling salesman problem_- Program: Google Summer of Code 2021
- Contributor:
@mjschwenne <https://github.com/mjschwenne/>__ - Link to Proposal:
GSoC 2021: Asadpour algorithm <https://github.com/networkx/archive/blob/main/proposals-gsoc/GSoC-2021-Asadpour-Asymmetric-Traveling%20Salesman-Problem.pdf>__
Pedagogical notebook:
Directed acyclic graphs and topological sort_- Program: Google Summer of Code 2021
- Contributor:
@vdshk <https://github.com/vdshk>__
Pedagogical notebooks:
Graph assortativity_ &Network flow analysis and Dinitz algorithm_- Program: Google Summer of Code 2021
- Contributor:
@harshal-dupare <https://github.com/harshal-dupare/>__
Add On system for NetworkX:
NetworkX-Metis_- Program: Google Summer of Code 2015
- Contributor:
@OrkoHunter <https://github.com/OrkoHunter/>__ - Link to Proposal:
GSoC 2015: Add On System for NetworkX <https://github.com/networkx/archive/blob/main/proposals-gsoc/GSoC-2015-Add-on-system-for-NetworkX.md>__
NetworkX 2.0 API_- Program: Google Summer of Code 2015
- Contributor:
@MridulS <https://github.com/MridulS/>__ - Link to Proposal:
GSoC 2015: NetworkX 2.0 API <https://github.com/networkx/archive/blob/main/proposals-gsoc/GSoC-2015-NetworkX-2.0-api.md>__
.. _Revisiting and expanding nx-parallel: https://github.com/Schefflera-Arboricola/blogs/tree/main/networkx/GSoC24
.. _VF2++ algorithm for graph isomorphism: https://github.com/networkx/networkx/pull/5788
.. _Louvain community detection algorithm: https://github.com/networkx/networkx/pull/4929
.. _Asadpour algorithm for directed travelling salesman problem: https://github.com/networkx/networkx/pull/4740
.. _Directed acyclic graphs and topological sort: https://github.com/networkx/nx-guides/pull/44
.. _Graph assortativity: https://github.com/networkx/nx-guides/pull/42
.. _Network flow analysis and Dinitz algorithm: https://github.com/networkx/nx-guides/pull/46
.. _NetworkX-Metis: https://github.com/networkx/networkx-metis
.. _NetworkX 2.0 API: https://networkx.org/documentation/latest/release/migration_guide_from_1.x_to_2.0.html
.. Project Idea Template
Abstract:
Recommended Skills:
Expected Outcome:
Complexity;
Interested Mentors:
Doc Developer Release (`doc/developer/release.rst`)
Pre-release checklist
Things to double-check prior to cutting a NetworkX release:
- Ensure that the copyright in
README.rstandLICENSE.txtis
updated to the current year.
Release Process
Set release variables:
.. code-block:: bash
textexport VERSION=<version number> export PREVIOUS=<previous version number> export ORG="networkx" export REPO="networkx"If this is a prerelease:
.. code-block:: bash
textexport NOTES="doc/release/release_dev.rst"If this is release:
.. code-block:: bash
textexport NOTES="doc/release/release_${VERSION}.rst" git rm doc/release/release_dev.rstAutogenerate release notes:
.. code-block:: bash
textchangelist ${ORG}/${REPO} networkx-${PREVIOUS} main --version ${VERSION} --out ${NOTES} --format rst changelist ${ORG}/${REPO} networkx-${PREVIOUS} main --version ${VERSION} --out ${VERSION}.md.. note::
The release notes are generated twice here - the reST version is included in
the documentation, while the markdown version is included with releases
on GitHub.Edit
doc/_static/version_switcher.jsonin order to add the release, move the
key value pair"preferred": trueto the most recent stable version, and commit.
For anrc, skip this step.Update
doc/release/index.rst.Update
__version__innetworkx/__init__.py.Commit changes:
.. code-block:: bash
textgit add networkx/__init__.py ${NOTES} doc/_static/version_switcher.json doc/release/index.rst git commit -m "Designate ${VERSION} release"Add the version number as a tag in git:
.. code-block:: bash
textgit tag -s networkx-${VERSION} -m "signed ${VERSION} tag"Push the new meta-data to github:
.. code-block:: bash
textgit push --tags origin main(where
originis the name of thegithub.com:networkx/networkxrepository.)Review the github release page: https://github.com/networkx/networkx/tags
Update documentation on the web:
.. note::
This step does not apply to rc releases.The documentation is kept in a separate repo:
https://github.com/networkx/documentationWait for the CI service to deploy to GitHub Pages
Sync your branch with the remote repo:
git pull.Copy the documentation built by the CI service.
Assuming you are at the top-level of thedocumentationrepo:.. code-block:: bash
text# FIXME - use eol_banner.html cp -a latest ../networkx-${VERSION} git reset --hard <commit from last release> mv ../networkx-${VERSION} . rm -rf stable cp -rf networkx-${VERSION} stable git add networkx-${VERSION} stable git commit -m "Add ${VERSION} docs" git push # force push---be careful!
Update
__version__innetworkx/__init__.py.
The new version should increment either the patch number or the rc number
depending on whether or not the release is an rc.
For example, if you are releasing versionX.Y, the__version__should
be updated toX.Y.1rc0.dev0.
If instead the release is an rc, then increment the rc number --- for example,
if releasingX.Yrc0, the__version__should be updated toX.Yrc1.dev0.Commit and push changes:
.. code-block:: bash
textgit add networkx/__init__.py git commit -m "Bump release version" git push origin main
Update the web frontpage:
.. note::
This step does not apply to rc releases.The webpage is kept in a separate repo: https://github.com/networkx/website
- Sync your branch with the remote repo:
git pull.
If you try tomake githubwhen your branch is out of sync, it
creates headaches. - Update
build/index.html. - Edit
build/_static/docversions.jsand commit - Push your changes to the repo.
- Deploy using
make github.
- Sync your branch with the remote repo:
Post release notes on mailing list.
Doc Developer Roadmap (`doc/developer/roadmap.rst`)
======= Roadmap
The roadmap is intended for larger, fundamental changes to
the project that are likely to take months or years of developer time.
Smaller-scoped items will continue to be tracked on our issue tracker.
The scope of these improvements means that these changes may be
controversial, are likely to involve significant discussion
among the core development team, and may require the creation
of one or more :ref:nxep.
Installation
We aim to make NetworkX as easy to install as possible.
Some of our dependencies can be tricky to install.
Other of our dependencies are easy to install on the CPython platform, but
may be more involved on other platforms such as PyPy.
Addressing these installation issues may involve working with the external projects.
Sustainability
We aim to reduce barriers to contribution, speed up pull request (PR) review,
onboard new maintainers, and attract new developers to ensure the long-term
sustainability of NetworkX.
This includes:
- improving continuous integration
- making code base more approachable
- creating new pathways beyond volunteer effort
- growing maintainers and leadership
- increasing diversity of developer community
Benchmarks
Speed improvements, lower memory usage, and the ability to parallelize
algorithms are beneficial to most science domains and use cases.
Toward that goal we want a benchmarking system using something
like airspeed velocity (https://asv.readthedocs.io/en/stable/).
See a fairly extensive version of this in benchmarks/benchmarks.
Performance
Individual functions can be optimized for performance and memory use.
We are also interested in exploring new technologies to accelerate
code and reduce memory use. Before adopting any new technologies
we will need to carefully consider its impact on code readability
and difficulty of building and installing NetworkX.
For more information, see our :ref:mission_and_values.
Many functions can be trivially parallelized. nx-parallel
(https://github.com/networkx/nx-parallel) is one possible approach
using backends. Python's new freethreading feature is a powerful
possibility.
Documentation
We’d like to improve the content, structure, and presentation of the NetworkX
documentation. Some specific goals include:
- examples that include short workflows for specific domains
- summary doc pages for suites of functions e.g. community with comparisons of
functions and why you might pick one over another - longer gallery examples or nx-guides, including complete life science workflows
- domain-specific documentation (NetworkX for Geneticists,
NetworkX for Neuroscientists, etc.) probably as nx-guides - examples of how to use NetworkX with other packages, e.g. Cytoscape
Linear Algebra
We would like to improve our linear algebra based algorithms.
This includes investigating SciPy's csgraph and possibly getting SciPy to support
a new sparse array format that uses a NX Graph as storage.
We should also decide how to handle algorithms with multiple implementations
(e.g., some algorithms are implemented in Python, NumPy, and SciPy).
Perhaps we can build off of NumPy's array-api to get e.g. PyTorch in our linalg.
Interoperability
We'd like to improve interoperability with the rest of the scientific Python
ecosystem.
This includes projects we depend on (e.g., NumPy, SciPy, Pandas, Matplotlib)
as well as ones we don't (e.g., Geopandas).
For example, we would also like to be able to seamlessly exchange graphs with
other network analysis software. Perhaps SciPy can support a sparse array format
that uses a NX Graph data structure. Perhaps we can store all node and edge
attributes in a DataFrame without copy.
Another way to integrate with other scientific python ecosystem tools is to
take on features from the other tools that are useful. And we should develop
tools to ease use of NetworkX from within these other tools.
Additional examples of interoperability improvements may include providing a more
pandas-like interface for the __getitem__ dunder function of node and
edge views (:ref:NXEP2).
Also developing a universal method to represent a graph as a single sequence ofnodes_and_edges objects that allow attribute dicts, nodes and edges asdiscussed for graph generators <https://github.com/networkx/networkx/issues/3036>_.
Visualization
Visualization is not a primary focus on NetworkX, but it is a major feature for
many users. We need to enhance the drawing tools for NetworkX. We intend to
evolve to a new display function that enhances both api and performance relative
to the draw functions. We should also enhance docs to make connections with
iplotx and GraphViz.
Doc Developer Values (`doc/developer/values.rst`)
.. _mission_and_values:
================== Mission and Values
Our mission
NetworkX aims to be the reference library for network science algorithms in
Python. We accomplish this by:
- being easy to use and install. We are careful in taking on new
dependencies, and sometimes cull existing ones, or make them optional. All
functions in our API have thorough docstrings clarifying expected inputs and
outputs. - providing a consistent API. Conceptually identical arguments have the
same name and position in a function signature. - ensuring correctness. Test coverage is close to 100% and code is reviewed by
at least two core developers before being included in the library. - caring for users’ data. We have a functional API and don't modify
input data unless explicitly directed to do so. - promoting education in network science, with extensive pedagogical
documentation.
Our values
- We are inclusive (:ref:
code_of_conduct). We welcome and mentor newcomers who are
making their first contribution. - We are open source and community-driven (:ref:
governance). - We focus on graph data structures and algorithms for network science applications.
- We prefer pure Python implementations using native data structures
(especially dicts) due to their consistent, intuitive interface and amazing
performance capabilities. We include interfaces to other data structures,
especially NumPy arrays and SciPy sparse matrices for algorithms that more
naturally use arrays and matrices or where time or space requirements are
significantly lower. Sometimes we provide two algorithms for the same result,
one using each data structure, when pedagogy or space/time trade-offs justify
such multiplicity. - We value simple, readable implementations over getting every last ounce of
performance. Readable code that is easy to understand, for newcomers and
maintainers alike, makes it easier to contribute new code as well as prevent
bugs. This means that we will prefer a 20% slowdown if it reduces lines of
code two-fold, for example. - We value education and documentation. All functions should have
NumPy-style docstrings <https://numpy.org/doc/stable/docs/howto_document.html>,
preferably with examples, as well as gallery examples that showcase how that
function is used in a scientific application.
Acknowledgments
This document is modified from the scikit-image mission and values document.
Doc Reference Backends (`doc/reference/backends.rst`)
Backends
NetworkX can be configured to use separate thrid-party backends to improve
performance and add functionality. Backends are optional, installed separately,
and can be enabled either directly in the user's code or through environment
variables.
.. note:: The interface used by developers creating custom NetworkX backends is
receiving frequent updates and improvements. Participating in weekly
NetworkX dispatch meetings <https://scientific-python.org/calendars/networkx.ics>_ is an excellent way
to stay updated and contribute to the ongoing discussions.
Docs for backend users
NetworkX utilizes a plugin-dispatch architecture. A valid NetworkX backend
specifies `entry points
<https://packaging.python.org/en/latest/specifications/entry-points>`_, named
``networkx.backends`` and an optional ``networkx.backend_info`` when it is
installed (not imported). This allows NetworkX to dispatch (redirect) function
calls to the backend so the execution flows to the designated backend
implementation. This design enhances flexibility and integration, making
NetworkX more adaptable and efficient.
NetworkX can dispatch to backends **explicitly** (this requires changing code)
or **automatically** (this requires setting configuration or environment
variables). The best way to use a backend depends on the backend, your use
case, and whether you want to automatically convert to or from backend
graphs. Automatic conversions of graphs is always opt-in.
To explicitly dispatch to a backend, use the ``backend=`` keyword argument in a
dispatchable function. This will convert (and cache by default) input NetworkX
graphs to backend graphs and call the backend implementation.
Another explicit way to use a backend is to create a backend graph directly.
Graph classes support the ``backend=`` keyword argument to create a backend
graph such as ``nx.Graph(backend=...)``, and backends may have their own
functions for loading data and creating graphs that you can use. Passing a
backend graph to a dispatchable function will call the backend implementation
without converting.
Using automatic dispatch requires setting configuration options. Every NetworkX
configuration may also be set from an environment variable and are processed at
the time networkx is imported.
.. important::
Environment variables (like ``NETWORKX_BACKEND_PRIORITY``) are read at import-time.
Modifying the environment (e.g. setting
``os.environ["NETWORKX_BACKEND_PRIORITY"]``) after importing networkx has no effect.
The following configuration variables are supported:
* ``nx.config.backend_priority`` (``NETWORKX_BACKEND_PRIORITY`` env var), a
list of backends, controls dispatchable functions that don't return graphs
such as e.g. ``nx.pagerank``. When one of these functions is called with
NetworkX graphs as input, the dispatcher iterates over the backends listed in
this backend_priority config and will use the first backend that implements
this function. The input NetworkX graphs are converted (and cached by
default) to backend graphs. Using this configuration can allow you to use the
full flexibility of NetworkX graphs and the performance of backend
implementations, but possible downsides are that creating NetworkX graphs,
converting to backend graphs, and caching backend graphs may all be
expensive.
* ``nx.config.backend_priority.algos`` (``NETWORKX_BACKEND_PRIORITY_ALGOS`` env
var), can be used instead of ``nx.config.backend_priority``
(``NETWORKX_BACKEND_PRIORITY`` env var) to emphasize that the setting only
affects the dispatching of algorithm functions as described above.
* ``nx.config.backend_priority.generators``
(``NETWORKX_BACKEND_PRIORITY_GENERATORS`` env var), a list of backends,
controls dispatchable functions that return graphs such as
nx.from_pandas_edgelist and nx.empty_graph. When one of these functions is
called, the first backend listed in this backend_priority config that
implements this function will be used and will return a backend graph. When
this backend graph is passed to other dispatchable NetworkX functions, it
will use the backend implementation if it exists or raise by default unless
nx.config.fallback_to_nx is True (default is False). Using this configuration
avoids creating NetworkX graphs, which subsequently avoids the need to
convert to and cache backend graphs as when using
nx.config.backend_priority.algos, but possible downsides are that the backend
graph may not behave the same as a NetworkX graph and the backend may not
implement all algorithms that you use, which may break your workflow.
* ``nx.config.backend_priority.classes``
(``NETWORKX_BACKEND_PRIORITY_CLASSES`` env var), a list of backends,
controls graph classes. For example, this allows ``nx.Graph(data)`` to
create a backend graph. Advantages and disadvantages of this are similar
to ``nx.config.backend_priority.generators`` (see above).
* ``nx.config.fallback_to_nx`` (``NETWORKX_FALLBACK_TO_NX`` env var), a boolean
(default False), controls what happens when a backend graph is passed to a
dispatchable function that is not implemented by that backend. The default
behavior when False is to raise. If True, then the backend graph will be
converted (and cached by default) to a NetworkX graph and will run with the
default NetworkX implementation. Enabling this configuration can allow
workflows to complete if the backend does not implement all algorithms used
by the workflow, but a possible downside is that it may require converting
the input backend graph to a NetworkX graph, which may be expensive. If a
backend graph is duck-type compatible as a NetworkX graph, then the backend
may choose not to convert to a NetworkX graph and use the incoming graph
as-is.
* ``nx.config.cache_converted_graphs`` (``NETWORKX_CACHE_CONVERTED_GRAPHS`` env
var), a boolean (default True), controls whether graph conversions are cached
to G.__networkx_cache__ or not. Caching can improve performance by avoiding
repeated conversions, but it uses more memory.
.. note:: Backends *should* follow the NetworkX backend naming convention. For
example, if a backend is named ``parallel`` and specified using
``backend=parallel`` or ``NETWORKX_BACKEND_PRIORITY=parallel``, the package
installed is ``nx-parallel``, and we would use ``import nx_parallel`` if we
were to import the backend package directly.
Backends are encouraged to document how they recommend to be used and whether
their graph types are duck-type compatible as NetworkX graphs. If backend
graphs are NetworkX-compatible and you want your workflow to automatically
"just work" with a backend--converting and caching if necessary--then use all
of the above configurations. Automatically converting graphs is opt-in, and
configuration gives the user control.
Examples:
---------
Use the ``cugraph`` backend for every algorithm function it supports. This will
allow for fall back to the default NetworkX implementations for algorithm calls
not supported by cugraph because graph generator functions are still returning
NetworkX graphs.
.. code-block:: bash
bash> NETWORKX_BACKEND_PRIORITY=cugraph python my_networkx_script.py
Explicitly use the ``parallel`` backend for a function call.
.. code-block:: python
nx.betweenness_centrality(G, k=10, backend="parallel")
Explicitly use the ``parallel`` backend for a function call by passing an
instance of the backend graph type to the function.
.. code-block:: python
H = nx_parallel.ParallelGraph(G)
nx.betweenness_centrality(H, k=10)
Explicitly use the ``parallel`` backend and pass additional backend-specific
arguments. Here, ``get_chunks`` is an argument unique to the ``parallel``
backend.
.. code-block:: python
nx.betweenness_centrality(G, k=10, backend="parallel", get_chunks=get_chunks)
Automatically dispatch the ``cugraph`` backend for all NetworkX algorithms and
generators, and allow the backend graph object returned from generators to be
passed to NetworkX functions the backend does not support.
.. code-block:: bash
bash> NETWORKX_BACKEND_PRIORITY_ALGOS=cugraph \\
NETWORKX_BACKEND_PRIORITY_GENERATORS=cugraph \\
NETWORKX_FALLBACK_TO_NX=True \\
python my_networkx_script.py
How does this work?
-------------------
If you've looked at functions in the NetworkX codebase, you might have seen the
``@nx._dispatchable`` decorator on most of the functions. This decorator allows the NetworkX
function to dispatch to the corresponding backend function if available. When the decorated
function is called, it first checks for a backend to run the function, and if no appropriate
backend is specified or available, it runs the NetworkX version of the function.
Backend Keyword Argument
^^^^^^^^^^^^^^^^^^^^^^^^
When a decorated function is called with the ``backend`` kwarg provided, it checks
if the specified backend is installed, and loads it. Next it checks whether to convert
input graphs by first resolving the backend of each input graph by looking
for an attribute named ``__networkx_backend__`` that holds the backend name for that
graph type. If all input graphs backend matches the ``backend`` kwarg, the backend's
function is called with the original inputs. If any of the input graphs do not match
the ``backend`` kwarg, they are converted to the backend graph type before calling.
Exceptions are raised if any step is not possible, e.g. if the backend does not
implement this function.
Finding a Backend
^^^^^^^^^^^^^^^^^
When a decorated function is called without a ``backend`` kwarg, it tries to find a
dispatchable backend function.
The backend type of each input graph parameter is resolved (using the
``__networkx_backend__`` attribute) and if they all agree, that backend's function
is called if possible. Otherwise the backends listed in the config ``backend_priority``
are considered one at a time in order. If that backend supports the function and
can convert the input graphs to its backend type, that backend function is called.
Otherwise the next backend is considered.
During this process, the backends can provide helpful information to the dispatcher
via helper methods in the backend's interface. Backend methods ``can_run`` and
``should_run`` are used by the dispatcher to determine whether to use the backend
function. If the number of nodes is small, it might be faster to run the NetworkX
version of the function. This is how backends can provide info about whether to run.
Falling Back to NetworkX
^^^^^^^^^^^^^^^^^^^^^^^^
If none of the backends are appropriate, we "fall back" to the NetworkX function.
That means we resolve the backends of all input graphs and if all are NetworkX
graphs we call the NetworkX function. If any are not NetworkX graphs, we raise
an exception unless the `fallback_to_nx` config is set. If it is, we convert all
graph types to NetworkX graph types before calling the NetworkX function.
Functions that mutate the graph
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Any function decorated with the option that indicates it mutates the graph goes through
a slightly different path to automatically find backends. These functions typically
generate a graph, or add attributes or change the graph structure. The config
`backend_priority.generators` holds a list of backend names similar to the config
`backend_priority`. The process is similar for finding a matching backend. Once found,
the backend function is called and a backend graph is returned (instead of a NetworkX
graph). You can then use this backend graph in any function supported by the backend.
And you can use it for functions not supported by the backend if you set the config
`fallback_to_nx` to allow it to convert the backend graph to a NetworkX graph before
calling the function.
Optional keyword arguments
^^^^^^^^^^^^^^^^^^^^^^^^^^
Backends can add optional keyword parameters to NetworkX functions to allow you to
control aspects of the backend algorithm. Thus the function signatures can be extended
beyond the NetworkX function signature. For example, the ``parallel`` backend might
have a parameter to specify how many CPUs to use. These parameters are collected
by the dispatchable decorator code at the start of the function call and used when
calling the backend function.
Existing Backends
^^^^^^^^^^^^^^^^^
NetworkX does not know all the backends that have been created. In fact, the
NetworkX library does not need to know that a backend exists for it to work. As
long as the backend package creates the ``entry_point``, and provides the
correct interface, it will be called when the user requests it using one of the
three approaches described above. Some backends have been working with the
NetworkX developers to ensure smooth operation.
Refer to the :doc:`/backends` section to see a list of available backends known
to work with the current stable release of NetworkX.
.. _introspect:
Introspection and Logging
-------------------------
Introspection techniques aim to demystify dispatching and backend graph conversion behaviors.
The primary way to see what the dispatch machinery is doing is by enabling logging.
This can help you verify that the backend you specified is being used.
You can enable NetworkX's backend logger to print to ``sys.stderr`` like this::
import logging
nxl = logging.getLogger("networkx")
nxl.addHandler(logging.StreamHandler())
nxl.setLevel(logging.DEBUG)
And you can disable it by running this::
nxl.setLevel(logging.CRITICAL)
Refer to :external+python:mod:`logging` to learn more about the logging facilities in Python.
By looking at the ``.backends`` attribute, you can get the set of all currently
installed backends that implement a particular function. For example::
>>> nx.betweenness_centrality.backends # doctest: +SKIP
{'parallel'}
The function docstring will also show which installed backends support it
along with any backend-specific notes and keyword arguments::
>>> help(nx.betweenness_centrality) # doctest: +SKIP
...
Backends
--------
parallel : Parallel backend for NetworkX algorithms
The parallel computation is implemented by dividing the nodes into chunks
and computing betweenness centrality for each chunk concurrently.
...
The NetworkX documentation website also includes info about trusted backends of NetworkX in function references.
For example, see :func:`~networkx.algorithms.shortest_paths.weighted.all_pairs_bellman_ford_path_length`.
Introspection capabilities are currently limited, but we are working to improve them.
We plan to make it easier to answer questions such as:
- What happened (and why)?
- What *will* happen (and why)?
- Where was time spent (including conversions)?
- What is in the cache and how much memory is it using?
Transparency is essential to allow for greater understanding, debug-ability,
and customization. After all, NetworkX dispatching is extremely flexible and can
support advanced workflows with multiple backends and fine-tuned configuration,
but introspection can be helpful by describing *when* and *how* to evolve your workflow
to meet your needs. If you have suggestions for how to improve introspection, please
`let us know <https://github.com/networkx/networkx/issues/new>`_!
Docs for backend developersCreating a custom backend
Defining a
BackendInterfaceobject:Note that the
BackendInterfacedoesn't need to be a class. It can be an
instance of a class, or a module as well. You can define the following methods or
functions in your backend'sBackendInterfaceobject.:convert_from_nxandconvert_to_nxmethods or functions are required for
backend dispatching to work. The arguments toconvert_from_nxare:G: NetworkX Graphedge_attrs: dict, optional
Dictionary mapping edge attributes to default values if missing inG.
If None, then no edge attributes will be converted and default may be 1.node_attrs: dict, optional
Dictionary mapping node attributes to default values if missing inG.
If None, then no node attributes will be converted.preserve_edge_attrs: bool
Whether to preserve all edge attributes.preserve_node_attrs: bool
Whether to preserve all node attributes.preserve_graph_attrs: bool
Whether to preserve all graph attributes.preserve_all_attrs: bool
Whether to preserve all graph, node, and edge attributes.name: str
The name of the algorithm.graph_name: str
The name of the graph argument being converted.
can_run(Optional):
If your backend only partially implements an algorithm, you can define
acan_run(name, args, kwargs)function in yourBackendInterfaceobject that
returns True or False indicating whether the backend can run the algorithm with
the given arguments or not. Instead of a boolean you can also return a string
message to inform the user why that algorithm can't be run.should_run(Optional):
A backend may also defineshould_run(name, args, kwargs)
that is similar tocan_run, but answers whether the backend should be run.
should_runis only run when performing backend graph conversions. Like
can_run, it receives the original arguments so it can decide whether it
should be run by inspecting the arguments.can_runruns before
should_run, soshould_runmay assumecan_runis True. If not
implemented by the backend,can_runandshould_runare assumed to
always return True if the backend implements the algorithm.on_start_tests(Optional):
A specialon_start_tests(items)function may be defined by the backend.
It will be called with the list of NetworkX tests discovered. Each item
is a test object that can be marked as xfail if the backend does not support
the test usingitem.add_marker(pytest.mark.xfail(reason=...)).
Adding entry points
To be discoverable by NetworkX, your package must register an
entry-point <https://packaging.python.org/en/latest/specifications/entry-points>_networkx.backendsin the package's metadata, with akey pointing to your dispatch object <https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/#using-package-metadata>_ .
For example, if you are usingsetuptoolsto manage your backend package,
you canadd the following to your pyproject.toml file <https://setuptools.pypa.io/en/latest/userguide/entry_point.html>_::text[project.entry-points."networkx.backends"] backend_name = "your_backend_interface_object"You can also add the
backend_infoentry-point. It points towards theget_info
function that returns all the backend information, which is then used to build the
"Additional Backend Implementation" box at the end of algorithm's documentation
page. Note that theget_infofunction shouldn't import your backend package.::text[project.entry-points."networkx.backend_info"] backend_name = "your_get_info_function"The
get_infoshould return a dictionary with following key-value pairs:
-backend_name: str or None
It is the name passed in thebackendkwarg and must be a valid Python identifier.
-project: str or None
The name of your backend project.
-package: str or None
The name of your backend package.
-url: str or None
This is the url to either your backend's codebase or documentation, and
will be displayed as a hyperlink to thebackend_name, in the
"Additional backend implementations" section.
-short_summary: str or None
One line summary of your backend which will be displayed in the
"Additional backend implementations" section.
-default_config: dict
A dictionary mapping the backend config parameter names to their default values.
This is used to automatically initialize the default configs for all the
installed backends at the time of networkx's import.
.. seealso::~networkx.utils.configs.Config
-functions: dict or None
A dictionary mapping function names to a dictionary of information
about the function. The information can include the following keys:
-url: str or None
The url tofunction's source code or documentation.
-additional_docs: str or None
A short description or note about the backend function's
implementation.
-additional_parameters: dict or None
A dictionary mapping additional parameters headers to their
short descriptions. For example::
"additional_parameters": {
'param1 : str, function (default = "chunks")' : "...",
'param2 : int' : "...",
}
If any of these keys are not present, the corresponding information
will not be displayed in the "Additional backend implementations"
section on NetworkX docs website.
Note that your backend's docs would only appear on the official NetworkX docs only
if your backend is a trusted backend of NetworkX, and is present in the.circleci/config.ymland.github/workflows/deploy-docs.ymlfiles in the
NetworkX repository.Defining a Backend Graph class
The backend must create an object with an attribute
__networkx_backend__that holds
a string with the entry point name, which must be a valid Python identifier::textclass BackendGraph: __networkx_backend__ = "backend_name" ...Backend graph objects are also required to implement the methods
is_directed()andis_multigraph(). These methods return boolean values indicating the type of the graph:is_directed()should return True if the graph is directed, and False otherwise.is_multigraph()should return True if the graph allows multiple (parallel) edges
between node pairs, and False otherwise.
These methods are used by NetworkX utilities such as the
@not_implemented_fordecorator
to determine whether a graph meets certain type constraints and to raise an error if the
function is not applicable to that graph type... note::
Decorators such as
@not_implemented_forin networkx are applied prior to dispatching.
Backend implementations can assume that graph-type constraints have
already been validated.A backend graph instance may have a
G.__networkx_cache__dict to enable
caching, and care should be taken to clear the cache when appropriate.
Testing the Custom backend
To test your custom backend, you can run the NetworkX test suite on your backend.
This also ensures that the custom backend is compatible with NetworkX's API.
The following steps will help you run the tests:
Setting Backend Environment Variables:
NETWORKX_TEST_BACKEND: Setting this to your backend'sbackend_namewill
let NetworkX's dispatch machinery to automatically convert a regular NetworkXGraph,DiGraph,MultiGraph, etc. to their backend equivalents, usingyour_backend_interface_object.convert_from_nx(G, ...)function.NETWORKX_FALLBACK_TO_NX(default=False) : Setting this variable toTruewill
instruct tests to use a NetworkXGraphfor algorithms not implemented by your
custom backend. Setting this toFalsewill only run the tests for algorithms
implemented by your custom backend and tests for other algorithms willxfail.
Running Tests:
You can invoke NetworkX tests for your custom backend with the following commands::textNETWORKX_TEST_BACKEND=<backend_name> NETWORKX_FALLBACK_TO_NX=True # or False pytest --pyargs networkx
How tests are run?
While dispatching to the backend implementation the
_convert_and_callfunction
is used and while testing the_convert_and_call_for_testsfunction is used.
Other than testing it also checks for functions that return numpy scalars, and
for functions that return graphs it runs the backend implementation and the
networkx implementation and then converts the backend graph into a NetworkX graph
and then compares them, and returns the networkx graph. This can be regarded as
(pragmatic) technical debt. We may replace these checks in the future.Conversions while running tests:
- Convert NetworkX graphs using
<your_backend_interface_object>.convert_from_nx(G, ...)into
the backend graph. - Pass the backend graph objects to the backend implementation of the algorithm.
- Convert the result back to a form expected by NetworkX tests using
<your_backend_interface_object>.convert_to_nx(result, ...). - For nx_loopback, the graph is copied using the dispatchable metadata
- Convert NetworkX graphs using
Dispatchable algorithms that are not implemented by the backend
will cause apytest.xfail, when theNETWORKX_FALLBACK_TO_NX
environment variable is set toFalse, giving some indication that
not all tests are running, while avoiding causing an explicit failure.
.. automodule:: networkx.utils.backends
.. autosummary::
:toctree: generated/
_dispatchable
Doc Reference Configs (`doc/reference/configs.rst`)
.. _configs:
Configs
Configs provide library-level storage of configuration settings. These settings
can be made in code or from environment variables.
.. automodule:: networkx.utils.configs
.. autoclass:: config
.. autoclass:: NetworkXConfig
.. autoclass:: Config
Doc Reference Convert (`doc/reference/convert.rst`)
Converting to and from other data formats
.. currentmodule:: networkx
To NetworkX Graph
.. automodule:: networkx.convert
.. autosummary::
:toctree: generated/
to_networkx_graph
Dictionaries
.. autosummary::
:toctree: generated/
to_dict_of_dicts
from_dict_of_dicts
Lists
.. autosummary::
:toctree: generated/
to_dict_of_lists
from_dict_of_lists
to_edgelist
from_edgelist
Numpy
.. automodule:: networkx.convert_matrix
.. autosummary::
:toctree: generated/
to_numpy_array
from_numpy_array
Scipy
.. autosummary::
:toctree: generated/
to_scipy_sparse_array
from_scipy_sparse_array
Pandas
.. autosummary::
:toctree: generated/
to_pandas_adjacency
from_pandas_adjacency
to_pandas_edgelist
from_pandas_edgelist
Doc Reference Drawing (`doc/reference/drawing.rst`)
.. _drawing:
Drawing
NetworkX provides basic functionality for visualizing graphs, but its main goal
is to enable graph analysis rather than perform graph visualization. In the
future, graph visualization functionality may be removed from NetworkX or only
available as an add-on package.
Proper graph visualization is hard, and we highly recommend that people
visualize their graphs with tools dedicated to that task. Notable examples of
dedicated and fully-featured graph visualization tools areCytoscape <http://www.cytoscape.org/>,Gephi <https://gephi.org/>,Graphviz <http://www.graphviz.org/>,Hiveplotlib <https://hiveplotlib.readthedocs.io/>,iplotx <https://iplotx.readthedocs.io/>_ and, forLaTeX <http://www.latex-project.org/>_ typesetting,PGF/TikZ <https://github.com/pgf-tikz/pgf/>_.
To use these and other such tools, you should export your NetworkX graph into
a format that can be read by those tools. For example, Cytoscape can read the
GraphML format, and so, networkx.write_graphml(G, path) might be an appropriate
choice.
.. tip::
iplotx and hiveplotlib accept NetworkX native data structures without
exporting to a file. An example of each is provided below.
More information on the features provided here are available at
- matplotlib: http://matplotlib.org/
- pygraphviz: http://pygraphviz.github.io/
- iplotx: https://iplotx.readthedocs.io/
- hiveplotlib: https://hiveplotlib.readthedocs.io/
Matplotlib
.. automodule:: networkx.drawing.nx_pylab
.. autosummary::
:toctree: generated/
display
apply_matplotlib_colors
draw
draw_networkx
draw_networkx_nodes
draw_networkx_edges
draw_networkx_labels
draw_networkx_edge_labels
draw_bipartite
draw_circular
draw_kamada_kawai
draw_planar
draw_random
draw_spectral
draw_spring
draw_shell
Matplotlib with iplotx
Draw networks with matplotlib, using iplotx for extended styling options.
Examples
.. code-block:: python
import iplotx as ipx
G = nx.cycle_graph(5, create_using=nx.DiGraph)
layout = nx.circular_layout(G)
ipx.network(G, layout=layout, vertex_facecolor=["tomato", "gold"])
See Also
iplotx <https://iplotx.readthedocs.io/>_iplotx.network <https://iplotx.readthedocs.io/en/latest/api/plotting.html#plotting-api>_
Hive Plots with Hiveplotlib
hiveplotlib draws hive plots, a layout that places nodes on a few radial axes
by a partition variable and orders them along each axis by a chosen sorting variable.
Positions are determined by the data rather than a layout algorithm, so the result is
reproducible and makes structural properties of the graph directly legible. A
NetworkX graph can be passed directly, and Networkx node and edge metrics
(such as node pagerank) can be computed on the fly to drive the layout.
Examples
.. code-block:: python
from hiveplotlib import HivePlot
p = [[0.3, 0.005, 0.0],
... [0.005, 0.3, 0.03],
... [0.0, 0.03, 0.3]]
G = nx.stochastic_block_model(sizes=[15, 15, 15], p=p, seed=0)
hp = HivePlot(
... graph=G,
... partition_variable="block",
... sorting_variables="pagerank",
... node_graph_metrics="pagerank",
... repeat_axes=True,
... )
hp.plot()
By default, hiveplotlib uses Matplotlib for rendering, but hive plots can also be
easily rendered with Bokeh, Plotly, and HoloViews. They can also be rasterized with
Datashader for larger networks.
See Also
Hiveplotlib <https://hiveplotlib.readthedocs.io/>_Creating hive plots from NetworkX <https://hiveplotlib.readthedocs.io/stable/notebooks/creating_hive_plots_from_networkx.html>_Computing graph metrics <https://hiveplotlib.readthedocs.io/stable/notebooks/computing_graph_metrics.html>_Visualizing with other backends <https://hiveplotlib.readthedocs.io/stable/notebooks/hive_plot_viz_outside_matplotlib.html>_Hive plots for large networks <https://hiveplotlib.readthedocs.io/stable/notebooks/hive_plots_for_large_networks.html>_
Graphviz AGraph (dot)
.. automodule:: networkx.drawing.nx_agraph
.. autosummary::
:toctree: generated/
from_agraph
to_agraph
write_dot
read_dot
graphviz_layout
pygraphviz_layout
Graphviz with pydot
.. automodule:: networkx.drawing.nx_pydot
.. autosummary::
:toctree: generated/
from_pydot
to_pydot
write_dot
read_dot
graphviz_layout
pydot_layout
Graph Layout
.. automodule:: networkx.drawing.layout
.. autosummary::
:toctree: generated/
arf_layout
bipartite_layout
bfs_layout
circular_layout
forceatlas2_layout
kamada_kawai_layout
planar_layout
random_layout
rescale_layout
rescale_layout_dict
shell_layout
spring_layout
spectral_layout
spiral_layout
multipartite_layout
LaTeX Code
.. automodule:: networkx.drawing.nx_latex
.. autosummary::
:toctree: generated/
to_latex_raw
to_latex
write_latex
Doc Reference Exceptions (`doc/reference/exceptions.rst`)
Exceptions
.. automodule:: networkx.exception
.. currentmodule:: networkx
.. autoclass:: networkx.NetworkXException
.. autoclass:: networkx.NetworkXError
.. autoclass:: networkx.NetworkXPointlessConcept
.. autoclass:: networkx.NetworkXAlgorithmError
.. autoclass:: networkx.NetworkXUnfeasible
.. autoclass:: networkx.NetworkXNoPath
.. autoclass:: networkx.NetworkXNoCycle
.. autoclass:: networkx.NodeNotFound
.. autoclass:: networkx.HasACycle
.. autoclass:: networkx.NetworkXUnbounded
.. autoclass:: networkx.NetworkXNotImplemented
.. autoclass:: networkx.AmbiguousSolution
.. autoclass:: networkx.ExceededMaxIterations
.. autoclass:: networkx.PowerIterationFailedConvergence
Doc Reference Functions (`doc/reference/functions.rst`)
Functions
.. automodule:: networkx.classes.function
Graph
.. autosummary::
:toctree: generated/
degree
degree_histogram
density
create_empty_copy
is_directed
to_directed
to_undirected
is_empty
add_star
add_path
add_cycle
subgraph
induced_subgraph
restricted_view
edge_subgraph
Nodes
.. autosummary::
:toctree: generated/
nodes
number_of_nodes
neighbors
all_neighbors
non_neighbors
common_neighbors
Edges
.. autosummary::
:toctree: generated/
edges
number_of_edges
non_edges
Self loops
.. autosummary::
:toctree: generated/
selfloop_edges
number_of_selfloops
nodes_with_selfloops
Attributes
.. autosummary::
:toctree: generated/
is_weighted
is_negatively_weighted
set_node_attributes
get_node_attributes
set_edge_attributes
get_edge_attributes
Paths
.. autosummary::
:toctree: generated/
is_path
path_weight
Freezing graph structure
.. autosummary::
:toctree: generated/
freeze
is_frozen
Doc Reference Generators (`doc/reference/generators.rst`)
.. _generators:
Graph generators
.. currentmodule:: networkx
Atlas
.. automodule:: networkx.generators.atlas
.. autosummary::
:toctree: generated/
graph_atlas
graph_atlas_g
Classic
.. automodule:: networkx.generators.classic
.. autosummary::
:toctree: generated/
balanced_tree
barbell_graph
binomial_tree
complete_graph
complete_multipartite_graph
circular_ladder_graph
circulant_graph
cycle_graph
dorogovtsev_goltsev_mendes_graph
empty_graph
full_rary_tree
kneser_graph
ladder_graph
lollipop_graph
null_graph
path_graph
star_graph
tadpole_graph
trivial_graph
turan_graph
wheel_graph
Expanders
.. automodule:: networkx.generators.expanders
.. autosummary::
:toctree: generated/
margulis_gabber_galil_graph
chordal_cycle_graph
paley_graph
maybe_regular_expander
is_regular_expander
random_regular_expander_graph
Lattice
.. automodule:: networkx.generators.lattice
.. autosummary::
:toctree: generated/
grid_2d_graph
grid_graph
hexagonal_lattice_graph
hypercube_graph
triangular_lattice_graph
Small
.. automodule:: networkx.generators.small
.. autosummary::
:toctree: generated/
LCF_graph
bull_graph
chvatal_graph
cubical_graph
desargues_graph
diamond_graph
dodecahedral_graph
frucht_graph
generalized_petersen_graph
heawood_graph
hoffman_singleton_graph
house_graph
house_x_graph
icosahedral_graph
krackhardt_kite_graph
moebius_kantor_graph
octahedral_graph
pappus_graph
petersen_graph
sedgewick_maze_graph
shrikhande_graph
tetrahedral_graph
truncated_cube_graph
truncated_tetrahedron_graph
tutte_graph
Random Graphs
.. automodule:: networkx.generators.random_graphs
.. autosummary::
:toctree: generated/
fast_gnp_random_graph
gnp_random_graph
dense_gnm_random_graph
gnm_random_graph
erdos_renyi_graph
binomial_graph
newman_watts_strogatz_graph
watts_strogatz_graph
connected_watts_strogatz_graph
random_regular_graph
barabasi_albert_graph
dual_barabasi_albert_graph
extended_barabasi_albert_graph
powerlaw_cluster_graph
random_kernel_graph
random_k_lift
random_lobster_graph
random_shell_graph
random_powerlaw_tree
random_powerlaw_tree_sequence
Duplication Divergence
.. automodule:: networkx.generators.duplication
.. autosummary::
:toctree: generated/
duplication_divergence_graph
partial_duplication_graph
Degree Sequence
.. automodule:: networkx.generators.degree_seq
.. autosummary::
:toctree: generated/
configuration_model
directed_configuration_model
expected_degree_graph
havel_hakimi_graph
directed_havel_hakimi_graph
degree_sequence_tree
random_degree_sequence_graph
Random Clustered
.. automodule:: networkx.generators.random_clustered
.. autosummary::
:toctree: generated/
random_clustered_graph
Directed
.. automodule:: networkx.generators.directed
.. autosummary::
:toctree: generated/
gn_graph
gnr_graph
gnc_graph
random_k_out_graph
scale_free_graph
Geometric
.. automodule:: networkx.generators.geometric
.. autosummary::
:toctree: generated/
geometric_edges
geographical_threshold_graph
navigable_small_world_graph
random_geometric_graph
soft_random_geometric_graph
thresholded_random_geometric_graph
waxman_graph
geometric_soft_configuration_graph
Line Graph
.. automodule:: networkx.generators.line
.. autosummary::
:toctree: generated/
line_graph
inverse_line_graph
Ego Graph
.. automodule:: networkx.generators.ego
.. autosummary::
:toctree: generated/
ego_graph
Stochastic
.. automodule:: networkx.generators.stochastic
.. autosummary::
:toctree: generated/
stochastic_graph
AS graph
.. automodule:: networkx.generators.internet_as_graphs
.. autosummary::
:toctree: generated/
random_internet_as_graph
Intersection
.. automodule:: networkx.generators.intersection
.. autosummary::
:toctree: generated/
uniform_random_intersection_graph
k_random_intersection_graph
general_random_intersection_graph
Social Networks
.. automodule:: networkx.generators.social
.. autosummary::
:toctree: generated/
karate_club_graph
davis_southern_women_graph
florentine_families_graph
les_miserables_graph
Community
.. automodule:: networkx.generators.community
.. autosummary::
:toctree: generated/
caveman_graph
connected_caveman_graph
gaussian_random_partition_graph
LFR_benchmark_graph
planted_partition_graph
random_partition_graph
relaxed_caveman_graph
ring_of_cliques
stochastic_block_model
windmill_graph
Spectral
.. automodule:: networkx.generators.spectral_graph_forge
.. autosummary::
:toctree: generated/
spectral_graph_forge
Trees
.. automodule:: networkx.generators.trees
.. autosummary::
:toctree: generated/
prefix_tree
random_labeled_tree
random_labeled_rooted_tree
random_labeled_rooted_forest
random_unlabeled_tree
random_unlabeled_rooted_tree
random_unlabeled_rooted_forest
Non Isomorphic Trees
.. automodule:: networkx.generators.nonisomorphic_trees
.. autosummary::
:toctree: generated/
nonisomorphic_trees
number_of_nonisomorphic_trees
Triads
.. automodule:: networkx.generators.triads
.. autosummary::
:toctree: generated/
triad_graph
Joint Degree Sequence
.. automodule:: networkx.generators.joint_degree_seq
.. autosummary::
:toctree: generated/
is_valid_joint_degree
joint_degree_graph
is_valid_directed_joint_degree
directed_joint_degree_graph
Mycielski
.. automodule:: networkx.generators.mycielski
.. autosummary::
:toctree: generated/
mycielskian
mycielski_graph
Harary Graph
.. automodule:: networkx.generators.harary_graph
.. autosummary::
:toctree: generated/
hnm_harary_graph
hkn_harary_graph
Cographs
.. automodule:: networkx.generators.cographs
.. autosummary::
:toctree: generated/
random_cograph
Interval Graph
.. automodule:: networkx.generators.interval_graph
.. autosummary::
:toctree: generated/
interval_graph
Sudoku
.. automodule:: networkx.generators.sudoku
.. autosummary::
:toctree: generated/
sudoku_graph
Time Series
.. automodule:: networkx.generators.time_series
.. autosummary::
:toctree: generated/
visibility_graph
Doc Reference Glossary (`doc/reference/glossary.rst`)
.. _glossary:
Glossary
.. glossary::
dictionary
A Python dictionary maps keys to values. Also known as "hashes",
or "associative arrays" in other programming languages.
See :ref:the Python tutorial on dictionaries <tut-dictionaries>.
edge
Edges are either two-tuples of nodes (u, v) or three tuples of nodes
with an edge attribute dictionary (u, v, dict).
ebunch
An iterable container of edge tuples like a list, iterator,
or file.
edge attribute
Edges can have arbitrary Python objects assigned as attributes
by using keyword/value pairs when adding an edge
assigning to the G.edges[u][v] attribute dictionary for the
specified edge u-v.
nbunch
An nbunch is a single node, container of nodes or None (representing
all nodes). It can be a list, set, graph, etc. To filter an nbunch
so that only nodes actually in G appear, use G.nbunch_iter(nbunch).
If the nbunch is a container or iterable that is not itself a node
in the graph, then it will be treated as an iterable of nodes, for
instance, when nbunch is a string or a tuple::
>>> import networkx as nx
>>> G = nx.DiGraph()
>>> G.add_edges_from([("b", "c"), ("a", "ab"), ("ab", "c")])
>>> G.edges("ab")
OutEdgeDataView([('ab', 'c')])
Since "ab" is a node in G, it is treated as a single node::
>>> G.edges("bc")
OutEdgeDataView([('b', 'c')])
Since "bc" is not a node in G, it is treated as an iterator::
>>> G.edges(["bc"])
OutEdgeDataView([])
If "bc" is wrapped in a list, the list is the iterable and
"bc" is treated as a single node. That is, if the
nbunch is an iterable of iterables, the inner iterables will
always be treated as nodes::
>>> G.edges("de")
OutEdgeDataView([])
When nbunch is an iterator that is not itself a node and none of
its elements are nodes, then the edge view suite of methods return
an empty edge view. node
A node can be any hashable Python object except None.
node attribute
Nodes can have arbitrary Python objects assigned as attributes
by using keyword/value pairs when adding a node or
assigning to the G.nodes[n] attribute dictionary for the
specified node n.
Doc Reference Index (`doc/reference/index.rst`)
.. _reference:
Reference
:Release: |release|
:Date: |today|
.. toctree::
:maxdepth: 2
introduction
classes/index
algorithms/index
functions
generators
linalg
convert
relabel
readwrite/index
drawing
randomness
exceptions
utils
backends
configs
glossary
Doc Reference Introduction (`doc/reference/introduction.md`)
jupytext:
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.13.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
name: python3
Introduction
The structure of NetworkX can be seen by the organization of its source code.
The package provides classes for graph objects, generators to create standard
graphs, IO routines for reading in existing datasets, algorithms to analyze
the resulting networks and some basic drawing tools.
Most of the NetworkX API is provided by functions which take a graph object
as an argument. Methods of the graph object are limited to basic manipulation
and reporting. This provides modularity of code and documentation.
It also makes it easier for newcomers to learn about the package in stages.
The source code for each module is meant to be easy to read and reading
this Python code is actually a good way to learn more about network algorithms,
but we have put a lot of effort into making the documentation sufficient and friendly.
If you have suggestions or questions please contact us by joining the
NetworkX Google group.
Classes are named using CamelCase (capital letters at the start of each word).
functions, methods and variable names are lower_case_underscore (lowercase with
an underscore representing a space between words).
NetworkX Basics
After starting Python, import the networkx module with (the recommended way)
import networkx as nxTo save repetition, in the documentation we assume that
NetworkX has been imported this way.
If importing networkx fails, it means that Python cannot find the installed
module. Check your installation and your PYTHONPATH.
The following basic graph types are provided as Python classes:
{class}Graph
- This class implements an undirected graph. It ignores
multiple edges between two nodes. It does allow self-loop
edges between a node and itself.
{class}DiGraph
- Directed graphs, that is, graphs with directed edges.
Provides operations common to directed graphs,
(a subclass of Graph).
{class}MultiGraph
- A flexible graph class that allows multiple undirected edges between
pairs of nodes. The additional flexibility leads to some degradation
in performance, though usually not significant.
{class}MultiDiGraph
- A directed version of a MultiGraph.
Empty graph-like objects are created with
G = nx.Graph()
G = nx.DiGraph()
G = nx.MultiGraph()
G = nx.MultiDiGraph()All graph classes allow any {term}hashable object as a node.
Hashable objects include strings, tuples, integers, and more.
Arbitrary edge attributes such as weights and labels
can be associated with an edge.
The graph internal data structures are based on an
adjacency list representation and implemented using
Python {term}dictionary datastructures.
The graph adjacency structure is
implemented as a Python dictionary of
dictionaries; the outer dictionary is keyed by nodes to values that are
themselves dictionaries keyed by neighboring node to the
edge attributes associated with that edge. This "dict-of-dicts" structure
allows fast addition, deletion, and lookup of nodes and neighbors in
large graphs. The underlying datastructure is accessed directly
by methods (the programming interface "API") in the class definitions.
All functions, on the other hand, manipulate graph-like objects
solely via those API methods and not by acting directly on the datastructure.
This design allows for possible replacement of the 'dicts-of-dicts'-based
datastructure with an alternative datastructure that implements the
same methods.
Graphs
The first choice to be made when using NetworkX is what type of graph
object to use. A graph (network) is a collection of nodes together
with a collection of edges that are pairs of nodes. Attributes are
often associated with nodes and/or edges. NetworkX graph objects come in
different flavors depending on two main properties of the network:
- Directed: Are the edges directed? Does the order of the edge
pairs $(u, v)$ matter? A directed graph is specified by the "Di"
prefix in the class name, e.g. {class}DiGraph. We make this distinction
because many classical graph properties are defined differently for
directed graphs.- Multi-edges: Are multiple edges allowed between each pair of nodes?
As you might imagine, multiple edges requires a different data
structure, though clever users could design edge data attributes to
support this functionality. We provide a standard data structure
and interface for this type of graph using the prefix "Multi",
e.g., {class}MultiGraph.
The basic graph classes are named:
{doc}Graph </reference/classes/graph>,
{doc}DiGraph</reference/classes/digraph>,
{doc}MultiGraph </reference/classes/multigraph>, and
{doc}MultiDiGraph </reference/classes/multidigraph>
Nodes and Edges
The next choice you have to make when specifying a graph is what kinds
of nodes and edges to use.
If the topology of the network is all you
care about then using integers or strings as the nodes makes sense and
you need not worry about edge data. If you have a data structure
already in place to describe nodes you can simply use that structure
as your nodes provided it is {term}hashable. If it is not hashable you can
use a unique identifier to represent the node and assign the data
as a {term}node attribute.
Edges often have data associated with them. Arbitrary data
can be associated with edges as an {term}edge attribute.
If the data is numeric and the intent is to represent
a weighted graph then use the 'weight' keyword for the attribute.
Some of the graph algorithms, such as
Dijkstra's shortest path algorithm, use this attribute
name by default to get the weight for each edge.
Attributes can be assigned to an edge by using keyword/value
pairs when adding edges. You can use any keyword
to name your attribute and can then query the edge
data using that attribute keyword.
Once you've decided how to encode the nodes and edges, and whether you have
an undirected/directed graph with or without multiedges you are ready to build
your network.
Graph Creation
NetworkX graph objects can be created in one of three ways:
- Graph generators---standard algorithms to create network topologies.
- Importing data from preexisting (usually file) sources.
- Adding edges and nodes explicitly.
Explicit addition and removal of nodes/edges is the easiest to describe.
Each graph object supplies methods to manipulate the graph. For example,
G = nx.Graph()
G.add_edge(1, 2) # default edge data=1
G.add_edge(2, 3, weight=0.9) # specify edge dataEdge attributes can be anything:
import math
G.add_edge('y', 'x', function=math.cos)
G.add_node(math.cos) # any hashable can be a nodeYou can add many edges at one time:
elist = [(1, 2), (2, 3), (1, 4), (4, 2)]
G.add_edges_from(elist)
elist = [('a', 'b', 5.0), ('b', 'c', 3.0), ('a', 'c', 1.0), ('c', 'd', 7.3)]
G.add_weighted_edges_from(elist)See the {doc}/tutorial for more examples.
Some basic graph operations such as union and intersection
are described in the {ref}operators module <operators> documentation.
Graph generators such as {func}~generators.random_graphs.binomial_graph
and {func}~generators.random_graphs.erdos_renyi_graph are
provided in the {ref}graph generators <generators> subpackage.
For importing network data from formats such as GML, GraphML, edge list text files
see the {ref}reading and writing graphs <readwrite> subpackage.
Graph Reporting
Class views provide basic reporting of nodes, neighbors, edges and degree.
These views provide iteration over the properties as well as membership
queries and data attribute lookup. The views refer to the graph data structure
so changes to the graph are reflected in the views. This is analogous to
dictionary views in Python 3. If you want to change the graph while iterating
you will need to use e.g. for e in list(G.edges):. The views provide
set-like operations, e.g. union and intersection, as well as dict-like
lookup and iteration of the data attributes using G.edges[u, v]['color']
and for e, datadict in G.edges.items():. Methods G.edges.items() andG.edges.values() are familiar from python dicts. In addition G.edges.data()
provides specific attribute iteration e.g. for e, e_color in G.edges.data('color'):.
The basic graph relationship of an edge can be obtained in two ways.
One can look for neighbors of a node or one can look for edges.
We jokingly refer to people who focus on nodes/neighbors as node-centric
and people who focus on edges as edge-centric. The designers of NetworkX
tend to be node-centric and view edges as a relationship between nodes.
You can see this by our choice of lookup notation like G[u] providing neighbors
(adjacency) while edge lookup is G.edges[u, v].
Most data structures for sparse graphs are essentially adjacency lists and so
fit this perspective. In the end, of course, it doesn't really matter which way
you examine the graph. G.edges removes duplicate representations of undirected
edges while neighbor reporting across all nodes will naturally report both directions.
Any properties that are more complicated than edges, neighbors and degree are
provided by functions. For example nx.triangles(G, n) gives the number of triangles
which include node n as a vertex. These functions are grouped in the code and
documentation under the term {ref}algorithms<algorithms>.
Algorithms
A number of graph algorithms are provided with NetworkX.
These include shortest path, and breadth first search
(see {ref}traversal<traversal>),
clustering and isomorphism algorithms and others. There are
many that we have not developed yet too. If you implement a
graph algorithm that might be useful for others please let
us know through the
NetworkX Google group
or the GitHub Developer Zone.
As an example here is code to use Dijkstra's algorithm to
find the shortest weighted path:
G = nx.Graph()
e = [('a', 'b', 0.3), ('b', 'c', 0.9), ('a', 'c', 0.5), ('c', 'd', 1.2)]
G.add_weighted_edges_from(e)
print(nx.dijkstra_path(G, 'a', 'd'))Drawing
While NetworkX is not designed as a network drawing tool, we provide
a simple interface to drawing packages and some simple layout algorithms.
We interface to the excellent Graphviz layout tools like dot and neato
with the (suggested) pygraphviz package or the pydot interface.
Drawing can be done using external programs or the Matplotlib Python
package. Interactive GUI interfaces are possible, though not provided.
The drawing tools are provided in the module {ref}drawing <drawing>.
The basic drawing functions essentially place the nodes on a scatterplot
using the positions you provide via a dictionary or the positions are
computed with a layout function. The edges are lines between those dots.
import matplotlib.pyplot as plt
G = nx.cubical_graph()
subax1 = plt.subplot(121)
nx.draw(G) # default spring_layout
subax2 = plt.subplot(122)
nx.draw(G, pos=nx.circular_layout(G), node_color='r', edge_color='b')See the {doc}examples </auto_examples/index> for more ideas.
Data Structure
NetworkX uses a "dictionary of dictionaries of dictionaries" as the
basic network data structure. This allows fast lookup with reasonable
storage for large sparse networks. The keys are nodes so G[u] returns
an adjacency dictionary keyed by neighbor to the edge attribute
dictionary. A view of the adjacency data structure is provided
by the dict-like object G.adj as e.g. for node, nbrsdict in G.adj.items():.
The expression G[u][v] returns the edge attribute dictionary itself.
A dictionary of lists would have also been possible, but not allow
fast edge detection nor convenient storage of edge data.
Advantages of dict-of-dicts-of-dicts data structure:
- Find edges and remove edges with two dictionary look-ups.
- Prefer to "lists" because of fast lookup with sparse storage.
- Prefer to "sets" since data can be attached to edge.
G[u][v]returns the edge attribute dictionary.n in Gtests if nodenis in graphG.for n in G:iterates through the graph.for nbr in G[n]:iterates through neighbors.
As an example, here is a representation of an undirected graph with the
edges $(A, B)$ and $(B, C)$.
G = nx.Graph()
G.add_edge('A', 'B')
G.add_edge('B', 'C')
print(G.adj)The data structure gets morphed slightly for each base graph class.
For DiGraph two dict-of-dicts-of-dicts structures are provided, one
for successors (G.succ) and one for predecessors (G.pred).
For MultiGraph/MultiDiGraph we use a dict-of-dicts-of-dicts-of-dicts [^turtles]
where the third dictionary is keyed by an edge key identifier to the fourth
dictionary which contains the edge attributes for that edge between
the two nodes.
Graphs provide two interfaces to the edge data attributes: adjacency
and edges. So G[u][v]['width'] is the same as G.edges[u, v]['width'].
G = nx.Graph()
G.add_edge(1, 2, color='red', weight=0.84, size=300)
print(G[1][2]['size'])
print(G.edges[1, 2]['color'])[^turtles]: "It's dictionaries all the way down."
Doc Reference Linalg (`doc/reference/linalg.rst`)
.. _linalg:
Linear algebra
.. currentmodule:: networkx
Graph Matrix
.. automodule:: networkx.linalg.graphmatrix
.. autosummary::
:toctree: generated/
adjacency_matrix
incidence_matrix
Laplacian Matrix
.. automodule:: networkx.linalg.laplacianmatrix
.. autosummary::
:toctree: generated/
laplacian_matrix
normalized_laplacian_matrix
directed_laplacian_matrix
directed_combinatorial_laplacian_matrix
magnetic_laplacian_matrix
Bethe Hessian Matrix
.. automodule:: networkx.linalg.bethehessianmatrix
.. autosummary::
:toctree: generated/
bethe_hessian_matrix
Algebraic Connectivity
.. automodule:: networkx.linalg.algebraicconnectivity
.. autosummary::
:toctree: generated/
algebraic_connectivity
fiedler_vector
spectral_ordering
spectral_bisection
Attribute Matrices
.. automodule:: networkx.linalg.attrmatrix
.. autosummary::
:toctree: generated/
attr_matrix
attr_sparse_matrix
Modularity Matrices
.. automodule:: networkx.linalg.modularitymatrix
.. autosummary::
:toctree: generated/
modularity_matrix
directed_modularity_matrix
Spectrum
.. automodule:: networkx.linalg.spectrum
.. autosummary::
:toctree: generated/
adjacency_spectrum
laplacian_spectrum
bethe_hessian_spectrum
normalized_laplacian_spectrum
modularity_spectrum
magnetic_spectrum
Doc Reference Randomness (`doc/reference/randomness.rst`)
.. _randomness:
Randomness
.. currentmodule:: networkx
Random Number Generators (RNGs) are often used when generating, drawing
and computing properties or manipulating networks. NetworkX provides
functions which use one of two standard RNGs: NumPy's package numpy.random
or Python's built-in package random. They each provide the same
algorithm for generating numbers (Mersenne Twister). Their interfaces
are similar (dangerously similar) and yet distinct.
They each provide a global default instance of their generator that
is shared by all programs in a single session.
For the most part you can use the RNGs as NetworkX has them set up and
you'll get reasonable pseudorandom results (results that are statistically
random, but created in a deterministic manner).
Sometimes you want more control over how the numbers are generated.
In particular, you need to set the seed of the generator to make
your results reproducible -- either for scientific publication or
for debugging. Both RNG packages have easy functions to set the seed
to any integer, thus determining the subsequent generated values.
Since this package (and many others) use both RNGs you may need to
set the seed of both RNGs. Even if we strictly only used one of the
RNGs, you may find yourself using another package that uses the other.
Setting the state of the two global RNGs is as simple setting the
seed of each RNG to an arbitrary integer:
.. code-block::
import random
random.seed(246) # or any integer
import numpy as np
np.random.seed(4812)
Many users will be satisfied with this level of control.
For people who want even more control, we include an optional argument
to functions that use an RNG. This argument is called seed, but
determines more than the seed of the RNG. It tells the function which
RNG package to use, and whether to use a global or local RNG.
.. code-block::
>>> from networkx import path_graph, random_layout
>>> G = path_graph(9)
>>> pos = random_layout(G, seed=None) # use (either) global default RNG
>>> pos = random_layout(G, seed=42) # local RNG just for this call
>>> pos = random_layout(G, seed=numpy.random) # use numpy global RNG
>>> random_state = numpy.random.RandomState(42)
>>> pos = random_layout(G, seed=random_state) # use/reuse your own RNGEach NetworkX function that uses an RNG was written with one RNG package
in mind. It either uses random or numpy.random by default.
But some users want to only use a single RNG for all their code.
This seed argument provides a mechanism so that any function
can use a numpy.random RNG even if the function is written for random.
It works as follows.
The default behavior (when seed=None) is to use the global RNG
for the function's preferred package.
If seed is set to an integer value,
a local RNG is created with the indicated seed value and
is used for the duration of that function (including any
calls to other functions) and then discarded.
Alternatively, you can specify seed=numpy.random to ensure that
the global numpy RNG is used whether the function expects it or not.
Finally, you can provide a numpy RNG to be used by the function.
The RNG is then available to use in other functions or even other
package like sklearn.
In this way you can use a single RNG for all random numbers
in your project.
While it is possible to assign seed a random-style RNG for
NetworkX functions written for the random package API,
the numpy RNG interface has too
many nice features for us to ensure a random-style RNG will work in
all functions. In practice, you can do most things using only random
RNGs (useful if numpy is not available). But your experience will be
richer if numpy is available.
To summarize, you can easily ignore the seed argument and use the global
RNGs. You can specify to use only the numpy global RNG withseed=numpy.random. You can use a local RNG by providing an integer
seed value. And you can provide your own numpy RNG, reusing it for all
functions. It is easier to use numpy RNGs if you want a single RNG for
your computations.
Doc Reference Relabel (`doc/reference/relabel.rst`)
Relabeling nodes
.. currentmodule:: networkx
Relabeling
.. automodule:: networkx.relabel
.. autosummary::
:toctree: generated/
convert_node_labels_to_integers
relabel_nodes
Doc Reference Utils (`doc/reference/utils.rst`)
Utilities
.. automodule:: networkx.utils
.. currentmodule:: networkx.utils
Helper Functions
.. automodule:: networkx.utils.misc
.. autosummary::
:toctree: generated/
arbitrary_element
flatten
make_list_of_ints
dict_to_numpy_array
pairwise
groups
create_random_state
create_py_random_state
nodes_equal
edges_equal
graphs_equal
Data Structures and Algorithms
.. automodule:: networkx.utils.union_find
.. autosummary::
:toctree: generated/
UnionFind.union
Random Sequence Generators
.. automodule:: networkx.utils.random_sequence
.. autosummary::
:toctree: generated/
powerlaw_sequence
is_valid_tree_degree_sequence
cumulative_distribution
discrete_sequence
zipf_rv
random_weighted_sample
weighted_choice
Decorators
.. automodule:: networkx.utils.decorators
.. autosummary::
:toctree: generated/
open_file
not_implemented_for
nodes_or_number
np_random_state
py_random_state
argmap
Cuthill-Mckee Ordering
.. automodule:: networkx.utils.rcm
.. autosummary::
:toctree: generated/
cuthill_mckee_ordering
reverse_cuthill_mckee_ordering
Mapped Queue
.. automodule:: networkx.utils.mapped_queue
.. autosummary::
:toctree: generated/
MappedQueue
Doc Release Api 0.99 (`doc/release/api_0.99.rst`)
NetworkX 0.99
Release date: 18 November 2008
See: https://networkx.lanl.gov/trac/timeline
New features
This release has significant changes to parts of the graph API.
See http://networkx.lanl.gov/reference/api_changes.html
- Update Graph and DiGraph classes to use weighted graphs as default
Change in API for performance and code simplicity. - New MultiGraph and MultiDiGraph classes (replace XGraph and XDiGraph)
- Update to use Sphinx documentation system http://networkx.lanl.gov/
- Developer site at https://networkx.lanl.gov/trac/
- Experimental LabeledGraph and LabeledDiGraph
- Moved package and file layout to subdirectories.
Bug fixes
- handle root= option to draw_graphviz correctly
Examples
- Update to work with networkx-0.99 API
- Drawing examples now use matplotlib.pyplot interface
- Improved drawings in many examples
- New examples - see http://networkx.lanl.gov/examples/
The version networkx-0.99 is the penultimate release before
networkx-1.0. We have bumped the version from 0.37 to 0.99 to
indicate (in our unusual version number scheme) that this is a major
change to NetworkX.
We have made some significant changes, detailed below, to NetworkX
to improve performance, functionality, and clarity.
Version 0.99 requires Python 2.4 or greater.
Please send comments and questions to the networkx-discuss mailing list.
http://groups.google.com/group/networkx-discuss
Changes in base classes
The most significant changes are in the graph classes.
We have redesigned the Graph() and DiGraph() classes
to optionally allow edge data.
This change allows Graph and DiGraph to naturally represent
weighted graphs and to hold arbitrary information on edges.
Both Graph and DiGraph take an optional argument weighted=True|False.
When weighted=True the graph is assumed to have numeric edge data
(with default 1). The Graph and DiGraph classes in earlier versions
used the Python None as data (which is still allowed as edge data).The Graph and DiGraph classes now allow self loops.
The XGraph and XDiGraph classes are removed and replaced with
MultiGraph and MultiDiGraph. MultiGraph and MultiDiGraph
optionally allow parallel (multiple) edges between two nodes.
The mapping from old to new classes is as follows::
- Graph -> Graph (self loops allowed now, default edge data is 1)
- DiGraph -> DiGraph (self loops allowed now, default edge data is 1)
- XGraph(multiedges=False) -> Graph
- XGraph(multiedges=True) -> MultiGraph
- XDiGraph(multiedges=False) -> DiGraph
- XDiGraph(multiedges=True) -> MultiDiGraph
Methods changed
edges()
^^^^^^^
New keyword data=True|False keyword determines whether to return
two-tuples (u,v) (False) or three-tuples (u,v,d) (True)
delete_node()
^^^^^^^^^^^^^
The preferred name is now remove_node().
delete_nodes_from()
^^^^^^^^^^^^^^^^^^^
No longer raises an exception on an attempt to delete a node not in
the graph. The preferred name is now remove_nodes_from().
delete_edge()
^^^^^^^^^^^^^^
Now raises an exception on an attempt to delete an edge not in the graph.
The preferred name is now remove_edge().
delete_edges_from()
^^^^^^^^^^^^^^^^^^^
The preferred name is now remove_edges_from().
add_edge()
^^^^^^^^^^
The add_edge() method no longer accepts an edge tuple (u,v)
directly. The tuple must be unpacked into individual nodes.
import networkx as nx
u='a'
v='b'
e=(u,v)
G=nx.Graph()
Old
G.add_edge((u,v)) # or G.add_edge(e)
New
G.add_edge(e) # or G.add_edge((u,v))
The * operator unpacks the edge tuple in the argument list.
Add edge now has
a data keyword parameter for setting the default (data=1) edge
data.
G.add_edge('a','b','foo') # add edge with string "foo" as data
G.add_edge(1,2,5.0) # add edge with float 5 as data
add_edges_from()
^^^^^^^^^^^^^^^^
Now can take list or iterator of either 2-tuples (u,v),
3-tuples (u,v,data) or a mix of both.
Now has data keyword parameter (default 1) for setting the edge data
for any edge in the edge list that is a 2-tuple.
has_edge()
^^^^^^^^^^
The has_edge() method no longer accepts an edge tuple (u,v)
directly. The tuple must be unpacked into individual nodes.
Old:
G.has_edge((u,v)) # or has_edge(e)
New:
G.has_edge(e) # or has_edge((u,v))
True
The * operator unpacks the edge tuple in the argument list.
get_edge()
^^^^^^^^^^
Now has the keyword argument "default" to specify
what value to return if no edge is found. If not specified
an exception is raised if no edge is found.
The fastest way to get edge data for edge (u,v) is to use G[u][v]
instead of G.get_edge(u,v)
degree_iter()
^^^^^^^^^^^^^
The degree_iter method now returns an iterator over pairs of (node,
degree). This was the previous behavior of degree_iter(with_labels=true)
Also there is a new keyword weighted=False|True for weighted degree.
subgraph()
^^^^^^^^^^
The argument inplace=False|True has been replaced with copy=True|False.
Subgraph no longer takes create_using keyword. To change the graph
type either make a copy of
the graph first and then change type or change type and make
a subgraph. E.g.
G=nx.path_graph(5)
H=nx.DiGraph(G.subgraph([0,1])) # digraph of copy of induced subgraph
getitem()
^^^^^^^^^^^^^
Getting node neighbors from the graph with G[v] now returns
a dictionary.
G=nx.path_graph(5)
G[0]
{1: 1}
To get a list of neighbors you can either use the keys of that
dictionary or use
G.neighbors(0) # doctest: +SKIP
[1]
This change allows algorithms to use the underlying dict-of-dict
representation through G[v] for substantial performance gains.
Warning: The returned dictionary should not be modified as it may
corrupt the graph data structure. Make a copy G[v].copy() if you
wish to modify the dict.
Methods removed
info()
^^^^^^
now a function
G=nx.Graph(name='test me')
nx.info(G) # doctest: +SKIP
Name: test me
Type: Graph
Number of nodes: 0
Number of edges: 0
node_boundary()
^^^^^^^^^^^^^^^
now a function
edge_boundary()
^^^^^^^^^^^^^^^
now a function
is_directed()
^^^^^^^^^^^^^
use the directed attribute
G=nx.DiGraph()
G.directed
True
G.out_edges()
^^^^^^^^^^^^^
use G.edges()
G.in_edges()
^^^^^^^^^^^^
use
G = nx.DiGraph()
R = G.reverse()
R.edges() # doctest: +SKIP
[]
or
[(v,u) for (u,v) in G.edges()]
[]
Methods added
adjacency_list()
^^^^^^^^^^^^^^^^
Returns a list-of-lists adjacency list representation of the graph.
adjacency_iter()
^^^^^^^^^^^^^^^^
Returns an iterator of (node, adjacency_dict[node]) over all
nodes in the graph. Intended for fast access to the internal
data structure for use in internal algorithms.
Other possible incompatibilities with existing code
Imports
Some of the code modules were moved into subdirectories.
Import statements such as::
import networkx.centrality
from networkx.centrality import *
may no longer work (including that example).
Use either
import networkx # e.g. centrality functions available as networkx.fcn()
or
from networkx import * # e.g. centrality functions available as fcn()
Self-loops
For Graph and DiGraph self loops are now allowed.
This might affect code or algorithms that add self loops
which were intended to be ignored.
Use the methods
- nodes_with_selfloops()
- selfloop_edges()
- number_of_selfloops()
to discover any self loops.
Copy
Copies of NetworkX graphs including using the copy() method
now return complete copies of the graph. This means that all
connection information is copied--subsequent changes in the
copy do not change the old graph. But node keys and edge
data in the original and copy graphs are pointers to the same data.
prepare_nbunch
Used internally - now called nbunch_iter and returns an iterator.
Converting your old code to Version 0.99
Mostly you can just run the code and python will raise an exception
for features that changed. Common places for changes are
- Converting XGraph() to either Graph or MultiGraph
- Converting XGraph.edges() to Graph.edges(data=True)
- Switching some rarely used methods to attributes (e.g. directed)
or to functions (e.g. node_boundary)
- If you relied on the old default edge data being None, you will
have to account for it now being 1.You may also want to look through your code for places which could
improve speed or readability. The iterators are helpful with large
graphs and getting edge data via G[u][v] is quite fast. You may also
want to change G.neighbors(n) to G[n] which returns the dict keyed by
neighbor nodes to the edge data. It is faster for many purposes but
does not work well when you are changing the graph.
Doc Release Api 1.0 (`doc/release/api_1.0.rst`)
NetworkX 1.0
Release date: 8 Jan 2010
Version 1.0 requires Python 2.4 or greater.
New features
This release has significant changes to parts of the graph API
to allow graph, node, and edge attributes.
See http://networkx.lanl.gov/reference/api_changes.html
- Update Graph, DiGraph, and MultiGraph classes to allow attributes.
- Default edge data is now an empty dictionary (was the integer 1)
- Difference and intersection operators
- Average shortest path
- A* (A-Star) algorithm
- PageRank, HITS, and eigenvector centrality
- Read Pajek files
- Line graphs
- Minimum spanning tree (Kruskal's algorithm)
- Dense and sparse Fruchterman-Reingold layout
- Random clustered graph generator
- Directed scale-free graph generator
- Faster random regular graph generator
- Improved edge color and label drawing with Matplotlib
- and much more, see https://networkx.lanl.gov/trac/query?status=closed&group=milestone&milestone=networkx-1.0
Examples
- Update to work with networkx-1.0 API
- Graph subclass example
Version numbering
In the future we will use a more standard release numbering system
with major.minor[build] labels where major and minor are numbers and
[build] is a label such as "dev1379" to indicate a development version
or "rc1" to indicate a release candidate.
We plan on sticking closer to a time-based release schedule with smaller
incremental changes released on a roughly quarterly basis. The graph
classes API will remain fixed, unless we determine there are serious
bugs or other defects in the existing classes, until networkx-2.0 is
released at some time in the future.
Changes in base classes
The most significant changes in are in the graph classes. All of the
graph classes now allow optional graph, node, and edge attributes. Those
attributes are stored internally in the graph classes as dictionaries
and can be accessed simply like Python dictionaries in most cases.
Graph attributes
^^^^^^^^^^^^^^^^
Each graph keeps a dictionary of key=value attributes
in the member G.graph. These attributes can be accessed
directly using G.graph or added at instantiation using
keyword arguments.
G=nx.Graph(region='Africa')
G.graph['color']='green'
G.graph
{'region': 'Africa', 'color': 'green'}
Node attributes
^^^^^^^^^^^^^^^
Each node has a corresponding dictionary of attributes.
Adding attributes to nodes is optional.
Add node attributes using add_node(), add_nodes_from() or G.node
G.add_node(1, time='5pm')
G.add_nodes_from([3], time='2pm')
G.node[1] # doctest: +SKIP
{'time': '5pm'}
G.node[1]['room'] = 714 # doctest: +SKIP
G.nodes(data=True) # doctest: +SKIP
[(1, {'room': 714, 'time': '5pm'}), (3, {'time': '2pm'})]
Edge attributes
^^^^^^^^^^^^^^^
Each edge has a corresponding dictionary of attributes.
The default edge data is now an empty dictionary of attributes
and adding attributes to edges is optional.
A common use case is to add a weight attribute to an edge:
G.add_edge(1,2,weight=3.14159)
Add edge attributes using add_edge(), add_edges_from(), subscript
notation, or G.edge.
G.add_edge(1, 2, weight=4.7 )
G.add_edges_from([(3,4),(4,5)], color='red')
G.add_edges_from([(1,2,{'color':'blue'}), (2,3,{'weight':8})])
G[1][2]['weight'] = 4.7
G.edge[1][2]['weight'] = 4 # doctest: +SKIP
Methods changed
Graph(), DiGraph(), MultiGraph(), MultiDiGraph()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Now takes optional keyword=value attributes on initialization.
G=nx.Graph(year='2009',city='New York')
add_node()
^^^^^^^^^^
Now takes optional keyword=value attributes or a dictionary of attributes.
G.add_node(1,room=714)
add_nodes_from()
^^^^^^^^^^^^^^^^
Now takes optional keyword=value attributes or a dictionary of
attributes applied to all affected nodes.
G.add_nodes_from([1,2],time='2pm') # all nodes have same attribute
add_edge()
^^^^^^^^^^
Now takes optional keyword=value attributes or a dictionary of attributes.
G.add_edge(1, 2, weight=4.7 )
add_edges_from()
^^^^^^^^^^^^^^^^
Now takes optional keyword=value attributes or a dictionary of
attributes applied to all affected edges.
G.add_edges_from([(3,4),(4,5)], color='red')
G.add_edges_from([(1,2,{'color':'blue'}), (2,3,{'weight':8})])
nodes() and nodes_iter()
^^^^^^^^^^^^^^^^^^^^^^^^
New keyword data=True|False keyword determines whether to return
two-tuples (n,dict) (True) with node attribution dictionary
G=nx.Graph([(1,2),(3,4)])
G.nodes(data=True) # doctest: +SKIP
[(1, {}), (2, {}), (3, {}), (4, {})]
copy()
^^^^^^
Now returns a deep copy of the graph (copies all underlying
data and attributes for nodes and edges). Use the class
initializer to make a shallow copy:
G=nx.Graph()
G_shallow=nx.Graph(G) # shallow copy
G_deep=G.copy() # deep copy
to_directed(), to_undirected()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Now returns a deep copy of the graph (copies all underlying
data and attributes for nodes and edges). Use the class
initializer to make a shallow copy:
G = nx.Graph()
D_shallow = nx.DiGraph(G) # shallow copy
D_deep = G.to_directed() # deep copy
subgraph()
^^^^^^^^^^
With copy=True now returns a deep copy of the graph
(copies all underlying data and attributes for nodes and edges).
G = nx.Graph()
note: copy keyword deprecated in networkx>1.0
H = G.subgraph([],copy=True) # deep copy of all data
add_cycle(), add_path(), add_star()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Now take optional keyword=value attributes or a dictionary of
attributes which are applied to all edges affected by the method.
G = nx.Graph()
G.add_path([0, 1, 2, 3], width=3.2) # doctest: +SKIP
Methods removed
delete_node()
^^^^^^^^^^^^^
The preferred name is now remove_node().
delete_nodes_from()
^^^^^^^^^^^^^^^^^^^
No longer raises an exception on an attempt to delete a node not in
the graph. The preferred name is now remove_nodes_from().
delete_edge()
^^^^^^^^^^^^^
Now raises an exception on an attempt to delete an edge not in the graph.
The preferred name is now remove_edge().
delete_edges_from()
^^^^^^^^^^^^^^^^^^^
The preferred name is now remove_edges_from().
has_neighbor():
Use has_edge()
get_edge()
^^^^^^^^^^
Renamed to get_edge_data(). Returns the edge attribute dictionary.
The fastest way to get edge data for edge (u,v) is to use G[u][v]
instead of G.get_edge_data(u,v)
Members removed
directed, multigraph, weighted
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Use methods G.is_directed() and G.is_multigraph().
All graphs are weighted graphs now if they have numeric
values in the 'weight' edge attribute.
Methods added
add_weighted edges_from()
^^^^^^^^^^^^^^^^^^^^^^^^^
Convenience method to add weighted edges to graph using a list of
3-tuples (u,v,weight).
get_edge_data()
^^^^^^^^^^^^^^^
Renamed from get_edge().
The fastest way to get edge data for edge (u,v) is to use G[u][v]
instead of G.get_edge_data(u,v)
is_directed()
^^^^^^^^^^^^^
replaces member G.directed
is_multigraph()
^^^^^^^^^^^^^^^
replaces member G.multigraph
Classes Removed
LabeledGraph, LabeledDiGraph
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
These classes have been folded into the regular classes.
UbiGraph
^^^^^^^^
Removed as the ubigraph platform is no longer being supported.
Additional functions/generators
ego_graph, stochastic_graph, PageRank algorithm, HITS algorithm,
GraphML writer, freeze, is_frozen, A* algorithm,
directed scale-free generator, random clustered graph.
Converting your existing code to networkx-1.0
Weighted edges
^^^^^^^^^^^^^^
Edge information is now stored in an attribution dictionary
so all edge data must be given a key to identify it.
There is currently only one standard/reserved key, 'weight', which is
used by algorithms and functions that use weighted edges. The
associated value should be numeric. All other keys are available for
users to assign as needed.
G=nx.Graph()
G.add_edge(1,2,weight=3.1415) # add the edge 1-2 with a weight
G[1][2]['weight']=2.3 # set the weight to 2.3
Similarly, for direct access the edge data, use
the key of the edge data to retrieve it.
w = G[1][2]['weight']
All NetworkX algorithms that require/use weighted edges now use the
'weight' edge attribute. If you have existing algorithms that assumed
the edge data was numeric, you should replace G[u][v] and
G.get_edge(u,v) with G[u][v]['weight'].
An idiom for getting a weight for graphs with or without an assigned
weight key is
w= G[1][2].get('weight',1) # set w to 1 if there is no 'weight' key
Doc Release Api 1.10 (`doc/release/api_1.10.rst`)
NetworkX 1.10
Release date: 2 August 2015
Support for Python 2.6 is dropped in this release.
Highlights
- Connected components now return generators
- new functions including
+ enumerate_all_cliques, greedy_coloring, edge_dfs, find_cycle
immediate_dominators, harmonic_centrality
+ Hopcraft--Karp algorithm for maximum matchings
+ optimum branchings and arborescences.
+ all_simple_paths
- pyparsing dependence removed from GML reader/parser
- improve flow algorithms
- new generators related to expander graphs.
- new generators for multipartite graphs, nonisomorphic trees,
circulant graphs
- allow graph subclasses to use dict-like objects in place of dicts
- added ordered graph subclasses
- pandas dataframe read/write added.
- data keyword in G.edges() allows requesting edge attribute directly
- expanded layout flexibility for node subsets
- Kanesky's algorithm for cut sets and k_components
- power function for graphs
- approximation of node connectivity
- transitive closure, triadic census and antichains
- quotient graphs and minors
- longest_path for DAGS
- modularity matrix routines
API changes
-----------
* [`#1501 <https://github.com/networkx/networkx/pull/1501>`_]
``connected_components``, ``weakly_connected_components``, and
``strongly_connected_components`` return now a generator of sets of
nodes. Previously the generator was of lists of nodes. This PR also
refactored the ``connected_components`` and ``weakly_connected_components``
implementations making them faster, especially for large graphs.
* [`#1547 <https://github.com/networkx/networkx/pull/1547>`_]
The ``func_iter`` functions in Di/Multi/Graphs classes are slated for
removal in NetworkX 2.0 release. ``func`` will behave like ``func_iter``
and return an iterator instead of list. These functions are deprecated in
NetworkX 1.10 release.
New functionalities
-------------------
* [`#823 <https://github.com/networkx/networkx/pull/823>`_]
A ``enumerate_all_cliques`` function is added in the clique package
(``networkx.algorithms.clique``) for enumerating all cliques (including
nonmaximal ones) of undirected graphs.
* [`#1105 <https://github.com/networkx/networkx/pull/1105>`_]
A coloring package (``networkx.algorithms.coloring``) is created for
graph coloring algorithms. Initially, a ``greedy_color`` function is
provided for coloring graphs using various greedy heuristics.
* [`#1193 <https://github.com/networkx/networkx/pull/1193>`_]
A new generator ``edge_dfs``, added to ``networkx.algorithms.traversal``,
implements a depth-first traversal of the edges in a graph. This complements
functionality provided by a depth-first traversal of the nodes in a graph.
For multigraphs, it allows the user to know precisely which edges were
followed in a traversal. All NetworkX graph types are supported. A traversal
can also reverse edge orientations or ignore them.
* [`#1194 <https://github.com/networkx/networkx/pull/1194>`_]
A ``find_cycle`` function is added to the ``networkx.algorithms.cycles``
package to find a cycle in a graph. Edge orientations can be optionally
reversed or ignored.
* [`#1210 <https://github.com/networkx/networkx/pull/1210>`_]
Add a random generator for the duplication-divergence model.
* [`#1241 <https://github.com/networkx/networkx/pull/1241>`_]
A new ``networkx.algorithms.dominance`` package is added for
dominance/dominator algorithms on directed graphs. It contains a
``immediate_dominators`` function for computing immediate
dominators/dominator trees and a ``dominance_frontiers`` function for
computing dominance frontiers.
* [`#1269 <https://github.com/networkx/networkx/pull/1269>`_]
The GML reader/parser and writer/generator are rewritten to remove the
dependence on pyparsing and enable handling of arbitrary graph data.
* [`#1280 <https://github.com/networkx/networkx/pull/1280>`_]
The network simplex method in the ``networkx.algorithms.flow`` package is
rewritten to improve its performance and support multi- and disconnected
networks. For some cases, the new implementation is two or three orders of
magnitude faster than the old implementation.
* [`#1286 <https://github.com/networkx/networkx/pull/1286>`_]
Added the Margulis--Gabber--Galil graph to ``networkx.generators``.
* [`#1306 <https://github.com/networkx/networkx/pull/1306>`_]
Added the chordal p-cycle graph, a mildly explicit algebraic construction
of a family of 3-regular expander graphs. Also, moves both the existing
expander graph generator function (for the Margulis-Gabber-Galil
expander) and the new chordal cycle graph function to a new module,
``networkx.generators.expanders``.
* [`#1314 <https://github.com/networkx/networkx/pull/1314>`_]
Allow overwriting of base class dict with dict-like:
OrderedGraph, ThinGraph, PrintGraph, etc.
* [`#1321 <https://github.com/networkx/networkx/pull/1321>`_]
Added ``to_pandas_dataframe`` and ``from_pandas_dataframe``.
* [`#1322 <https://github.com/networkx/networkx/pull/1322>`_]
Added the Hopcroft--Karp algorithm for finding a maximum cardinality
matching in bipartite graphs.
* [`#1336 <https://github.com/networkx/networkx/pull/1336>`_]
Expanded data keyword in G.edges and added default keyword.
* [`#1338 <https://github.com/networkx/networkx/pull/1338>`_]
Added support for finding optimum branchings and arborescences.
* [`#1340 <https://github.com/networkx/networkx/pull/1340>`_]
Added a ``from_pandas_dataframe`` function that accepts Pandas DataFrames
and returns a new graph object. At a minimum, the DataFrame must have two
columns, which define the nodes that make up an edge. However, the function
can also process an arbitrary number of additional columns as edge
attributes, such as 'weight'.
* [`#1354 <https://github.com/networkx/networkx/pull/1354>`_]
Expanded layout functions to add flexibility for drawing subsets of nodes
with distinct layouts and for centering each layout around given
coordinates.
* [`#1356 <https://github.com/networkx/networkx/pull/1356>`_]
Added ordered variants of default graph class.
* [`#1360 <https://github.com/networkx/networkx/pull/1360>`_]
Added harmonic centrality to ``network.algorithms.centrality``.
* [`#1390 <https://github.com/networkx/networkx/pull/1390>`_]
The ``generators.bipartite`` have been moved to
``algorithms.bipartite.generators``. The functions are not imported in the
main namespace, so to use it, the bipartite package has to be imported.
* [`#1391 <https://github.com/networkx/networkx/pull/1391>`_]
Added Kanevsky's algorithm for finding all minimum-size separating
node sets in an undirected graph. It is implemented as a generator
of node cut sets.
* [`#1399 <https://github.com/networkx/networkx/pull/1399>`_]
Added power function for simple graphs
* [`#1405 <https://github.com/networkx/networkx/pull/1405>`_]
Added fast approximation for node connectivity based on White and
Newman's approximation algorithm for finding node independent paths
between two nodes.
* [`#1413 <https://github.com/networkx/networkx/pull/1413>`_]
Added transitive closure and antichains function for directed acyclic
graphs in ``algorithms.dag``. The antichains function was contributed
by Peter Jipsen and Franco Saliola and originally developed for the
SAGE project.
* [`#1425 <https://github.com/networkx/networkx/pull/1425>`_]
Added generator function for the complete multipartite graph.
* [`#1427 <https://github.com/networkx/networkx/pull/1427>`_]
Added nonisomorphic trees generator.
* [`#1436 <https://github.com/networkx/networkx/pull/1436>`_]
Added a generator function for circulant graphs to the
``networkx.generators.classic`` module.
* [`#1437 <https://github.com/networkx/networkx/pull/1437>`_]
Added function for computing quotient graphs; also created a new module,
``networkx.algorithms.minors``.
* [`#1438 <https://github.com/networkx/networkx/pull/1438>`_]
Added longest_path and longest_path_length for DAG.
* [`#1439 <https://github.com/networkx/networkx/pull/1439>`_]
Added node and edge contraction functions to
``networkx.algorithms.minors``.
* [`#1445 <https://github.com/networkx/networkx/pull/1448>`_]
Added a new modularity matrix module to ``networkx.linalg``,
and associated spectrum functions to the ``networkx.linalg.spectrum``
module.
* [`#1447 <https://github.com/networkx/networkx/pull/1447>`_]
Added function to generate all simple paths starting with the shortest
ones based on Yen's algorithm for finding k shortest paths at
``algorithms.simple_paths``.
* [`#1455 <https://github.com/networkx/networkx/pull/1455>`_]
Added the directed modularity matrix to the
``networkx.linalg.modularity_matrix`` module.
* [`#1474 <https://github.com/networkx/networkx/pull/1474>`_]
Adds ``triadic_census`` function; also creates a new module,
``networkx.algorithms.triads``.
* [`#1476 <https://github.com/networkx/networkx/pull/1476>`_]
Adds functions for testing if a graph has weighted or negatively weighted
edges. Also adds a function for testing if a graph is empty. These are
``is_weighted``, ``is_negatively_weighted``, and ``is_empty``.
* [`#1481 <https://github.com/networkx/networkx/pull/1481>`_]
Added Johnson's algorithm; one more algorithm for shortest paths. It
solves all pairs shortest path problem. This is ``johnson`` at
``algorithms.shortest_paths``
* [`#1414 <https://github.com/networkx/networkx/pull/1414>`_]
Added Moody and White algorithm for identifying ``k_components`` in a
graph, which is based on Kanevsky's algorithm for finding all minimum-size
node cut-sets (implemented in ``all_node_cuts`` #1391).
* [`#1415 <https://github.com/networkx/networkx/pull/1415>`_]
Added fast approximation for ``k_components`` to the
``networkx.approximation`` package. This is based on White and Newman
approximation algorithm for finding node independent paths between two
nodes (see #1405).
Removed functionalities
-----------------------
* [`#1236 <https://github.com/networkx/networkx/pull/1236>`_]
The legacy ``ford_fulkerson`` maximum flow function is removed. Use
``edmonds_karp`` instead.
Miscellaneous changes
---------------------
* [`#1192 <https://github.com/networkx/networkx/pull/1192>`_]
Support for Python 2.6 is dropped.
---
### Doc Release Api 1.11 (`doc/release/api_1.11.rst`)
NetworkX 1.11
=============
Release date: 30 January 2016
Support for Python 3.5 added, drop support for Python 3.2.
HighlightsPydot features now use pydotplus.
Fixes installation on some machines and test with appveyor.
Restores default center and scale of layout routines.
Fixes various docs including no symbolic links in examples.
Docs can now build using autosummary on readthedocs.org.
API changes
[
#1930 <https://github.com/networkx/networkx/pull/1930>_]
No longer import nx_agraph and nx_pydot into the top-level namespace.
They can be accessed within networkx as e.g.nx.nx_agraph.write_dot
or imported asfrom networkx.drawing.nx_agraph import write_dot.[
#1750 <https://github.com/networkx/networkx/pull/1750>_]
Arguments center and scale are now available for all layout functions.
The default values revert to the v1.9 values (center is the origin
for circular layouts and domain is [0, scale) for others.[
#1924 <https://github.com/networkx/networkx/pull/1924>_]
Replace pydot with pydotplus for drawing with the pydot interface.[
#1888 <https://github.com/networkx/networkx/pull/1888>_]
Replace support for Python3.2 with support for Python 3.5.
Miscellaneous changes
- [
#1763 <https://github.com/networkx/networkx/pull/1763>_]
Set up appveyor to automatically test installation on Windows machines.
Remove symbolic links in examples to help such installation.
Change many doc_string typos to allow sphinx
to build the docs without errors or warnings.
Enable the docs to be automatically built on
readthedocs.org by changing requirements.txt
Doc Release Api 1.4 (`doc/release/api_1.4.rst`)
NetworkX 1.4
Release date: 23 January 2011
New features
- :mod:
k-shell,k-crust,k-corona <networkx.algorithms.core> - :mod:
read GraphML files from yEd <networkx.readwrite.graphml> - :mod:
read/write GEXF format files <networkx.readwrite.gexf> - :mod:
find cycles in a directed graph <networkx.algorithms.cycles> - :mod:
DFS <networkx.algorithms.traversal.depth_first_search>and :mod:BFS <networkx.algorithms.traversal.breadth_first_search>algorithms - :mod:
chordal graph functions <networkx.algorithms.chordal.chordal_alg> - :mod:
Prim's algorithm for minimum spanning tree <networkx.algorithms.mst> - :mod:
r-ary tree generator <networkx.generators.classic> - :mod:
rich club coefficient <networkx.algorithms.richclub> - NumPy matrix version of :mod:
Floyd's algorithm for all-pairs shortest path <networkx.algorithms.shortest_paths.dense> - :mod:
read GIS shapefiles <networkx.readwrite.nx_shp> - :mod:
functions to get and set node and edge attributes <networkx.classes.function> - and more, see https://networkx.lanl.gov/trac/query?status=closed&group=milestone&milestone=networkx-1.4
API changes
- :mod:
gnp_random_graph() <networkx.generators.random_graphs>now takes a
directed=True|False keyword instead of create_using - :mod:
gnm_random_graph() <networkx.generators.random_graphs>now takes a
directed=True|False keyword instead of create_using
Algorithms changed
Shortest path
astar_path(), astar_path_length(), shortest_path(), shortest_path_length(),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bidirectional_shortest_path(), dijkstra_path(), dijkstra_path_length(),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bidirectional_dijkstra()
^^^^^^^^^^^^^^^^^^^^^^^^
These algorithms now raise an exception when a source and a target are
specified and no path exist between these two nodes. The exception is
a NetworkXNoPath exception.
Doc Release Api 1.5 (`doc/release/api_1.5.rst`)
NetworkX 1.5
Release date: 4 June 2011
Highlights
New featuresAlgorithms for :mod:
generating <networkx.generators.bipartite>
and :mod:analyzing <networkx.algorithms.bipartite>bipartite graphs:mod:
Maximal independent set <networkx.algorithms.mis>algorithm:mod:
Erdős-Gallai graphical degree sequence test <networkx.generators.degree_seq>:mod:
Negative edge cycle test <networkx.algorithms.shortest_paths.weighted>More memory efficient :mod:
Dijkstra path length <networkx.algorithms.shortest_paths.weighted>with cutoff parameter:mod:
Weighted clustering coefficient <networkx.algorithms.cluster>Read and write version 1.2 of :mod:
GEXF reader <networkx.readwrite.gexf>format:mod:
Neighbor degree correlation <networkx.algorithms.neighbor_degree>
that handle subsets of nodes:mod:
In-place node relabeling <networkx.relabel>Many 'weighted' graph algorithms now take optional parameter to use
specified edge attribute (default='weight')
(ticket https://networkx.lanl.gov/trac/ticket/509)Test for :mod:
distance regular <networkx.algorithms.distance_regular>graphsFast :mod:
directed Erdős-Renyi graph <networkx.generators.random_graphs>generatorFast :mod:
expected degree graph <networkx.generators.degree_seq>generator:mod:
Navigable small world <networkx.generators.geometric>generator:mod:
Waxman model <networkx.generators.geometric>generator:mod:
Geographical threshold graph <networkx.generators.geometric>generator:mod:
Karate Club, Florentine Families, and Davis' Women's Club <networkx.generators.social>graphs
Weighted graph algorithms
Many 'weighted' graph algorithms now take optional parameter to
specify which edge attribute should be used for the weight
(default='weight') (ticket https://networkx.lanl.gov/trac/ticket/509)
In some cases the parameter name was changed from weighted_edges,
or weighted, to weight. Here is how to specify which edge attribute
will be used in the algorithms:
Use weight=None to consider all weights equally (unweighted case)
Use weight=True or weight='weight' to use the 'weight' edge attribute
Use weight='other' to use the 'other' edge attribute
Algorithms affected are:
betweenness_centrality, closeness_centrality, edge_betweenness_centrality,
betweenness_centrality_subset, edge_betweenness_centrality_subset,
betweenness_centrality_source, load, closeness_vitality,
weiner_index, spectral_bipartivity
current_flow_betweenness_centrality,
edge_current_flow_betweenness_centrality,
current_flow_betweenness_centrality_subset,
edge_current_flow_betweenness_centrality_subset,
laplacian, normalized_laplacian, adj_matrix, adjacency_spectrum,
shortest_path, shortest_path_length, average_shortest_path_length,
single_source_dijkstra_path_basic, astar_path, astar_path_length
Random geometric graph
The random geometric graph generator has been simplified.
It no longer supports the create_using, repel, or verbose parameters.
An optional pos keyword was added to allow specification of node positions.
Bug fixes
- Fix edge handling for multigraphs in networkx/graphviz interface
(ticket https://networkx.lanl.gov/trac/ticket/507)
- Update networkx/pydot interface for new versions of pydot
(ticket https://networkx.lanl.gov/trac/ticket/506)
(ticket https://networkx.lanl.gov/trac/ticket/535)
- Fix negative cycle handling in Bellman-Ford
(ticket https://networkx.lanl.gov/trac/ticket/502)
- Write more attributes with GraphML and GML formats
(ticket https://networkx.lanl.gov/trac/ticket/480)
- Handle white space better in read_edgelist
(ticket https://networkx.lanl.gov/trac/ticket/513)
- Better parsing of Pajek format files
(ticket https://networkx.lanl.gov/trac/ticket/524)
(ticket https://networkx.lanl.gov/trac/ticket/542)
- Isolates functions work with directed graphs
(ticket https://networkx.lanl.gov/trac/ticket/526)
- Faster conversion to numpy matrices
(ticket https://networkx.lanl.gov/trac/ticket/529)
- Add graph['name'] and use properties to access Graph.name
(ticket https://networkx.lanl.gov/trac/ticket/544)
- Topological sort confused None and 0
(ticket https://networkx.lanl.gov/trac/ticket/546)
- GEXF writer mishandled weight=0
(ticket https://networkx.lanl.gov/trac/ticket/550)
- Speedup in SciPy version of PageRank
(ticket https://networkx.lanl.gov/trac/ticket/554)
- Numpy PageRank node order incorrect + speedups
(ticket https://networkx.lanl.gov/trac/ticket/555)
---
### Doc Release Api 1.6 (`doc/release/api_1.6.rst`)
NetworkX 1.6
============
Release date: 20 November 2011
HighlightsNew functions for finding articulation points, generating random bipartite graphs, constructing adjacency matrix representations, forming graph products, computing assortativity coefficients, measuring subgraph centrality and communicability, finding k-clique communities, and writing JSON format output.
New examples for drawing with D3 JavaScript library, and ordering matrices with the Cuthill-McKee algorithm.
More memory efficient implementation of current-flow betweenness and new approximation algorithms for current-flow betweenness and shortest-path betweenness.
Simplified handling of "weight" attributes for algorithms that use weights/costs/values.
Updated all code to work with the PyPy Python implementation http://pypy.org which produces faster performance on many algorithms.
Graph Classes
The degree* methods in the graph classes (Graph, DiGraph, MultiGraph,
MultiDiGraph) now take an optional weight= keyword that allows computing
weighted degree with arbitrary (numerical) edge attributes. Setting
weight=None is equivalent to the previous weighted=False.
Weighted graph algorithms
Many 'weighted' graph algorithms now take optional parameter to
specify which edge attribute should be used for the weight
(default='weight') (ticket https://networkx.lanl.gov/trac/ticket/573)
In some cases the parameter name was changed from weighted, to weight. Here is
how to specify which edge attribute will be used in the algorithms:
Use weight=None to consider all weights equally (unweighted case)
Use weight='weight' to use the 'weight' edge attribute
Use weight='other' to use the 'other' edge attribute
Algorithms affected are:
to_scipy_sparse_matrix,
clustering,
average_clustering,
bipartite.degree,
spectral_layout,
neighbor_degree,
is_isomorphic,
betweenness_centrality,
betweenness_centrality_subset,
vitality,
load_centrality,
mincost,
shortest_path,
shortest_path_length,
average_shortest_path_length
Isomorphisms
Node and edge attributes are now more easily incorporated into isomorphism
checks via the 'node_match' and 'edge_match' parameters. As part of this
change, the following classes were removed::
WeightedGraphMatcher
WeightedDiGraphMatcher
WeightedMultiGraphMatcher
WeightedMultiDiGraphMatcherThe function signature for 'is_isomorphic' is now simply::
is_isomorphic(g1, g2, node_match=None, edge_match=None)See its docstring for more details. To aid in the creation of 'node_match'
and 'edge_match' functions, users are encouraged to work with::
categorical_node_match
categorical_edge_match
categorical_multiedge_match
numerical_node_match
numerical_edge_match
numerical_multiedge_match
generic_node_match
generic_edge_match
generic_multiedge_matchThese functions construct functions which can be passed to 'is_isomorphic'.
Finally, note that the above functions are not imported into the top-level
namespace and should be accessed from 'networkx.algorithms.isomorphism'.
A useful import statement that will be repeated throughout documentation is::
import networkx.algorithms.isomorphism as isoOther
attracting_components
A list of lists is returned instead of a list of tuples.
condensation
The condensation algorithm now takes a second argument (scc) and returns a
graph with nodes labeled as integers instead of node tuples.degree connectivity
average_in_degree_connectivity and average_out_degree_connectivity have
been replaced withaverage_degree_connectivity(G, source='in', target='in')
and
average_degree_connectivity(G, source='out', target='out')
neighbor degree
average_neighbor_in_degree and average_neighbor_out_degreey have
have been replaced withaverage_neighbor_degree(G, source='in', target='in')
and
average_neighbor_degree(G, source='out', target='out')
Doc Release Api 1.7 (`doc/release/api_1.7.rst`)
NetworkX 1.7
Release date: 4 July 2012
Highlights
- New functions for k-clique community finding, flow hierarchy,
union, disjoint union, compose, and intersection operators that work on
lists of graphs, and creating the biadjacency matrix of a bipartite graph.
- New approximation algorithms for dominating set, edge dominating set,
independent set, max clique, and min-weighted vertex cover.
- Many bug fixes and other improvements.
For full details of the tickets closed for this release (added features and bug fixes) see:
https://networkx.lanl.gov/trac/query?status=closed&group=milestone&milestone=networkx-1.7
Other
-----
* Untested bipartite_random_regular_graph() removed.
---
### Doc Release Api 1.8 (`doc/release/api_1.8.rst`)
NetworkX 1.8
============
Release date: 28 July 2013
Highlights- Faster (linear-time) graphicality tests and Havel-Hakimi graph generators
- Directed Laplacian matrix generator
- Katz centrality algorithm
- Functions to generate all simple paths
- Improved shapefile reader
- More flexible weighted projection of bipartite graphs
- Faster topological sort, descendants and ancestors of DAGs
- Scaling parameter for force-directed layout
Bug fixes
- Error with average weighted connectivity for digraphs, correct normalized laplacian with self-loops, load betweenness for single node graphs, isolated nodes missing from dfs/bfs trees, normalize HITS using l1, handle density of graphs with self loops
- Cleaner handling of current figure status with Matplotlib, Pajek files now don't write troublesome header line, default alpha value for GEXF files, read curved edges from yEd GraphML
For full details of the issues closed for this release (added features and bug fixes) see: https://github.com/networkx/networkx/issues?milestone=1&page=1&state=closed
API changesLaplacian functions now all return matrices. To get a numpy array from a matrix use L = nx.laplacian_matrix(G).A
is_directed_acyclic_graph() now returns false on undirected graphs (instead of raising exception)
cycles returned from simple_cycles() do not include repeated last node
Doc Release Api 1.9 (`doc/release/api_1.9.rst`)
NetworkX 1.9
Release date: 21 June 2014
Support for Python 3.1 is dropped in this release.
Highlights
- Completely rewritten maximum flow and flow-based connectivity algorithms with
backwards incompatible interfaces - Community graph generators
- Stoer–Wagner minimum cut algorithm
- Linear-time Eulerian circuit algorithm
- Linear algebra package changed to use SciPy sparse matrices
- Algebraic connectivity, Fiedler vector, spectral ordering algorithms
- Link prediction algorithms
- Goldberg–Radzik shortest path algorithm
- Semiconnected graph and tree recognition algorithms
Flow package
The flow package (:samp:networkx.algorithms.flow) is completely rewritten
with backward incompatible changes. It introduces a new interface to flow
algorithms. Existing code that uses the flow package will not work unmodified
with NetworkX 1.9.
Main changes
We added two new maximum flow algorithms (:samp:
preflow_pushand
:samp:shortest_augmenting_path) and rewrote the Edmonds–Karp algorithm in
:samp:flow_fulkersonwhich is now in :samp:edmonds_karp.@ysitu <https://github.com/ysitu>_ contributed implementations of all new
maximum flow algorithms. The legacy Edmonds–Karp algorithm implementation in
:samp:ford_fulkersonis still available but will be removed in the next
release.All maximum flow algorithm implementations (including the legacy
:samp:ford_fulkerson) output now a residual network (i.e., a
:samp:DiGraph) after computing the maximum flow. See :samp:maximum_flow
documentation for the details on the conventions that NetworkX uses for
defining a residual network.We removed the old :samp:
max_flowand :samp:min_cutfunctions. The main
entry points to flow algorithms are now the functions :samp:maximum_flow,
:samp:maximum_flow_value, :samp:minimum_cutand
:samp:minimum_cut_value, which have new parameters that control maximum
flow computation: :samp:flow_funcfor specifying the algorithm that will
do the actual computation (it accepts a function as argument that implements
a maximum flow algorithm), :samp:cutofffor suggesting a maximum flow
value at which the algorithm stops, :samp:value_onlyfor stopping the
computation as soon as we have the value of the flow, and :samp:residual
that accepts as argument a residual network to be reused in repeated maximum
flow computation.All flow algorithms are required to accept arguments for these parameters
but may selectively ignored the inapplicable ones. For instance,
:samp:preflow_pushalgorithm can stop after the preflow phase without
computing a maximum flow if we only need the flow value, but both
:samp:edmonds_karpand :samp:shortest_augmenting_pathalways compute a
maximum flow to obtain the flow value.The new function :samp:
minimum_cutreturns the cut value and a node
partition that defines the minimum cut. The function
:samp:minimum_cut_valuereturns only the value of the cut, which is what
the removed :samp:min_cutfunction used to return before 1.9.The functions that implement flow algorithms (i.e., :samp:
preflow_push,
:samp:edmonds_karp, :samp:shortest_augmenting_pathand
:samp:ford_fulkerson) are not imported to the base NetworkX namespace. You
have to explicitly import them from the flow package:
from networkx.algorithms.flow import (ford_fulkerson, preflow_push,
... edmonds_karp, shortest_augmenting_path) # doctest: +SKIP
- We also added a capacity-scaling minimum cost flow algorithm:
:samp:capacity_scaling. It supports :samp:MultiDiGraphand disconnected
networks.
Examples
Below are some small examples illustrating how to obtain the same output than in
NetworkX 1.8.1 using the new interface to flow algorithms introduced in 1.9:
import networkx as nx
G = nx.icosahedral_graph()
nx.set_edge_attributes(G, 'capacity', 1)
With NetworkX 1.8:
flow_value = nx.max_flow(G, 0, 6) # doctest: +SKIP
cut_value = nx.min_cut(G, 0, 6) # doctest: +SKIP
flow_value == cut_value # doctest: +SKIP
True
flow_value, flow_dict = nx.ford_fulkerson(G, 0, 6) # doctest: +SKIP
With NetworkX 1.9:
from networkx.algorithms.flow import (ford_fulkerson, preflow_push,
... edmonds_karp, shortest_augmenting_path) # doctest: +SKIP
flow_value = nx.maximum_flow_value(G, 0, 6) # doctest: +SKIP
cut_value = nx.minimum_cut_value(G, 0, 6) # doctest: +SKIP
flow_value == cut_value # doctest: +SKIP
TrueLegacy: this returns the exact same output than ford_fulkerson in 1.8.1
flow_value, flow_dict = nx.maximum_flow(G, 0, 6, flow_func=ford_fulkerson) # doctest: +SKIP
We strongly recommend to use the new algorithms:
flow_value, flow_dict = nx.maximum_flow(G, 0, 6) # doctest: +SKIP
If no flow_func is passed as argument, the default flow_func
(preflow-push) is used. Therefore this is the same than:
flow_value, flow_dict = nx.maximum_flow(G, 0, 6, flow_func=preflow_push) # doctest: +SKIP
You can also use alternative maximum flow algorithms:
flow_value, flow_dict = nx.maximum_flow(G, 0, 6, flow_func=shortest_augmenting_path) # doctest: +SKIP
flow_value, flow_dict = nx.maximum_flow(G, 0, 6, flow_func=edmonds_karp) # doctest: +SKIP
Connectivity package
The flow-based connectivity and cut algorithms from the connectivity
package (:samp:networkx.algorithms.connectivity) are adapted to take
advantage of the new interface to flow algorithms. As a result, flow-based
connectivity algorithms are up to 10x faster than in NetworkX 1.8 for some
problems, such as sparse networks with highly skewed degree distributions.
A few backwards incompatible changes were introduced.
The functions for local connectivity and cuts accept now
arguments for the new parameters defined for the flow interface:
:samp:flow_funcfor defining the algorithm that will perform the
underlying maximum flow computations, :samp:residualthat accepts
as argument a residual network to be reused in repeated maximum
flow computations, and :samp:cutofffor defining a maximum flow
value at which the underlying maximum flow algorithm stops. The big
speed improvement with respect to 1.8 comes mainly from the reuse
of the residual network and the use of :samp:cutoff.We removed the flow-based local connectivity and cut functions from
the base namespace. Now they have to be explicitly imported from the
connectivity package. The main entry point to flow-based connectivity
and cut functions are the functions :samp:edge_connectivity,
:samp:node_connectivity, :samp:minimum_edge_cut, and
:samp:minimum_node_cut. All these functions accept a couple of nodes
as optional arguments for computing local connectivity and cuts.We improved the auxiliary network for connectivity functions: The node
mapping dict needed for node connectivity and minimum node cuts is now a
graph attribute of the auxiliary network. Thus we removed the
:samp:mappingparameter from the local versions of connectivity and cut
functions. We also changed the parameter name for the auxiliary digraph
from :samp:aux_digraphto :samp:auxiliary.We changed the name of the function :samp:
all_pairs_node_connectivity_matrix
to :samp:all_pairs_node_connectivity. This function now returns a dictionary
instead of a NumPy 2D array. We added a new parameter :samp:nbunchfor
computing node connectivity only among pairs of nodes in :samp:nbunch.A :samp:
stoer_wagnerfunction is added to the connectivity package
for computing the weighted minimum cuts of undirected graphs using
the Stoer–Wagner algorithm. This algorithm is not based on maximum flows.
Several heap implementations are also added in the utility package
(:samp:networkx.utils) for use in this function.
:class:BinaryHeapis recommended over :class:PairingHeapfor Python
implementations without optimized attribute accesses (e.g., CPython)
despite a slower asymptotic running time. For Python implementations
with optimized attribute accesses (e.g., PyPy), :class:PairingHeap
provides better performance.
Other new functionalities
A :samp:
dispersonfunction is added in the centrality package
(:samp:networkx.algorithms.centrality) for computing the dispersion of
graphs.A community package (:samp:
networkx.generators.community) is added for
generating community graphs.An :samp:
is_semiconnectedfunction is added in the connectivity package
(:samp:networkx.algorithms.connectivity) for recognizing semiconnected
graphs.The :samp:
eulerian_circuitfunction in the Euler package
(:samp:networkx.algorithm.euler) is changed to use a linear-time algorithm.A :samp:
non_edgesfunction in added in the function package
(:samp:networkx.functions) for enumerating nonexistent edges between
existing nodes of graphs.The linear algebra package (:samp:
networkx.linalg) is changed to use SciPy
sparse matrices.Functions :samp:
algebraic_connectivity, :samp:fiedler_vectorand
:samp:spectral_orderingare added in the linear algebra package
(:samp:networkx.linalg) for computing the algebraic connectivity, Fiedler
vectors and spectral orderings of undirected graphs.A link prediction package (:samp:
networkx.algorithms.link_prediction) is
added to provide link prediction-related functionalities.Write Support for the graph6 and sparse6 formats is added in the read/write
package (:samp:networkx.readwrite).A :samp:
goldberg_radzikfunction is added in the shortest path package
(:samp:networkx.algorithms.shortest_paths) for computing shortest paths
using the Goldberg–Radzik algorithm.A tree package (:samp:
networkx.tree) is added to provide tree recognition
functionalities.A context manager :samp:
reversedis added in the utility package
(:samp:networkx.utils) for temporary in-place reversal of graphs.
Miscellaneous changes
The functions in the components package
(:samp:networkx.algorithms.components) such as :samp:connected_components,
:samp:connected_components_subgraphnow return generators instead of lists.
To recover the earlier behavior, use :samp:list(connected_components(G)).JSON helpers in the JSON graph package (:samp:
networkx.readwrite.json_graph)
are removed. Use functions from the standard library (e.g.,
:samp:json.dumps) instead.Support for Python 3.1 is dropped. Basic support is added for Jython 2.7 and
IronPython 2.7, although they remain not officially supported.Numerous reported issues are fixed.
Doc Release Index (`doc/release/index.rst`)
Releases
We don't use semantic versioning. The first number indicates that we have
made a major API break (e.g., 1.x to 2.x), which happens rarely.
The point releases are new versions and may contain minor API breakage.
Usually, this happens after a two cycle deprecation period.
.. warning::
Since we don't normally make bug-fix only releases, it may not make sense
for you to use ~= as a pip version specifier.
.. toctree::
:maxdepth: 2
release_3.7
release_3.6.1
release_3.6
release_3.5
release_3.4.2
release_3.4.1
release_3.4
release_3.3
release_3.2.1
release_3.2
release_3.1
release_3.0
release_2.8.8
release_2.8.7
release_2.8.6
release_2.8.5
release_2.8.4
release_2.8.3
release_2.8.2
release_2.8.1
release_2.8
release_2.7.1
release_2.7
release_2.6
release_2.5
release_2.4
release_2.3
release_2.2
release_2.1
release_2.0
api_1.11
api_1.10
api_1.9
api_1.8
api_1.7
api_1.6
api_1.5
api_1.4
api_1.0
api_0.99
old_release_log
Doc Release Migration Guide From 1.X To 2.0 (`doc/release/migration_guide_from_1.x_to_2.0.rst`)
:orphan:
Migration guide from 1.X to 2.0
This is a guide for people moving from NetworkX 1.X to NetworkX 2.0
Any issues with these can be discussed on the mailing list <https://groups.google.com/forum/#!forum/networkx-discuss>_.
At the bottom of this document we discuss how to create code that will
work with both NetworkX v1.x and v2.0.
We have made some major changes to the methods in the Multi/Di/Graph classes.
The methods changed are explained with examples below.
With the release of NetworkX 2.0 we are moving to a view/iterator reporting API.
We have changed many methods from reporting lists or dicts to iterating over
the information. Most of the changes in this regard are in the base classes.
Methods that used to return containers now return views (inspired fromdictionary views <https://docs.python.org/3/library/stdtypes.html#dict-views>_
in Python) and methods that returned an iterator have been removed.
The methods which create new graphs have changed in the depth of data copying.G.subgraph/edge_subgraph/reverse/to_directed/to_undirected
are affected. Many now have options for view creation instead of copying data.
The depth of the data copying may have also changed.
One View example is G.nodes (or G.nodes()) which now returns a
dict-like NodeView while G.nodes_iter() has been removed. Similarly
for views with G.edges and removing G.edges_iter.
The Graph attributes G.node and G.edge have been removed in favor of
using G.nodes[n] and G.edges[u, v].
Finally, the selfloop methods and add_path/star/cycle have
been moved from graph methods to networkx functions.
We expect that these changes will break some code. We have tried to make
them break the code in ways that raise exceptions, so it will be obvious
that code is broken.
There are also a number of improvements to the codebase outside of the base
graph classes. These are too numerous to catalog here, but a couple obvious
ones include:
- centering of nodes in
drawing/nx_pylab, - iterator vs dict output from a few
shortest_pathroutines
Some demonstrations:
>>> import networkx as nx
>>> G = nx.complete_graph(5)
>>> G.nodes # for backward compatibility G.nodes() works as well
NodeView((0, 1, 2, 3, 4))You can iterate through G.nodes (or G.nodes())
>>> for node in G.nodes:
... print(node)
0
1
2
3
4If you want a list of nodes you can use the Python list function
>>> list(G.nodes)
[0, 1, 2, 3, 4]G.nodes is set-like allowing set operations. It is also dict-like in that you
can look up node data with G.nodes[n]['weight']. You can still use the calling
interface G.nodes(data='weight') to iterate over node/data pairs. In addition
to the dict-like views keys/values/items, G.nodes has a data-view
G.nodes.data('weight'). The new EdgeView G.edges has similar features for edges.
By adding views NetworkX supports some new features like set operations on
views.
>>> H = nx.Graph()
>>> H.add_nodes_from([1, 'networkx', '2.0'])
>>> G.nodes & H.nodes # finding common nodes in 2 graphs
{1}
>>> # union of nodes in 2 graphs
>>> G.nodes | H.nodes # doctest: +SKIP
{0, 1, 2, 3, 4, 'networkx', '2.0'}Similarly, G.edges now returns an EdgeView instead of a list of edges and it
also supports set operations.
>>> G.edges # for backward compatibility G.nodes() works as well
EdgeView([(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)])
>>> list(G.edges)
[(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]G.degree now returns a DegreeView. This is less dict-like than the other views
in the sense that it iterates over (node, degree) pairs, does not provide
keys/values/items/get methods. It does provide lookup G.degree[n] and(node, degree) iteration. A dict keyed by nodes to degree values can be
easily created if needed as dict(G.degree).
>>> G.degree # for backward compatibility G.degree() works as well
DegreeView({0: 4, 1: 4, 2: 4, 3: 4, 4: 4})
>>> G.degree([1, 2, 3])
DegreeView({1: 4, 2: 4, 3: 4})
>>> list(G.degree([1, 2, 3]))
[(1, 4), (2, 4), (3, 4)]
>>> dict(G.degree([1, 2, 3]))
{1: 4, 2: 4, 3: 4}
>>> G.degree
DegreeView({0: 4, 1: 4, 2: 4, 3: 4, 4: 4})
>>> list(G.degree)
[(0, 4), (1, 4), (2, 4), (3, 4), (4, 4)]
>>> dict(G.degree)
{0: 4, 1: 4, 2: 4, 3: 4, 4: 4}The degree of an individual node can be calculated by G.degree[node].
Similar changes have been made to in_degree and out_degree
for directed graphs. If you want just the degree values, here are some options.
They are shown for in_degree of a DiGraph, but similar ideas work
for out_degree and degree
>>> DG = nx.DiGraph()
>>> DG.add_weighted_edges_from([(1, 2, 0.5), (3, 1, 0.75)])
>>> deg = DG.in_degree # sets up the view
>>> [d for n, d in deg] # gets all nodes' degree values
[1, 1, 0]
>>> (d for n, d in deg) # iterator over degree values
<generator object <genexpr> ...>
>>> [deg[n] for n in [1, 3]] # using lookup for only some nodes
[1, 0]
>>> for node, in_deg in dict(DG.in_degree).items(): # works for nx1 and nx2
... print(node, in_deg)
1 1
2 1
3 0
>>> dict(DG.in_degree([1, 3])).values() # works for nx1 and nx2
dict_values([1, 0])
>>> # DG.in_degree(nlist) creates a restricted view for only nodes in nlist.
>>> # but see the fourth option above for using lookup instead.
>>> list(d for n, d in DG.in_degree([1, 3]))
[1, 0]
>>> [len(nbrs) for n, nbrs in DG.pred.items()] # probably slightly fastest for all nodes
[1, 1, 0]
>>> [len(DG.pred[n]) for n in [1, 3]] # probably slightly faster for only some nodes
[1, 0]If n is a node in G, then G.neighbors(n) returns an iterator.
>>> n = 1
>>> G.neighbors(n)
<dict_keyiterator object at ...>
>>> list(G.neighbors(n))
[0, 2, 3, 4]DiGraphViews behave similar to GraphViews, but have a few more methods.
>>> D = nx.DiGraph()
>>> D.add_edges_from([(1, 2), (2, 3), (1, 3), (2, 4)])
>>> D.nodes
NodeView((1, 2, 3, 4))
>>> list(D.nodes)
[1, 2, 3, 4]
>>> D.edges
OutEdgeView([(1, 2), (1, 3), (2, 3), (2, 4)])
>>> list(D.edges)
[(1, 2), (1, 3), (2, 3), (2, 4)]
>>> D.in_degree[2]
1
>>> D.out_degree[2]
2
>>> D.in_edges
InEdgeView([(1, 2), (2, 3), (1, 3), (2, 4)])
>>> list(D.in_edges())
[(1, 2), (2, 3), (1, 3), (2, 4)]
>>> D.out_edges(2)
OutEdgeDataView([(2, 3), (2, 4)])
>>> list(D.out_edges(2))
[(2, 3), (2, 4)]
>>> D.in_degree
InDegreeView({1: 0, 2: 1, 3: 2, 4: 1})
>>> list(D.in_degree)
[(1, 0), (2, 1), (3, 2), (4, 1)]
>>> D.successors(2)
<dict_keyiterator object at ...>
>>> list(D.successors(2))
[3, 4]
>>> D.predecessors(2)
<dict_keyiterator object at ...>
>>> list(D.predecessors(2))
[1]The same changes apply to MultiGraphs and MultiDiGraphs.
The order of arguments to set_edge_attributes and set_node_attributes has
changed. The position of name and values has been swapped, and name now
defaults to None. The previous call signature of (graph, name, value) has
been changed to (graph, value, name=None). The new style allows for name to
be omitted in favor of passing a dictionary of dictionaries to values.
A simple method for migrating existing code to the new version is to explicitly
specify the keyword argument names. This method is backwards compatible and
ensures the correct arguments are passed, regardless of the order. For example the old code
>>> G = nx.Graph([(1, 2), (1, 3)])
>>> nx.set_node_attributes(G, 'label', {1: 'one', 2: 'two', 3: 'three'}) # doctest: +SKIP
>>> nx.set_edge_attributes(G, 'label', {(1, 2): 'path1', (2, 3): 'path2'}) # doctest: +SKIPWill cause TypeError: unhashable type: 'dict' in the new version. The code
can be refactored as
>>> G = nx.Graph([(1, 2), (1, 3)])
>>> nx.set_node_attributes(G, name='label', values={1: 'one', 2: 'two', 3: 'three'})
>>> nx.set_edge_attributes(G, name='label', values={(1, 2): 'path1', (2, 3): 'path2'})Some methods have been moved from the base graph class into the main namespace.
These are: G.add_path, G.add_star, G.add_cycle, G.number_of_selfloops,G.nodes_with_selfloops, and G.selfloop_edges.
They are replaced by nx.path_graph(G, ...) nx.add_star(G, ...),nx.selfloop_edges(G), etc.
For backward compatibility, we are leaving them as deprecated methods.
With the new GraphViews (SubGraph, ReversedGraph, etc) you can't assume thatG.__class__() will create a new instance of the same graph type as G.
In fact, the call signature for __class__ differs depending on whether G
is a view or a base class. For v2.x you should use G.fresh_copy() to
create a null graph of the correct type---ready to fill with nodes and edges.
Graph views can also be views-of-views-of-views-of-graphs. If you want to find the
original graph at the end of this chain use G.root_graph. Be careful though
because it may be a different graph type (directed/undirected) than the view.
topological_sort no longer accepts reverse or nbunch arguments.
If nbunch was a single node source, then the same effect can now be achieved
using the subgraph operator:
nx.topological_sort(G.subgraph(nx.descendants(G, nbunch)))To achieve a reverse topological sort, the output should be converted to a list:
reversed(list(nx.topological_sort(G)))Writing code that works for both versions
Methods set_node_attributes/get_node_attributes/set_edge_attributes/get_edge_attributes
have changed the order of their keyword arguments name and values. So, to make it
work with both versions you should use the keywords in your call.
>>> nx.set_node_attributes(G, values=1.0, name='weight')Change any method with _iter in its name to the version without _iter.
In v1 this replaces an iterator by a list, but the code will still work.
In v2 this creates a view (which acts like an iterator).
Replace any use of G.edge with G.adj. The Graph attribute edge
has been removed. The attribute G.adj is G.edge in v1 and will work
with both versions.
If you use G.node.items() or similar in v1.x, you can replace it withG.nodes(data=True) which works for v2.x and v1.x. Iterating over G.node``` as in for n in G.node:can be replaced withG, as in: for n in G:``.
The Graph attribute node has moved its functionality to G.nodes, so code
expected to work with v2.x should use G.nodes.
In fact most uses of G.node can be replaced by an idiom that works for both
versions. The functionality that can't easily is: G.node[n].
In v2.x that becomes G.nodes[n] which doesn't work in v1.x.
Luckily you can still use G.node[n] in v2.x when you want it to be able to work
with v1.x too. We have left G.node in v2.x as a transition pointer to G.nodes.
We envision removing G.node in v3.x (sometime in the future).
Copying node attribute dicts directly from one graph to another can corrupt
the node data structure if not done correctly. Code such as the following:
>>> # dangerous in v1.x, not allowed in v2.x
>>> G.node[n] = H.node[n] # doctest: +SKIPused to work, even though it could cause errors if n was not a node in G.
That code will cause an error in v2.x. Replace it with one of the more safe versions:
>>> G.nodes[n].update(H.nodes[n]) # works in v2.xThe methods removed from the graph classes and put into the main package namespace
can be used via the associated deprecated methods. If you want to update your code
to the new functions, one hack to make that work with both versions is to write
your code for v2.x and add code to the v1 namespace in an ad hoc manner:
>>> if nx.__version__[0] == '1':
... nx.add_path = lambda G, nodes: G.add_path(nodes)Similarly, v2.x code that uses G.fresh_copy() or G.root_graph is hard to make
work for v1.x. It may be best in this case to determine the graph type you want
explicitly and call Graph/DiGraph/MultiGraph/MultiDiGraph directly.
Using Pickle with v1 and v2
The Pickle protocol does not store class methods, only the data. So if you write a
pickle file with v1 you should not expect to read it into a v2 Graph. If this happens
to you, read it in with v1 installed and write a file with the node and edge
information. You can read that into a config with v2 installed and then add those nodes
and edges to a fresh graph. Try something similar to this:
>>> # in v1.x
>>> pickle.dump([G.nodes(data=True), G.edges(data=True)], file) # doctest: +SKIP
>>> # then in v2.x
>>> nodes, edges = pickle.load(file) # doctest: +SKIP
>>> G = nx.Graph() # doctest: +SKIP
>>> G.add_nodes_from(nodes) # doctest: +SKIP
>>> G.add_edges_from(edges) # doctest: +SKIPDoc Release Migration Guide From 2.X To 3.0 (`doc/release/migration_guide_from_2.x_to_3.0.rst`)
:orphan:
Migration guide from 2.X to 3.0
.. note::
Much of the work leading to the NetworkX 3.0 release will be included
in the NetworkX 2.6, 2.7, and 2.8 releases. For example, we are deprecating a lot
of old code in these releases. This guide will discuss this
ongoing work and will help you understand what changes you can make now
to minimize the disruption caused by the move to 3.0.
This is a guide for people moving from NetworkX 2.X to NetworkX 3.0.
Any issues with these can be discussed on the mailing list <https://groups.google.com/forum/#!forum/networkx-discuss>_.
The focus of 3.0 release is on addressing years of technical debt, modernizing our codebase,
improving performance, and making it easier to contribute.
We plan to release 3.0 in the summer.
Default dependencies
We no longer depend on the "decorator" library, thus NetworkX no longer has
any dependencies.
However, NetworkX 3.0 includes many changes and improvements centered around
tighter integration with other scientific Python libraries; namelynumpy, scipy, matplotlib, and pandas.
There are no dependencies for NetworkX's core functionality, such as the data
structures (Graph, DiGraph, etc.) and common algorithms, but some
functionality, e.g. functions found in the networkx.linalg package, are
only available if these additional libraries are installed.
Improved integration with scientific Python
NetworkX 3.0 includes several changes to improve and modernize the usage ofnumpy and scipy within networkx.
:ref:
Removal of matrix semantics <matrix-to-array>.- Removing all uses of
numpy.matrixin favor ofnumpy.ndarray. - Adoption of the scipy.sparse array interface.
- Removing all uses of
:ref:
NumPy or SciPy implementations of some algorithms by default (e.g. pagerank) <scipy-default-impl>.numpy.random.Generatorsupport for random number generation.:ref:
Replace recarray support <recarray-to-structured>with more generic
support for structured dtypes.
.. _matrix-to-array:
Replacing NumPy/SciPy matrices with arrays
The numpy.matrix has long been discouraged due to significant departures
from the ndarray interface, namely:
- Matrices are always two-dimensional, leading to different results for common
operations like indexing and broadcasting. - The multiplication operator is interpreted as matrix multiplication rather
than element-wise multiplication.
These differences make code more difficult to understand and often require
boilerplate in order to work with multiple formats.
With the addition of a sparse array interface in scipy version 1.8, NetworkX
3.0 has replaced all instances of scipy sparse matrices and numpy matrices
in favor of their array counterparts.
Any functions that returned either scipy.sparse.spmatrix or numpy.matrix
objects now return their corresponding array counterparts (scipy.sparse._sparray
and numpy.ndarray, respectively) and explicit conversion functions that
resulted in matrix objects have been removed (e.g. to_numpy_matrix).
Users should expect all numpy and scipy.sparse objects to obey
array semantics in NetworkX 3.X.
.. _scipy-default-impl:
Switch to NumPy/SciPy implementations by default for some algorithms
Some networkx analysis algorithms can be implemented with very high performance
using linear algebra, such as the pagerank algorithm.
In NetworkX 2.0, there were multiple implementations of the pagerank
algorithm: pagerank (a pure-Python implementation), pagerank_numpy
(for dense adjacency matrices), and pagerank_scipy (sparse adjacency
matrices).
In all practical use-cases, the SciPy implementation vastly outperforms the
others.
In NetworkX 3.0, the ~networkx.algorithms.link_analysis.pagerank_alg.pagerank
function now uses the SciPy implementation by default.
This means that calling nx.pagerank now requires SciPy to be installed.
The original Python implementation is still available for pedagogical
purposes as networkx.algorithms.link_analysis.pagerank_alg._pagerank_python
but is not exposed publicly to discourage it's use.
Supporting `numpy.random.Generator`
NumPy v1.17 introduced a new interface for pseudo-random number generation.
The ~networkx.utils.misc.py_random_state and ~networkx.utils.misc.np_random_state
decorators have added support for the new numpy.random.Generator instances;
in other words, the seed argument now accepts numpy.random.Generator instances::
>>> G = nx.barbell_graph(6, 2)
>>> pos = nx.spring_layout(G, seed=np.random.default_rng(123456789))The numpy.random.Generator interface includes several improvements over the
original numpy.random.RandomState, including better statistical properties
and improved performance.
However Generator is not stream-compatible with RandomState and
does not guarantee stream-compatibility with future versions of NumPy.
Therefore, the best-practice is to be explicit when using random number
generators.
To guarantee exact reproducibility of random numbers across all versions
of NetworkX (past and future), RandomState is recommended::
>>> rng = np.random.RandomState(12345)
>>> pos = nx.spring_layout(G, seed=rng)For new code where exact stream-reproducibility is less important,Generator is recommended::
>>>> rng = np.random.default_rng(12345)
>>> pos = nx.spring_layout(G, seed=rng).. note:: Exact reproducibility of random numbers with Generator is still
possible but may require specific versions of numpy to be installed.
.. _recarray-to-structured:
NumPy structured dtypes for multi-attribute adjacency matrices
Prior to NetworkX 3.0, multi-attribute adjacency matrices were supported
through the nx.to_numpy_recarray conversion function.numpy.recarray is a convenience wrapper around ndarray with structured
dtypes.
As such, thisconversion function has been removed in NetworkX 3.0 and support
for structured dtypes has been added to to_numpy_array instead, generally
improving supported for array representations of multi-attribute adjacency::
>>> import numpy as np
>>> edges = [
... (0, 1, {"weight": 10, "cost": 2}),
... (1, 2, {"weight": 5, "cost": 100})
... ]
>>> G = nx.Graph(edges)
>>> # Create an adjacency matrix with "weight" and "cost" attributes
>>> dtype = np.dtype([("weight", float), ("cost", int)])
>>> A = nx.to_numpy_array(G, dtype=dtype, weight=None)
>>> A
array([[( 0., 0), (10., 2), ( 0., 0)],
[(10., 2), ( 0., 0), ( 5., 100)],
[( 0., 0), ( 5., 100), ( 0., 0)]],
dtype=[('weight', '<f8'), ('cost', '<i8')])
>>> A["cost"]
array([[ 0, 2, 0],
[ 2, 0, 100],
[ 0, 100, 0]])
>>> # The recarray interface can be recovered with ``view``
>>> A = nx.to_numpy_array(G, dtype=dtype, weight=None).view(np.recarray)
>>> A
rec.array([[( 0., 0), (10., 2), ( 0., 0)],
[(10., 2), ( 0., 0), ( 5., 100)],
[( 0., 0), ( 5., 100), ( 0., 0)]],
dtype=[('weight', '<f8'), ('cost', '<i8')])
>>> A.weight
array([[ 0., 10., 0.],
[10., 0., 5.],
[ 0., 5., 0.]])Deprecated code
The functions read_gpickle and write_gpickle were removed in 3.0.
You can read and write NetworkX graphs as Python pickles.
import pickle
G = nx.path_graph(4)
with open('test.gpickle', 'wb') as f:
... pickle.dump(G, f, pickle.HIGHEST_PROTOCOL)
...
with open('test.gpickle', 'rb') as f:
... G = pickle.load(f)
...
The functions read_yaml and write_yaml were removed in 3.0.
You can read and write NetworkX graphs in YAML format
using pyyaml.
import yaml
G = nx.path_graph(4)
with open('test.yaml', 'w') as f:
... yaml.dump(G, f)
...
with open('test.yaml', 'r') as f:
... G = yaml.load(f, Loader=yaml.Loader)
Doc Release Old Release Log (`doc/release/old_release_log.rst`)
.. currentmodule:: networkx
Old Release Log
NetworkX 2.5
Release date: 22 August 2020
Supports Python 3.6, 3.7, and 3.8.
Release notes
See :doc:`release_2.5`.
NetworkX 2.4
------------
Release date: 16 October 2019
Supports Python 3.5, 3.6, 3.7, and 3.8.
This is the last release to support Python 3.5.
Release notesSee :doc:release_2.4.
NetworkX 2.3
Release date: 11 April 2019
Supports Python 3.5, 3.6 and 3.7.
This is our first Python 3 only release.
Release notes
See :doc:`release_2.3`.
NetworkX 2.2
------------
Release date: 19 September 2018
Supports Python 2.7, 3.5, 3.6 and 3.7.
This is the last release to support Python 2.
Release notesSee :doc:release_2.2.
NetworkX 2.1
Release date: 22 January 2018
Supports Python 2.7, 3.4, 3.5, and 3.6.
Release notes
See :doc:`release_2.1`.
NetworkX 2.0
------------
Release date: 20 September 2017
Support for Python 3.6 added, drop support for Python 3.3.
See :doc:`migration_guide_from_1.x_to_2.0`.
Release notesSee :doc:release_2.0.
NetworkX 1.11
Release date: 30 January 2016
Support for Python 3.5 added, drop support for Python 3.2.
Highlights
Pydot features now use pydotplus.
Fixes installation on some machines and test with appveyor.
Restores default center and scale of layout routines.
Fixes various docs including no symbolic links in examples.
Docs can now build using autosummary on readthedocs.org.
NetworkX 1.10
--------------
Release date: 2 August 2015
Support for Python 2.6 is dropped in this release.
HighlightsConnected components now return generators
new functions including
- enumerate_all_cliques, greedy_coloring, edge_dfs, find_cycle
immediate_dominators, harmonic_centrality - Hopcraft--Karp algorithm for maximum matchings
- optimum branchings and arborescences.
- all_simple_paths
- enumerate_all_cliques, greedy_coloring, edge_dfs, find_cycle
pyparsing dependence removed from GML reader/parser
improve flow algorithms
new generators related to expander graphs.
new generators for multipartite graphs, nonisomorphic trees,
circulant graphsallow graph subclasses to use dict-like objects in place of dicts
added ordered graph subclasses
pandas dataframe read/write added.
data keyword in G.edges() allows requesting edge attribute directly
expanded layout flexibility for node subsets
Kanesky's algorithm for cut sets and k_components
power function for graphs
approximation of node connectivity
transitive closure, triadic census and antichains
quotient graphs and minors
longest_path for DAGS
modularity matrix routines
API changes
See :doc:`api_1.10`.
NetworkX 1.9.1
--------------
Release date: 13 September 2014
Bugfix release for minor installation and documentation issues.
NetworkX 1.9
------------
Release date: 21 June 2014
Support for Python 3.1 is dropped in this release.
Highlights
~~~~~~~~~~
- Completely rewritten maximum flow and flow-based connectivity algorithms with
backwards incompatible interfaces
- Community graph generators
- Stoer–Wagner minimum cut algorithm
- Linear-time Eulerian circuit algorithm
- Linear algebra package changed to use SciPy sparse matrices
- Algebraic connectivity, Fiedler vector, spectral ordering algorithms
- Link prediction algorithms
- Goldberg–Radzik shortest path algorithm
- Semiconnected graph and tree recognition algorithms
API changesSee :doc:api_1.9.
NetworkX 1.8.1
Release date: 4 August 2013
Bugfix release for missing files in source packaging.
NetworkX 1.8
Release date: 28 July 2013
Highlights
- Faster (linear-time) graphicality tests and Havel-Hakimi graph generators
- Directed Laplacian matrix generator
- Katz centrality algorithm
- Functions to generate all simple paths
- Improved shapefile reader
- More flexible weighted projection of bipartite graphs
- Faster topological sort, descendants and ancestors of DAGs
- Scaling parameter for force-directed layout
Bug fixes
~~~~~~~~~
- Error with average weighted connectivity for digraphs, correct normalized laplacian with self-loops, load betweenness for single node graphs, isolated nodes missing from dfs/bfs trees, normalize HITS using l1, handle density of graphs with self loops
- Cleaner handling of current figure status with Matplotlib, Pajek files now don't write troublesome header line, default alpha value for GEXF files, read curved edges from yEd GraphML
For full details of the issues closed for this release (added features and bug fixes) see: https://github.com/networkx/networkx/issues?milestone=1&page=1&state=closed
API changesSee :doc:api_1.8
NetworkX 1.7
Release date: 4 July 2012
Highlights
- New functions for k-clique community finding, flow hierarchy,
union, disjoint union, compose, and intersection operators that work on
lists of graphs, and creating the biadjacency matrix of a bipartite graph.
- New approximation algorithms for dominating set, edge dominating set,
independent set, max clique, and min-weighted vertex cover.
- Many bug fixes and other improvements.
For full details of the tickets closed for this release (added features and bug fixes) see:
https://networkx.lanl.gov/trac/query?status=closed&group=milestone&milestone=networkx-1.7
API changesSee :doc:api_1.7
NetworkX 1.6
Release date: 20 November 2011
Highlights
New functions for finding articulation points, generating random bipartite graphs, constructing adjacency matrix representations, forming graph products, computing assortativity coefficients, measuring subgraph centrality and communicability, finding k-clique communities, and writing JSON format output.
New examples for drawing with D3 JavaScript library, and ordering matrices with the Cuthill-McKee algorithm.
More memory efficient implementation of current-flow betweenness and new approximation algorithms for current-flow betweenness and shortest-path betweenness.
Simplified handling of "weight" attributes for algorithms that use weights/costs/values. See :doc:`api_1.6`.
Updated all code to work with the PyPy Python implementation http://pypy.org which produces faster performance on many algorithms.
For full details of the tickets closed for this release (added features and bug fixes) see:
https://networkx.lanl.gov/trac/query?status=closed&group=milestone&milestone=networkx-1.6
API changesSee :doc:api_1.6
NetworkX 1.5
Release date: 4 June 2011
For full details of the tickets closed for this release see:
https://networkx.lanl.gov/trac/query?status=closed&group=milestone&milestone=networkx-1.5
Highlights
New featuresAlgorithms for :mod:
generating <networkx.generators.bipartite>
and :mod:analyzing <networkx.algorithms.bipartite>bipartite graphs:mod:
Maximal independent set <networkx.algorithms.mis>algorithm:mod:
Erdős-Gallai graphical degree sequence test <networkx.generators.degree_seq>:mod:
Negative edge cycle test <networkx.algorithms.shortest_paths.weighted>More memory efficient :mod:
Dijkstra path length <networkx.algorithms.shortest_paths.weighted>with cutoff parameter:mod:
Weighted clustering coefficient <networkx.algorithms.cluster>Read and write version 1.2 of :mod:
GEXF reader <networkx.readwrite.gexf>format:mod:
Neighbor degree correlation <networkx.algorithms.neighbor_degree>
that handle subsets of nodes:mod:
In-place node relabeling <networkx.relabel>Many 'weighted' graph algorithms now take optional parameter to use
specified edge attribute (default='weight')
(ticket https://networkx.lanl.gov/trac/ticket/509)Test for :mod:
distance regular <networkx.algorithms.distance_regular>graphsFast :mod:
directed Erdős-Renyi graph <networkx.generators.random_graphs>generatorFast :mod:
expected degree graph <networkx.generators.degree_seq>generator:mod:
Navigable small world <networkx.generators.geometric>generator:mod:
Waxman model <networkx.generators.geometric>generator:mod:
Geographical threshold graph <networkx.generators.geometric>generator:mod:
Karate Club, Florentine Families, and Davis' Women's Club <networkx.generators.social>graphs
API changes
See :doc:`api_1.5`
Bug fixes
~~~~~~~~~
- Fix edge handling for multigraphs in networkx/graphviz interface
(ticket https://networkx.lanl.gov/trac/ticket/507)
- Update networkx/pydot interface for new versions of pydot
(ticket https://networkx.lanl.gov/trac/ticket/506)
(ticket https://networkx.lanl.gov/trac/ticket/535)
- Fix negative cycle handling in Bellman-Ford
(ticket https://networkx.lanl.gov/trac/ticket/502)
- Write more attributes with GraphML and GML formats
(ticket https://networkx.lanl.gov/trac/ticket/480)
- Handle white space better in read_edgelist
(ticket https://networkx.lanl.gov/trac/ticket/513)
- Better parsing of Pajek format files
(ticket https://networkx.lanl.gov/trac/ticket/524)
(ticket https://networkx.lanl.gov/trac/ticket/542)
- Isolates functions work with directed graphs
(ticket https://networkx.lanl.gov/trac/ticket/526)
- Faster conversion to numpy matrices
(ticket https://networkx.lanl.gov/trac/ticket/529)
- Add graph['name'] and use properties to access Graph.name
(ticket https://networkx.lanl.gov/trac/ticket/544)
- Topological sort confused None and 0
(ticket https://networkx.lanl.gov/trac/ticket/546)
- GEXF writer mishandled weight=0
(ticket https://networkx.lanl.gov/trac/ticket/550)
- Speedup in SciPy version of PageRank
(ticket https://networkx.lanl.gov/trac/ticket/554)
- Numpy PageRank node order incorrect + speedups
(ticket https://networkx.lanl.gov/trac/ticket/555)
NetworkX 1.4
------------
Release date: 23 January 2011
New features- :mod:
k-shell,k-crust,k-corona <networkx.algorithms.core> - :mod:
read GraphML files from yEd <networkx.readwrite.graphml> - :mod:
read/write GEXF format files <networkx.readwrite.gexf> - :mod:
find cycles in a directed graph <networkx.algorithms.cycles> - :mod:
DFS <networkx.algorithms.traversal.depth_first_search>and :mod:BFS <networkx.algorithms.traversal.breadth_first_search>algorithms - :mod:
chordal graph functions <networkx.algorithms.chordal.chordal_alg> - :mod:
Prim's algorithm for minimum spanning tree <networkx.algorithms.mst> - :mod:
r-ary tree generator <networkx.generators.classic> - :mod:
rich club coefficient <networkx.algorithms.richclub> - NumPy matrix version of :mod:
Floyd's algorithm for all-pairs shortest path <networkx.algorithms.shortest_paths.dense> - :mod:
read GIS shapefiles <networkx.readwrite.nx_shp> - :mod:
functions to get and set node and edge attributes <networkx.classes.function> - and more, see https://networkx.lanl.gov/trac/query?status=closed&group=milestone&milestone=networkx-1.4
API changes
- :mod:`gnp_random_graph() <networkx.generators.random_graphs>` now takes a
directed=True|False keyword instead of create_using
- :mod:`gnm_random_graph() <networkx.generators.random_graphs>` now takes a
directed=True|False keyword instead of create_using
Bug fixes
~~~~~~~~~
- see https://networkx.lanl.gov/trac/query?status=closed&group=milestone&milestone=networkx-1.4
NetworkX 1.3
------------
Release date: 28 August 2010
See: https://networkx.lanl.gov/trac/timeline
New features- Works with Python versions 2.6, 2.7, 3.1, and 3.2 (but not 2.4 and 2.5).
- :mod:
Minimum cost flow algorithms <networkx.algorithms.flow> - :mod:
Bellman-Ford shortest paths <networkx.algorithms.shortest_paths.weighted> - :mod:
GraphML reader and writer <networkx.readwrite.graphml> - :mod:
More exception/error types <networkx.exception> - Updated many tests to unittest style. Run with: "import networkx; networkx.test()" (requires nose testing package)
- and more, see https://networkx.lanl.gov/trac/query?status=closed&group=milestone&milestone=networkx-1.3
API changes
- :mod:`minimum_spanning_tree() now returns a NetworkX Graph (a tree or forest) <networkx.algorithms.mst>`
Bug fixes
~~~~~~~~~
- see https://networkx.lanl.gov/trac/query?status=closed&group=milestone&milestone=networkx-1.3
NetworkX 1.2
------------
Release date: 28 July 2010
See: https://networkx.lanl.gov/trac/timeline
New features- :mod:
Ford-Fulkerson max flow and min cut <networkx.algorithms.flow> - :mod:
Closeness vitality <networkx.algorithms.vitality> - :mod:
Eulerian circuits <networkx.algorithms.euler> - :mod:
Functions for isolates <networkx.algorithms.isolates> - :mod:
Simpler s_max generator <networkx.generators.degree_seq> - Compatible with IronPython-2.6
- Improved testing functionality: import networkx; networkx.test() tests
entire package and skips tests with missing optional packages - All tests work with Python-2.4
- and more, see https://networkx.lanl.gov/trac/query?status=closed&group=milestone&milestone=networkx-1.2
NetworkX 1.1
Release date: 21 April 2010
See: https://networkx.lanl.gov/trac/timeline
New features
- :mod:`Algorithm for finding a basis for graph cycles <networkx.algorithms.cycles>`
- :mod:`Blockmodeling <networkx.algorithms.block>`
- :mod:`Assortativity and mixing matrices <networkx.algorithms.mixing>`
- :mod:`in-degree and out-degree centrality <networkx.algorithms.centrality.degree>`
- :mod:`Attracting components <networkx.algorithms.components.attracting>`
and :mod:`condensation <networkx.algorithms.components.strongly_connected>`.
- :mod:`Weakly connected components <networkx.algorithms.components.weakly_connected>`
- :mod:`Simpler interface to shortest path algorithms <networkx.algorithms.shortest_paths.generic>`
- :mod:`Edgelist format to read and write data with attributes <networkx.readwrite.edgelist>`
- :mod:`Attribute matrices <networkx.linalg.spectrum>`
- :mod:`GML reader for nested attributes <networkx.readwrite.gml>`
- Current-flow (random walk)
:mod:`betweenness <networkx.algorithms.centrality.current_flow_betweenness>`
and
:mod:`closeness <networkx.algorithms.centrality.current_flow_closeness>`.
- :mod:`Directed configuration model <networkx.generators.degree_seq>`,
and :mod:`directed random graph model <networkx.generators.random_graphs>`.
- Improved documentation of drawing, shortest paths, and other algorithms
- Many more tests, can be run with "import networkx; networkx.test()"
- and much more, see https://networkx.lanl.gov/trac/query?status=closed&group=milestone&milestone=networkx-1.1
API changes
~~~~~~~~~~~
Returning dictionaries
**********************
Several of the algorithms and the degree() method now return dictionaries
keyed by node instead of lists. In some cases there was a with_labels
keyword which is no longer necessary. For example,
>>> G=nx.Graph()
>>> G.add_edge('a','b')
>>> G.degree() # doctest: +SKIP
{'a': 1, 'b': 1}
Asking for the degree of a single node still returns a single number
>>> G.degree('a')
1
The following now return dictionaries by default (instead of lists)
and the with_labels keyword has been removed:
- :meth:`Graph.degree`,
:meth:`MultiGraph.degree`,
:meth:`DiGraph.degree`,
:meth:`DiGraph.in_degree`,
:meth:`DiGraph.out_degree`,
:meth:`MultiDiGraph.degree`,
:meth:`MultiDiGraph.in_degree`,
:meth:`MultiDiGraph.out_degree`.
- :func:`clustering`,
:func:`triangles`
- :func:`node_clique_number`,
:func:`number_of_cliques`,
:func:`cliques_containing_node`
- :func:`eccentricity`
The following now return dictionaries by default (instead of lists)
- :func:`pagerank`
- :func:`hits`
Adding nodes
************
``add_nodes_from`` now accepts ``(node, attrdict)`` two-tuples
>>> G = nx.Graph()
>>> G.add_nodes_from([(1, {'color': 'red'})])
Examples
~~~~~~~~
- `Mayvi2 drawing <https://networkx.org/documentation/latest/auto_examples/3d_drawing/mayavi2_spring.html>`_
- `Blockmodel <https://networkx.org/documentation/latest/auto_examples/algorithms/plot_blockmodel.html>`_
- `Sampson's monastery <https://networkx.org/documentation/latest/auto_examples/drawing/plot_sampson.html>`_
- `Ego graph <https://networkx.org/documentation/latest/auto_examples/drawing/plot_ego_graph.html>`_
Bug fixes
~~~~~~~~~
- Support graph attributes with union, intersection, and other graph operations
- Improve subgraph speed (and related algorithms such as
connected_components_subgraphs())
- Handle multigraphs in more operators (e.g. union)
- Handle double-quoted labels with pydot
- Normalize betweenness_centrality for undirected graphs correctly
- Normalize eigenvector_centrality by l2 norm
- :func:`read_gml` now returns multigraphs
NetworkX 1.0.1
--------------
Release date: 11 Jan 2010
See: https://networkx.lanl.gov/trac/timeline
Bug fix release for missing setup.py in manifest.
NetworkX 1.0
------------
Release date: 8 Jan 2010
See: https://networkx.lanl.gov/trac/timeline
New featuresThis release has significant changes to parts of the graph API
to allow graph, node, and edge attributes.
See http://networkx.lanl.gov/reference/api_changes.html
- Update Graph, DiGraph, and MultiGraph classes to allow attributes.
- Default edge data is now an empty dictionary (was the integer 1)
- Difference and intersection operators
- Average shortest path
- A* (A-Star) algorithm
- PageRank, HITS, and eigenvector centrality
- Read Pajek files
- Line graphs
- Minimum spanning tree (Kruskal's algorithm)
- Dense and sparse Fruchterman-Reingold layout
- Random clustered graph generator
- Directed scale-free graph generator
- Faster random regular graph generator
- Improved edge color and label drawing with Matplotlib
- and much more, see https://networkx.lanl.gov/trac/query?status=closed&group=milestone&milestone=networkx-1.0
Examples
- Update to work with networkx-1.0 API
- Graph subclass example
NetworkX 0.99
-------------
Release date: 18 November 2008
See: https://networkx.lanl.gov/trac/timeline
New featuresThis release has significant changes to parts of the graph API.
See http://networkx.lanl.gov/reference/api_changes.html
- Update Graph and DiGraph classes to use weighted graphs as default
Change in API for performance and code simplicity. - New MultiGraph and MultiDiGraph classes (replace XGraph and XDiGraph)
- Update to use Sphinx documentation system http://networkx.lanl.gov/
- Developer site at https://networkx.lanl.gov/trac/
- Experimental LabeledGraph and LabeledDiGraph
- Moved package and file layout to subdirectories.
Bug fixes
- handle root= option to draw_graphviz correctly
Examples
~~~~~~~~
- Update to work with networkx-0.99 API
- Drawing examples now use matplotlib.pyplot interface
- Improved drawings in many examples
- New examples - see http://networkx.lanl.gov/examples/
NetworkX 0.37
---------------
Release date: 17 August 2008
See: https://networkx.lanl.gov/trac/timeline
NetworkX now requires Python 2.4 or later for full functionality.
New features- Edge coloring and node line widths with Matplotlib drawings
- Update pydot functions to work with pydot-1.0.2
- Maximum-weight matching algorithm
- Ubigraph interface for 3D OpenGL layout and drawing
- Pajek graph file format reader and writer
- p2g graph file format reader and writer
- Secondary sort in topological sort
Bug fixes
- Better edge data handling with GML writer
- Edge betweenness fix for XGraph with default data of None
- Handle Matplotlib version strings (allow "pre")
- Interface to PyGraphviz (to_agraph()) now handles parallel edges
- Fix bug in copy from XGraph to XGraph with multiedges
- Use SciPy sparse lil matrix format instead of coo format
- Clear up ambiguous cases for Barabasi-Albert model
- Better care of color maps with Matplotlib when drawing colored nodes
and edges
- Fix error handling in layout.py
Examples
~~~~~~~~
- Ubigraph examples showing 3D drawing
NetworkX 0.36
---------------
Release date: 13 January 2008
See: https://networkx.lanl.gov/trac/timeline
New features- GML format graph reader, tests, and example (football.py)
- edge_betweenness() and load_betweenness()
Bug fixes
- remove obsolete parts of pygraphviz interface
- improve handling of Matplotlib version strings
- write_dot() now writes parallel edges and self loops
- is_bipartite() and bipartite_color() fixes
- configuration model speedup using random.shuffle()
- convert with specified nodelist now works correctly
- vf2 isomorphism checker updates
NetworkX 0.35.1
---------------
Release date: 27 July 2007
See: https://networkx.lanl.gov/trac/timeline
Small update to fix import readwrite problem and maintain Python2.3
compatibility.
NetworkX 0.35
-------------
Release date: 22 July 2007
See: https://networkx.lanl.gov/trac/timeline
New features- algorithms for strongly connected components.
- Brandes betweenness centrality algorithm (weighted and unweighted versions)
- closeness centrality for weighted graphs
- dfs_preorder, dfs_postorder, dfs_tree, dfs_successor, dfs_predecessor
- readers for GraphML, LEDA, sparse6, and graph6 formats.
- allow arguments in graphviz_layout to be passed directly to graphviz
Bug fixes
- more detailed installation instructions
- replaced dfs_preorder,dfs_postorder (see search.py)
- allow initial node positions in spectral_layout
- report no error on attempting to draw empty graph
- report errors correctly when using tuples as nodes #114
- handle conversions from incomplete dict-of-dict data
NetworkX 0.34
-------------
Release date: 12 April 2007
See: https://networkx.lanl.gov/trac/timeline
New features- benchmarks for graph classes
- Brandes betweenness centrality algorithm
- Dijkstra predecessor and distance algorithm
- xslt to convert DIA graphs to NetworkX
- number_of_edges(u,v) counts edges between nodes u and v
- run tests with python setup_egg.py test (needs setuptools)
else use python -c "import networkx; networkx.test()" - is_isomorphic() that uses vf2 algorithm
Bug fixes
- speedups of neighbors()
- simplified Dijkstra's algorithm code
- better exception handling for shortest paths
- get_edge(u,v) returns None (instead of exception) if no edge u-v
- floyd_warshall_array fixes for negative weights
- bad G467, docs, and unittest fixes for graph atlas
- don't put nans in numpy or scipy sparse adjacency matrix
- handle get_edge() exception (return None if no edge)
- remove extra kwds arguments in many places
- no multi counting edges in conversion to dict of lists for multigraphs
- allow passing tuple to get_edge()
- bad parameter order in node/edge betweenness
- edge betweenness doesn't fail with XGraph
- don't throw exceptions for nodes not in graph (silently ignore instead)
in edges_* and degree_*
NetworkX 0.33
-------------
Release date: 27 November 2006
See: https://networkx.lanl.gov/trac/timeline
New features- draw edges with specified colormap
- more efficient version of Floyd's algorithm for all pairs shortest path
- use numpy only, Numeric is deprecated
- include tests in source package (networkx/tests)
- include documentation in source package (doc)
- tests can now be run with
import networkx
networkx.test() # doctest: +SKIP
Bug fixes
- read_gpickle now works correctly with Windows
- refactored large modules into smaller code files
- degree(nbunch) now returns degrees in same order as nbunch
- degree() now works for multiedges=True
- update node_boundary and edge_boundary for efficiency
- edited documentation for graph classes, now mostly in info.py
Examples
~~~~~~~~
- Draw edges with colormap
NetworkX 0.32
-------------
Release date: 29 September 2006
See: https://networkx.lanl.gov/trac/timeline
New features- Update to work with numpy-1.0x
- Make egg usage optional: use python setup_egg.py bdist_egg to build egg
- Generators and functions for bipartite graphs
- Experimental classes for trees and forests
- Support for new pygraphviz update (in nx_agraph.py) , see
http://networkx.lanl.gov/pygraphviz/ for pygraphviz details
Bug fixes
- Handle special cases correctly in triangles function
- Typos in documentation
- Handle special cases in shortest_path and shortest_path_length,
allow cutoff parameter for maximum depth to search
- Update examples: erdos_renyi.py, miles.py, roget,py, eigenvalues.py
Examples
~~~~~~~~
- Expected degree sequence
- New pygraphviz interface
NetworkX 0.31
-------------
Release date: 20 July 2006
See: https://networkx.lanl.gov/trac/timeline
New features- arbitrary node relabeling (use relabel_nodes)
- conversion of NetworkX graphs to/from Python dict/list types,
numpy matrix or array types, and scipy_sparse_matrix types - generator for random graphs with given expected degree sequence
Bug fixes
- Allow drawing graphs with no edges using pylab
- Use faster heapq in dijkstra
- Don't complain if X windows is not available
Examples
~~~~~~~~
- update drawing examples
NetworkX 0.30
-------------
Release date: 23 June 2006
See: https://networkx.lanl.gov/trac/timeline
New features- update to work with Python 2.5
- bidirectional version of shortest_path and Dijkstra
- single_source_shortest_path and all_pairs_shortest_path
- s-metric and experimental code to generate maximal s-metric graph
- double_edge_swap and connected_double_edge_swap
- Floyd's algorithm for all pairs shortest path
- read and write unicode graph data to text files
- read and write YAML format text files, http://yaml.org
Bug fixes
- speed improvements (faster version of subgraph, is_connected)
- added cumulative distribution and modified discrete distribution utilities
- report error if DiGraphs are sent to connected_components routines
- removed with_labels keywords for many functions where it was
causing confusion
- function name changes in shortest_path routines
- saner internal handling of nbunch (node bunches), raise an
exception if an nbunch isn't a node or iterable
- better keyword handling in io.py allows reading multiple graphs
- don't mix Numeric and numpy arrays in graph layouts and drawing
- avoid automatically rescaling matplotlib axes when redrawing graph layout
Examples
~~~~~~~~
- unicode node labels
NetworkX 0.29
-------------
Release date: 28 April 2006
See: https://networkx.lanl.gov/trac/timeline
New features- Algorithms for betweenness, eigenvalues, eigenvectors, and
spectral projection for threshold graphs - Use numpy when available
- dense_gnm_random_graph generator
- Generators for some directed graphs: GN, GNR, and GNC by Krapivsky
and Redner - Grid graph generators now label by index tuples. Helper
functions for manipulating labels. - relabel_nodes_with_function
Bug fixes
- Betweenness centrality now correctly uses Brandes definition and
has normalization option outside main loop
- Empty graph now labeled as empty_graph(n)
- shortest_path_length used python2.4 generator feature
- degree_sequence_tree off by one error caused nonconsecutive labeling
- periodic_grid_2d_graph removed in favor of grid_2d_graph with
periodic=True
NetworkX 0.28
-------------
Release date: 13 March 2006
See: https://networkx.lanl.gov/trac/timeline
New features- Option to construct Laplacian with rows and columns in specified order
- Option in convert_node_labels_to_integers to use sorted order
- predecessor(G,n) function that returns dictionary of
nodes with predecessors from breadth-first search of G
starting at node n.
https://networkx.lanl.gov/trac/ticket/26
Examples
- Formation of giant component in binomial_graph:
- Chess masters matches:
- Gallery https://networkx.org/documentation/latest/auto_examples/index.html
Bug fixes- Adjusted names for random graphs.
- erdos_renyi_graph=binomial_graph=gnp_graph: n nodes with
edge probability p - gnm_graph: n nodes and m edges
- fast_gnp_random_graph: gnp for sparse graphs (small p)
- erdos_renyi_graph=binomial_graph=gnp_graph: n nodes with
- Documentation contains correct spelling of Barabási, Bollobás,
Erdős, and Rényi in UTF-8 encoding - Increased speed of connected_components and related functions
by using faster BFS algorithm in networkx.paths
https://networkx.lanl.gov/trac/ticket/27 - XGraph and XDiGraph with multiedges=True produced error on delete_edge
- Cleaned up docstring errors
- Normalize names of some graphs to produce strings that represent
calling sequence
NetworkX 0.27
Release date: 5 February 2006
See: https://networkx.lanl.gov/trac/timeline
New features
- sparse_binomial_graph: faster graph generator for sparse random graphs
- read/write routines in io.py now handle XGraph() type and
gzip and bzip2 files
- optional mapping of type for read/write routine to allow
on-the-fly conversion of node and edge datatype on read
- Substantial changes related to digraphs and definitions of
neighbors() and edges(). For digraphs edges=out_edges.
Neighbors now returns a list of neighboring nodes with
possible duplicates for graphs with parallel edges
See https://networkx.lanl.gov/trac/ticket/24
- Addition of out_edges, in_edges and corresponding out_neighbors
and in_neighbors for digraphs. For digraphs edges=out_edges.
Examples
~~~~~~~~
- Minard's data for Napoleon's Russian campaign
Bug fixes
~~~~~~~~~
- XGraph(multiedges=True) returns a copy of the list of edges
for get_edge()
NetworkX 0.26
-------------
Release date: 6 January 2006
New features- Simpler interface to drawing with pylab
- G.info(node=None) function returns short information about graph
or node - adj_matrix now takes optional nodelist to force ordering of
rows/columns in matrix - optional pygraphviz and pydot interface to graphviz is now callable as
"graphviz" with pygraphviz preferred. Use draw_graphviz(G).
Examples
- Several new examples showing how draw to graphs with various
properties of nodes, edges, and labels
Bug fixes- Default data type for all graphs is now None (was the integer 1)
- add_nodes_from now won't delete edges if nodes added already exist
- Added missing names to generated graphs
- Indexes for nodes in graphs start at zero by default (was 1)
NetworkX 0.25
Release date: 5 December 2005
New features
- Uses setuptools for installation http://peak.telecommunity.com/DevCenter/setuptools
- Improved testing infrastructure, can now run python setup.py test
- Added interface to draw graphs with pygraphviz
https://networkx.lanl.gov/pygraphviz/
- is_directed() function call
Examples
~~~~~~~~
- Email example shows how to use XDiGraph with Python objects as
edge data
Documentation- Reformat menu, minor changes to Readme, better stylesheet
Bug fixes
- use create_using= instead of result= keywords for graph types
in all cases
- missing weights for degree 0 and 1 nodes in clustering
- configuration model now uses XGraph, returns graph with identical
degree sequence as input sequence
- fixed Dijkstra priority queue
- fixed non-recursive toposort and is_directed_acyclic graph
NetworkX 0.24
-------------
Release date: 20 August 2005
Bug fixes- Update of Dijkstra algorithm code
- dfs_successor now calls proper search method
- Changed to list comprehension in DiGraph.reverse() for python2.3
compatibility - Barabasi-Albert graph generator fixed
- Attempt to add self loop should add node even if parallel edges not
allowed
NetworkX 0.23
Release date: 14 July 2005
The NetworkX web locations have changed:
http://networkx.lanl.gov/ - main documentation site
http://networkx.lanl.gov/svn/ - subversion source code repository
https://networkx.lanl.gov/trac/ - bug tracking and info
Important Change
The naming conventions in NetworkX have changed.
The package name "NX" is now "networkx".
The suggested ways to import the NetworkX package are
- import networkx
- import networkx as NX
- from networkx import *
New features
~~~~~~~~~~~~
- DiGraph reverse
- Graph generators
+ watts_strogatz_graph now does rewiring method
+ old watts_strogatz_graph->newman_watts_strogatz_graph
Examples
~~~~~~~~
Documentation
~~~~~~~~~~~~~
- Changed to reflect NX-networkx change
- main site is now https://networkx.lanl.gov/
Bug fixes
~~~~~~~~~
- Fixed logic in io.py for reading DiGraphs.
- Path based centrality measures (betweenness, closeness)
modified so they work on graphs that are not connected and
produce the same result as if each connected component were
considered separately.
NetworkX 0.22
-------------
Release date: 17 June 2005
New features
~~~~~~~~~~~~
- Topological sort, testing for directed acyclic graphs (DAGs)
- Dijkstra's algorithm for shortest paths in weighted graphs
- Multidimensional layout with dim=n for drawing
- 3d rendering demonstration with vtk
- Graph generators
+ random_powerlaw_tree
+ dorogovtsev_goltsev_mendes_graph
Examples
~~~~~~~~
- Kevin Bacon movie actor graph: Examples/kevin_bacon.py
- Compute eigenvalues of graph Laplacian: Examples/eigenvalues.py
- Atlas of small graphs: Examples/atlas.py
Documentation
~~~~~~~~~~~~~
- Rewrite of setup scripts to install documentation and
tests in documentation directory specified
Bug fixes
~~~~~~~~~
- Handle calls to edges() with non-node, non-iterable items.
- truncated_tetrahedral_graph was just plain wrong
- Speedup of betweenness_centrality code
- bfs_path_length now returns correct lengths
- Catch error if target of search not in connected component of source
- Code cleanup to label internal functions with _name
- Changed import statement lines to always use "import NX" to
protect name-spaces
- Other minor bug-fixes and testing added
---
### Doc Release Release 2.0 (`doc/release/release_2.0.rst`)
NetworkX 2.0
============
Release date: 20 September 2017
Support for Python 3.6 added, drop support for Python 3.3.
See :doc:`migration_guide_from_1.x_to_2.0`.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our `gallery of examples
<https://networkx.org/documentation/latest/auto_examples/index.html>`_.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
This release is the result of over two years of work with 1212 commits and
193 merges by 86 contributors. Highlights include:
- We have made major changes to the methods in the Multi/Di/Graph classes.
There is a `migration guide for people moving from 1.X to 2.0
<https://networkx.org/documentation/latest/release/migration_guide_from_1.x_to_2.0.html>`_.
- We updated the documentation system.
API Changes
-----------
* Base Graph Class Changes
With the release of NetworkX 2.0 we are moving towards a view/iterator reporting API.
We used to have two methods for the same property of the graph, one that returns a
list and one that returns an iterator. With 2.0 we have replaced them with a view.
A view is a read-only object that is quick to create, automatically updated, and
provides basic access like iteration, membership and set operations where appropriate.
For example, ``G.nodes()`` used to return a list and ``G.nodes_iter()`` an iterator.
Now ``G.nodes()`` returns a view and ``G.nodes_iter()`` is removed. ``G.degree()``
returns a view with ``(node, degree)`` iteration, so that ``dict(G.degree())``
returns a dict keyed by node with degree as value.
The old behavior
>>> G = nx.complete_graph(5)
>>> G.nodes() # doctest: +SKIP
[0, 1, 2, 3, 4]
>>> G.nodes_iter() # doctest: +SKIP
<dictionary-keyiterator at ...>
has changed to
>>> G = nx.complete_graph(5)
>>> G.nodes()
NodeView((0, 1, 2, 3, 4))
>>> list(G.nodes())
[0, 1, 2, 3, 4]
New feature include lookup of node and edge data from the views, property
access without parentheses, and set operations.
>>> G.add_node(3, color='blue')
>>> G.nodes[3]
{'color': 'blue'}
>>> G.nodes & {3, 4, 5}
{3, 4}
The following methods have changed:
* Graph/MultiGraph
* ``G.nodes()``
* ``G.edges()``
* ``G.neighbors()``
* ``G.adjacency_list()`` and ``G.adjacency_iter()`` to ``G.adjacency()``
* ``G.degree()``
* ``G.subgraph()``
* ``G.copy()``
* ``G.__class__()`` should be replaced with ``G.fresh_copy()``
* DiGraph/MultiDiGraph
* ``G.nodes()``
* ``G.edges()``
* ``G.in_edges()``
* ``G.out_edges()``
* ``G.degree()``
* ``G.in_degree()``
* ``G.out_degree()``
* ``G.reverse()``
The following deprecated methods will be removed in a future release (3.0?).
* ``G.node``, ``G.edge`` (replaced by G.nodes, G.edges)
* ``G.add_path``, ``G.add_cycle``, ``G.add_star`` (Now ``nx.add_path(G,...``)
* ``G.selfloop_edges``, ``G.nodes_with_selfloops``, ``G.number_of_selfloops``
(Now ``nx.selfloop_edges(G)``, etc)
Many subclasses have been changed accordingly such as:
* AntiGraph
* OrderedGraph and friends
* Examples such as ThinGraph that inherit from Graph
* [`#2107 <https://github.com/networkx/networkx/pull/2107>`_]
The Graph class methods ``add_edge`` and ``add_edges_from`` no longer
allow the use of the ``attr_dict`` parameter. Instead use keyword arguments.
Thus ``G.add_edge(1, 2, {'color': 'red'})`` becomes
``G.add_edge(1, 2, color='red')``.
Note that this only works if the attribute name is a string. For non-string
attributes you will need to add the edge and then update manually using
e.g. ``G.edges[1, 2].update({0: "zero"})``
* [`#1577 <https://github.com/networkx/networkx/pull/1577>`_]
In addition to minimum spanning trees, a new function for calculating maximum
spanning trees is now provided. The new API consists of four functions:
``minimum_spanning_edges``, ``maximum_spanning_edges``,
``minimum_spanning_tree``, and ``maximum_spanning_tree``.
All of these functions accept an ``algorithm`` parameter which specifies the
algorithm to use when finding the minimum or maximum spanning tree. Currently,
Kruskal's and Prim's algorithms are implemented, defined as 'kruskal' and
'prim', respectively. If nothing is specified, Kruskal's algorithm is used.
For example, to calculate the maximum spanning tree of a graph using Kruskal's
algorithm, the function ``maximum_spanning_tree`` has to be called like::
>>> nx.maximum_spanning_tree(G, algorithm='kruskal')
The ``algorithm`` parameter is new and appears before the existing ``weight``
parameter. So existing code that did not explicitly name the optional
``weight`` parameter will need to be updated::
>>> nx.minimum_spanning_tree(G, 'mass') # old
>>> nx.minimum_spanning_tree(G, weight='mass') # new
In the above, we are still relying on the functions being imported into the
top-level namespace. We do not have immediate plans to deprecate this approach,
but we recommend the following instead::
>>> from networkx.algorithms import tree
# recommended
>>> tree.minimum_spanning_tree(G, algorithm='kruskal', weight='mass')
>>> tree.minimum_spanning_edges(G, algorithm='prim', weight='mass')
* [`#1445 <https://github.com/networkx/networkx/pull/1445>`_]
Most of the ``shortest_path`` algorithms now raise a ``NodeNotFound`` exception
when a source or a target are not present in the graph.
* [`#2326 <https://github.com/networkx/networkx/pull/2326>`_]
Centrality algorithms were harmonized with respect to the default behavior of
the weight parameter. The default value of the ``weight`` keyword argument has
been changed from ``weight`` to ``None``. This affects the
following centrality functions:
- :func:`approximate_current_flow_betweenness_centrality()`
- :func:`current_flow_betweenness_centrality()`
- :func:`current_flow_betweenness_centrality_subset()`
- :func:`current_flow_closeness_centrality()`
- :func:`edge_current_flow_betweenness_centrality()`
- :func:`edge_current_flow_betweenness_centrality_subset()`
- :func:`eigenvector_centrality()`
- :func:`eigenvector_centrality_numpy()`
- :func:`katz_centrality()`
- :func:`katz_centrality_numpy()`
* [`#2420 <https://github.com/networkx/networkx/pull/2420>`_]
New community detection algorithm provided. Fluid Communities is an
asynchronous algorithm based on the simple idea of fluids interacting in an
environment, expanding and pushing each other. The algorithm is completely
described in `"Fluid Communities: A Competitive and Highly Scalable Community
Detection Algorithm" <https://arxiv.org/pdf/1703.09307.pdf>`_.
* [`#2510 <https://github.com/networkx/networkx/pull/2510>`_ and
`#2508 <https://github.com/networkx/networkx/pull/2508>`_]
``single_source_dijkstra``, ``multi_source_dijkstra`` and functions that use
these now have new behavior when ``target`` is specified. Instead of
returning dicts for distances and paths a 2-tuple of ``(distance, path)`` is
returned. When ``target`` is not specified the return value is still 2
dicts.
* [`#2553 <https://github.com/networkx/networkx/pull/2553>`_]
``set_node_attributes()`` and ``set_edge_attributes()`` now accept
dict-of-dict input of shape ``{node/edge: {name: value}}`` in addition to
previous valid inputs: ``{node/edge: value}`` and ``value``. The order of the
parameters changed also: The second parameter "values" is the value argument
and the third parameter "name" is the name of the attribute. "name" has
default value ``None`` in which case "values" must be the newly allowed form
containing names. Previously "name" came second without default, and "values"
came third.
* [`#2604 <https://github.com/networkx/networkx/pull/2604>`_] Move selfloop
methods out of base classes to networkx functions.
``G.number_of_selfloops()``, ``G.selfloop_edges()``,
``G.nodes_with_selfloops()`` are now ``nx.number_of_selfloops(G)``,
``nx.selfloop_edges(G)``, ``nx.nodes_with_selfloops(G)``.
``G.node`` and ``G.edge`` are removed. Their functionality are replaced by
``G.nodes`` and ``G.edges``.
* [`#2558 <https://github.com/networkx/networkx/pull/2558>`_]
Previously, the function ``from_pandas_dataframe`` assumed that the dataframe
has edge-list like structures, but ``to_pandas_dataframe`` generates an
adjacency matrix. We now provide four functions ``from_pandas_edgelist``,
``to_pandas_edgelist``, ``from_pandas_adjacency``, and ``to_pandas_adjacency``.
* [`#2620 <https://github.com/networkx/networkx/pull/2620>`_]
Removed ``draw_nx``, please use ``draw`` or ``draw_networkx``.
* [`#1662 <https://github.com/networkx/networkx/pull/1662>`_]
Rewrote ``topological_sort`` as a generator. It no longer accepts
``reverse`` or ``nbunch`` arguments and is slightly faster.
Added ``lexicographical_topological_sort``, which accepts a key.
Deprecations
------------
The following deprecated functions will be removed in 2.1.
- The function ``bellman_ford`` has been deprecated in favor of
``bellman_ford_predecessor_and_distance``.
- The functions ``to_pandas_dataframe`` and ``from_pandas_dataframe`` have been
deprecated in favor of ``to_pandas_adjacency``, ``from_pandas_adjacency``,
``to_pandas_edgelist``, and ``from_pandas_edgelist``.
Contributors
------------
- Niels van Adrichem
- Kevin Arvai
- Ali Baharev
- Moritz Emanuel Beber
- Livio Bioglio
- Jake Bogerd
- Moreno Bonaventura
- Raphaël Bournhonesque
- Matthew Brett
- James Clough
- Marco Cognetta
- Jamie Cox
- Jon Crall
- Robert Davidson
- Nikhil Desai
- DonQuixoteDeLaMancha
- Dosenpfand
- Allen Downey
- Enrico
- Jens Erat
- Jeffrey Finkelstein
- Minas Gjoka
- Aravind Gollakota
- Thomas Grainger
- Aric Hagberg
- Harry
- Yawara ISHIDA
- Bilal AL JAMMAL
- Ryan James
- Omer Katz
- Janis Klaise
- Valentin Lorentz
- Alessandro Luongo
- Francois Malassenet
- Arya McCarthy
- Michael-E-Rose
- Peleg Michaeli
- Jarrod Millman
- Chris Morin
- Sanggyu Nam
- Nishant Nikhil
- Rhile Nova
- Ramil Nugmanov
- Juan Nunez-Iglesias
- Pim Otte
- Ferran Parés
- Richard Penney
- Phobia
- Tristan Poupard
- Sebastian Pucilowski
- Alexander Rodriguez
- Michael E. Rose
- Alex Ryan
- Zachary Sailer
- René Saitenmacher
- Felipe Schneider
- Dan Schult
- Scinawa
- Michael Seifert
- Mohammad Hossein Sekhavat
- Mridul Seth
- SkyTodInfi
- Stacey Smolash
- Jordi Torrents
- Martin Törnwall
- Jannis Vamvas
- Luca Verginer
- Prayag Verma
- Peter Wills
- Ianto Lin Xi
- Heqing Ya
- aryamccarthy
- chebee7i
- definitelyuncertain
- jfinkels
- juliensiebert
- leotrs
- leycec
- mcognetta
- numpde
- root
- salotz
- scott-vsi
- thegreathippo
- vpodpecan
- yash14123
- Neil Girdhar
Merged PRs
----------
- Gml read fix. (#1962)
- Small changes leftover from #1847 (#1966)
- Fix k_core for directed graphs. Add tests (#1963)
- Communicability fix (#1958)
- Allows weight functions in shortest path functions (#1690)
- minor doc changes on weighted.py (#1969)
- Fix minimum_st_edge_cut documentation. (#1977)
- Fix all_node_cuts corner cases: cycle and complete graphs. (#1976)
- Change add_path/star/cycle from methods to functions (#1970)
- branch 'edge-subgraph' from @jfinkels (#1740)
- Corrected eppstein matching (#1955)
- Nose ignore docstrings (#1980)
- Edited Doc Makefile so clean doesn't delete the examples folder (#1967)
- bug fix in convert_matrix.py (#1983)
- Avoid unnecessary eigenval sort in pagerank_numpy (#1986)
- Fix a typo in install.rst (#1991)
- Adds unorderable nodes test for dag_longest_path. (#1999)
- Improve drawing test scripts (typos, newlines, methods) (#1992)
- Improves test coverage for A* shortest path. (#1988)
- Improves test coverage for avg degree connectivity (#1987)
- Fix Graph() docstring to reflect input flexibility (#2006)
- Fix sphinx autosummary doc generation errors. (#2026)
- Improve gexf.py (#2010)
- Readme.rst should mention Decorator package is required. (#2009)
- fix_duplicate_kwarg: Fix a duplicate kwarg that was causing to_agraph… (#2005)
- Cleans documentation for graph6 and sparse6 I/O. (#2002)
- Remove http server example (#2001)
- Generalize and improve docstrings of node_link.py (#2000)
- fix issue #1948 and PEP8 formatting (#2031)
- Uses weight function for dijkstra_path_length. (#2033)
- Change default role for sphinx to 'obj' (#2027)
- fixed typo s/abritrary/arbitrary/ (#2035)
- Fix bug in dtype-valued matrices (#2038)
- Adds example for using Graph.nodes() with default (#2040)
- Clarifies some examples for relabel_nodes(). (#2041)
- Cleans code and documentation for graph power. (#2042)
- Cleans the classes.function module. (#2043)
- UnboundLocalError if called with an empty graph (#2047)
- Standardized Bellman-Ford function calls (#1910)
- Nobody is in IRC (#2059)
- Uses add_weighted_edges_from function in MST test. (#2061)
- Adds multi-source Dijkstra's algorithm (#2073)
- Adds Voronoi cells algorithm (#2074)
- Fixes several issues with the Girvan-Newman partitioning function. Fixes #1703, #1725, #1799 (#1972)
- Moves is_path from utils to simple_paths. (#1921)
- add max_iter and tol parameter for numpy version (#2013)
- Remove draw_graphviz function. Fixes #1997 (#2077)
- Fixes #1998 edge_load function needs documentation. (#2075)
- Update fixcoverage.py (#2080)
- Support digraphs in approximate min vertex cover (#2039)
- Simplifies code in functions for greedy coloring. (#1680)
- Allows arbitrary metric in geometric generators. (#1679)
- Fix spring_layout for single node graph. (#2081)
- Updates set_{node,edge}_attributes and docs. (#1935)
- Fixes tests for maximal matching. (#1919)
- Adds LFM benchmark graph generator for communities (#1727)
- Adds global and local efficiency functions. (#1521)
- Apply alphas to individual nodes (#1289)
- Code and tests for temporal VF2 (#1653)
- extend convert_bool in gexf.py and graphml.py to all valid boolean (#1063)
- Remove encoded ... to plain ascii (#2086)
- Use not_implemented_for() for in_degree_centrality() and out_degree_centrality() (#2084)
- Issue 2072 weighted modularity (#2088)
- Simplifies eigenvector centrality implementation. (#1708)
- Fjmalass nodes as tuples (#2089)
- Generator rename (#2090)
- Ensure links in doc ```See also``` sections (#2082)
- Document integer-only numeric mixing (#2085)
- doc sphinx error removal (#2091)
- Correct see also links (#2095)
- Adjust layout.py function signatures, docs, exposure (#2096)
- Adds missing __all__ attributes. (#2098)
- Fixes 2 bugs in dominance frontier code (#2092)
- Created two new files: joint_degree_seq.py and test_joint_degree_seq.… (#2011)
- Adds Borůvka's minimum spanning tree algorithm. (#1873)
- Adds global/local reaching centrality functions. (#2099)
- Remove conflicts from #1894 (Update Exception Classes) (#2100)
- Add Exceptions for missing source in shortest_path (#2102)
- Docs for compose now warn about MultiGraph edgekeys (#2101)
- Improve Notes section on simplex and friends docs. (#2104)
- Add Dinitz' algorithm for maximum flow problems. (#1978)
- Removed duplicated method/doc (add_edges_from) (#1)
- Bugfix for generic_multiedge_match (Issue #2114) (#2124)
- Fix for 2015. (#2)
- add_node, add_edge attr_dict change. (#2132)
- Handle graph name attribute in relabel_nodes (#2136)
- Fix fruchterman reingold bug and add more tests to layouts. (#2141)
- Adds exception: failed power iteration convergence (#2143)
- Tweak iteration logic of HITS (#2142)
- Fix PageRank personalize docstring (#2148)
- Set default source=None for dfs_tree (#2149)
- Fix docs for maximal_matching and tensor_product (#2158)
- Isolate edge key generation in multigraphs (#2150)
- Sort centralities together and outsource dispersion (#2083)
- Changed classic generators to use generators instead of lists (#2167)
- Adds beam search traversal algorithm with example (#2129)
- Turan graph (#2172)
- Removes irrelevant Notes section from docstring (#2178)
- Corrects logarithm base in example (#2179)
- Minor correction in documentation (#2180)
- Add Boykov Kolmogorov algorithm for maximum flow problems. (#2122)
- Remove temporary files after tests are run. (#2202)
- Add support for subgraphs with no edges in convert_matrix.to_scipy_sparse_matrix. (#2199)
- Add support for reading adjacency matrix in readwrite.pajek.parse_pajek. (#2200)
- Moves Graph Atlas to data file. (#2064)
- Refactor Dinitz' algorithm implementation. (#2196)
- Use arrays instead of matrices in scipy.linalg.expm() (#2208)
- Making in_edges equivalent to out_edges (#2206)
- Fix tests failing because of ordering issues. (#2207)
- Fix code escaping. (#2214)
- Add adjlist_outer_dict_factory. (#2222)
- Typo in scale free network generator documentation (#2225)
- Add link to nx.drawing.layout instead of mentioning nx.layout. (#2224)
- Example not working in tutorial (#2230)
- don't assume nodes are sortable when running dag_longest_path (#2228)
- Correct typo (#2236)
- Use ego graph when computing local efficiency (#2246)
- Make harmonic centrality more memory-efficient (#2247)
- have dag_longest_path_length return path length, not edge count (#2237)
- Added transitive_reduction in dag (#2215)
- alpha kwarg not used in pylab label drawing, added it here. (#2269)
- Make PyDot Support Great Again (#2272)
- Unnecessary array copying in katz_centrality_numpy ? (#2287)
- Switch to faster smallest-last algorithm implementation. (#2268)
- Adds example for getting all simple edge paths. Fixes #718 (#2260)
- Remove obsolete testing tools. (#2303)
- Correct error in minimum_spanning_arborescence (#2285)
- Yield string, not dict, in dfs_labeled_edges. (#2277)
- Removes unnecessary convert_to_(un)directed func (#2259)
- Complete multipartite graph docs (#2221)
- fix LPA bug, see issues/2219 (#2227)
- Generalized degree (#2220)
- Turan docs (#2218)
- Fix broken link to the description of the P2G format. (#2211)
- Test ordering (#2209)
- add example of node weights (#2250)
- added parameter nbunch (#2253)
- Adds unit tests for using dtype with to_numpy_matrix (#2257)
- Adds chain decomposition algorithm. (#2284)
- add the Hoffman-Singleton graph (#2275)
- Allow grid_graph generator to accept tuple dim argument (#2320)
- pseudo -> pseudo (fixing typo) (#2322)
- Corrects navigable small world graph param docs (#2321)
- Fix bug in find_cycle. (#2324)
- flip source target (#2309)
- Simpler version of digitsrep(..) function (#2330)
- change articulation_points so that it only returns every vertex once (#2333)
- Use faster random geometric graph implementation. (#2337)
- Allow community asyn_lpa test to have two answers (#2339)
- Fix broken links and remove pdf files from Makefile (#2344)
- Documents orderable node requirement for isom. (#2302)
- Adds modularity measure for communities. (#1729)
- Simplifies degree sequence graph generators. (#1866)
- Adds tree encoding and decoding functions. (#1874)
- Corrects number_of_edges docs for directed graphs (#2360)
- Adds multigraph keys to Eulerian circuits (#2359)
- Update predecessors/successors in edge subgraph (#2373)
- Fix for #2364 (#2372)
- Raise an Exception for disconnected Graphs in bipartite.sets (#2375)
- fixes typo in NetworkXNotImplemented (#2385)
- Check alternating paths using iterative DFS in to_vertex_cover. (#2386)
- Fix typos in generating NXError in networkx.linalg.graphmatrix.incidence_matrix (#2395)
- [Fixes #2342] remove calls to plt.hold(), deprecated in mpl2.0 (#2397)
- Fix broken links (#2414)
- Fix all tests for 3.6 (#2413)
- Improve bipartite documentation. (#2402)
- correct logic in GEXFWriter (#2399)
- list optional dependencies in setup.py (#2398)
- Gitwash update (#2371)
- Added cytoscape JSON handling (#2351)
- Fix for issues #2328 and #2332 (#2366)
- Workaround for gdal python3.6 at travis and more doctests fixes (#2416)
- Fixed bug on custom attrs usage: unavailable iteritems method for dict. (#2461)
- Fix sphinx errors and class outlines (#2480)
- Note the precondition that graphs are directed and acyclic (#2500)
- Add CONTRIBUTE file (#2501)
- Remove external module (#2521)
- Ensure `make html` doesn't fail build on exit (#2530)
- Cherry pick missing commits (#2535)
- Document release process (#2539)
- Update copyright (#2551)
- Remove deprecated code (#2536)
- Improve docs (#2555)
- WIP: Add note on how to estimate appropriate values for alpha (#2583)
- Travis refactor (#2596)
- Create separate functions for df as edge-lists and adjacency matrices (#2558)
- Use texext for math_dollar (#2609)
- Add drawing tests (#2617)
- Add threshold tests (#2622)
- Update docs (#2623)
- Prep beta release (#2624)
- Refactor travis tests and deploy docs with travis (#2647)
- matplotlib 2.1 deprecated is_string_like (#2659)
- topological_sort, lexicographical_topological_sort (#1662)
---
### Doc Release Release 2.1 (`doc/release/release_2.1.rst`)
NetworkX 2.1
============
Release date: 22 January 2018
Supports Python 2.7, 3.4, 3.5, and 3.6.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our `gallery of examples
<https://networkx.org/documentation/latest/auto_examples/index.html>`_.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
This release is the result of four months of work with 75 pull requests by
37 contributors. Highlights include:
- Arrows for drawing DiGraph edges are vastly improved!
And an example to show them.
- More than 12 new functions for graph generation, manipulation and/or
new graph algorithms.
- Add a large clique size heuristic function (#2830)
- Add rooted product function (#2825)
- Label Propagation Community Detection (#2821)
- Minimum cycle basis (#2823)
- Add Mycielski Operator (#2785)
- Adds prefix_tree, dag_to_branching, and example. (#2784)
- Add inverse_line_graph generator from #2241 (#2782)
- Steiner tree and metric closure. (#2252)
- Add flow based node and edge disjoint paths. (#2063)
- Update geometric networks with new models (#2498)
- Graph edit distance (#2729)
- Added function for finding a k-edge-augmentation (#2572)
- G.name is no longer processed by graph operators. It remains as a
property mechanism to access ``G.graph['name']`` but the user is in
charge of updating or changing it for copies, subgraphs, unions and
other graph operations.
Improvements
------------
- Many bug fixes, documentation changes.
- Speed improvements especially for subgraphs.
- Changed input variable names for functions using ``**kwds``
to avoid name collisions -- especially ``add_node``
- New examples for arrows and spectral embedding of the grid graph.
API Changes
-----------
* [`#2498 <https://github.com/networkx/networkx/pull/2498>`_]
In ``geographical_threshold_graph``, starting in NetworkX 2.1 the parameter
``alpha`` is deprecated and replaced with the customizable ``p_dist``
function parameter, which defaults to r^-2
if ``p_dist`` is not supplied. To reproduce networks of earlier NetworkX
versions, a custom function needs to be defined and passed as the ``p_dist``
parameter. For example, if the parameter ``alpha`` = 2 was used in NetworkX 2.0,
the custom function def custom_dist(r): r**-2 can be passed in versions >=2.1
as the parameter p_dist = custom_dist to produce an equivalent network.
Note the change in sign from +2 to -2 in this parameter change.
* [`#2554 <https://github.com/networkx/networkx/issues/2554>`_]
New algorithms for finding k-edge-connected components and k-edge-connected
subgraphs in directed and undirected graphs. Efficient implementations are
provided for the special case of k=1 and k=2. The new functionality is
provided by:
:func:`k_edge_components()`
:func:`k_edge_subgraphs()`
* [`#2572 <https://github.com/networkx/networkx/issues/2572>`_]
New algorithm finding for finding k-edge-augmentations in undirected graphs.
Efficient implementations are provided for the special case of k=1 and k=2.
New functionality is provided by:
- :func:`k_edge_augmentation()`
* [`#2812 <https://github.com/networkx/networkx/pull/2812>`_]
Removed ``bellman_ford``, please use
``bellman_ford_predecessor_and_distance``.
* [`#2811 <https://github.com/networkx/networkx/pull/2811>`_]
Removed ``to_pandas_dataframe`` and ``from_pandas_dataframe``, please use
``to_pandas_adjacency``, ``from_pandas_adjacency``, ``to_pandas_edgelist``,
or ``from_pandas_edgelist``.
* [`#2766 <https://github.com/networkx/networkx/pull/2766>`_]
Add seed keyword argument to random_layout and spring_layout
* [`#2776 <https://github.com/networkx/networkx/pull/2776>`_]
Add threshold option to spring layout
* [`#2774 <https://github.com/networkx/networkx/pull/2774>`_]
max_weight_matching returns set of edges
* [`#2753 <https://github.com/networkx/networkx/pull/2753>`_]
Add directed graphs support for jit_graph reading
* [`#2788 <https://github.com/networkx/networkx/pull/2788>`_]
Control node-border color in draw_networkx_nodes
Deprecations
------------
* [`#2819 <https://github.com/networkx/networkx/pull/2819>`_]
Deprecate ``connected_component_subgraphs``, ``biconnected_component_subgraphs``,
``attracting_component_subgraphs``, ``strongly_connected_component_subgraphs``,
``weakly_connected_component_subgraphs``.
Instead use: ``[G.subgraph(c) for c in *_components]``
Contributors
------------
- Jack Amadeo
- Boskovits
- Daniel Bradburn
- David Bradway
- Ariel Chinn
- Jon Crall
- Rodrigo Dorantes-Gilardi
- Bradley Ellert
- Adam Erispaha
- Ioannis Filippidis
- ForFer
- Louis Gatin
- Aric Hagberg
- Harry
- Huston Hedinger
- Charles Tapley Hoyt
- James Lamb
- Sanghack Lee
- MD
- Cole MacLean
- Marco
- Jarrod Millman
- Sanggyu Nam
- Viraj Parimi
- Dima Pasechnik
- Richard Penney
- Naresh Peshwe
- Zachary Sailer
- Dan Schult
- Jordi Torrents
- John Wegis
- aparamon
- aweltsch
- gfyoung
- md0000
- mddddd
- talhum
Merged PRs
----------
- Update Release Notes for v2.1 (#2839)
- Update release notes (#2838)
- Update copyright (#2837)
- Add a large clique size heuristic function (#2830)
- Remove automatic processing of G.name attribute (#2829)
- Add rooted product function (#2825)
- Label Propagation Community Detection (#2821)
- change variable names to avoid kwargs clobber (#2824)
- Minimum cycle basis (#2823)
- Deprecate component_subgraphs functions (#2819)
- Temporarily disable sphinx doctests (#2818)
- Adjust docs for graph class edge attrib assignment (#2817)
- Add directed graphs support for jit_graph reading (#2753)
- Arrows as a plot example. (#2801)
- Fix bug in len(edges) for self-loops (#2816)
- MRG: Remove ``to_pandas_dataframe`` and ``from_pandas_dataframe`` (#2811)
- Fix Pydot tests so works with new version 1.2.4 (#2815)
- MRG: Remove ``bellman_ford`` (#2812)
- Combine generator modules and tweak docs (#2814)
- Legacy array printing for NumPy 1.14+ (#2810)
- Fix rare structurally forbidden mappings bug. (#2798)
- Digraph Arrows to fix #2757 (#2760)
- use a generic Integral type for parameters check (#2800)
- Control node-border color in draw_networkx_nodes (#2788)
- Add seed keyword argument to random_layout and spring_layout (#2766)
- Add Mycielski Operator (#2785)
- Adds prefix_tree, dag_to_branching, and example. (#2784)
- Add inverse_line_graph generator from #2241 (#2782)
- Add docs for steiner_tree and metric_closure (#2783)
- Steiner tree and metric closure. (#2252)
- Correct docstring for weight parameter (#2781)
- Switch to xcode 7.3 for osx_image in .travis.yml (#2780)
- Change how sparse6 tests filenames (#2779)
- Add flow based node and edge disjoint paths. (#2063)
- Update geometric networks with new models (#2498)
- [WIP] Graph edit distance 2361 (#2729)
- max_weight_matching returns set of edges (#2774)
- Avoid keyword and attribute clash (#2775)
- Add threshold option to spring layout (#2776)
- Fix bug in expected_degree_graph generator (#2773)
- Add support for incomplete partitions in quotient_graph. (#2771)
- Fix SOURCE_DATE_EPOCH ignored bug (#2735) (#2736)
- Makes write_graph6 less memory-intensive. (#2299)
- all_simple_paths should not return cycles. Fix issue #2762 (#2770)
- Fix typo in write_gml and add test (#2769)
- Fix bug and add checks for non-convergent fiedler_vector (#2681)
- Dictionary comprehensions from #1700 merged conflicts (#2768)
- Fix 2763: Typo `furether` in networkx tutorial documentation (#2764)
- Fix #2726: ensure add_path to add the first node (#2759)
- a minor correction in docs (#2751)
- Speedups for subgraph and copy methods (#2744)
- fix typo in tutorial (#2746)
- Expand documentation regarding strong connectivity (#2732)
- Correct when we raise NetworkXNotImplemented (#2731)
- removed list conversion from _triangles_and_degree_iter (#2725)
- nx_shp fixes (#2721)
- removed reference to create_using from union docs (#2722)
- Copy graph in transitive closure algorithm. (#2718)
- Fix dag_longest_path bug (#2703)
- Fix for inter_community_edges (#2713)
- Fix shortest_simple_paths. Issue #2427 (#2712)
- Update migration_guide_from_1.x_to_2.0.rst (#2694)
- mention `doc.txt` in `requirements/README.md` (#2699)
- docs(centrality/dispersion): updating contributor email address (#2698)
- Fixes bug #2503 by removing arrow labels (#2696)
- Add example of spectral embedding of the grid graph (#2690)
- Fix create_using of nx.from_pandas_adjacency() (#2693)
- Added function for finding a k-edge-augmentation (#2572)
- rm arg `strict` from function `networkx.drawing.nx_pydot.to_pydot` (#2672)
- Fixed problem parsing graphml with nodes in groups (#2644)
- Remove unused imports (#2653)
- Improve subgraph node iteration (#2687)
- Added Kamada-Kawai functions to Sphinx documentation (#2680)
- unpacked dict to provide kwargs when creating nodes from shapefiles (#2678)
- Fix typo in documentation (#2677)
---
### Doc Release Release 2.2 (`doc/release/release_2.2.rst`)
NetworkX 2.2
============
Release date: 19 September 2018
Supports Python 2.7, 3.5, 3.6 and 3.7.
This is the last release to support Python 2.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our `gallery of examples
<https://networkx.org/documentation/latest/auto_examples/index.html>`_.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
This release is the result of 8 months of work with over 149 commits by
58 contributors. Highlights include:
- Add support for Python 3.7. This is the last release to support Python 2.
- Uniform random number generator (RNG) handling which defaults to global
RNGs but allows specification of a single RNG for all random numbers in NX.
- Improved GraphViews to ease subclassing and remove cyclic references
which caused trouble with deepcopy and pickle.
- New Graph method `G.update(H)`
Improvements
------------
Each function that uses random numbers now uses a `seed` argument to control
the random number generation (RNG). By default the global default RNG is
used. More precisely, the `random` package's default RNG or the numpy.random
default RNG. You can also create your own RNG and pass it into the `seed`
argument. Finally, you can use an integer to indicate the state to set for
the RNG. In this case a local RNG is created leaving the global RNG untouched.
Some functions use `random` and some use `numpy.random`, but we have written
a translator so that all functions CAN take a `numpy.random.RandomState`
object. So a single RNG can be used for the entire package.
Cyclic references between graph classes and views have been removed to ease
subclassing without memory leaks. Graphs no longer hold references to views.
Cyclic references between a graph and itself have been removed by eliminating
G.root_graph. It turns out this was an avoidable construct anyway.
GraphViews have been reformulated as functions removing much of the subclass
trouble with the copy/to_directed/subgraph methods. It also simplifies the
graph view code base and API. There are now three function that create
graph views: generic_graph_view(graph, create_using), reverse_view(digraph)
and subgraph_view(graph, node_filter, edge_filter).
GraphML can now be written with attributes using numpy numeric types.
In particular, np.float64 and np.int64 no longer need to convert to Python
float and int to be written. They are still written as generic floats so
reading them back in will not make the numpy values.
A generator following the Stochastic Block Model is now available.
New function `all_topological_sort` to generate all possible top_sorts.
New functions for tree width and tree decompositions.
Functions for Clauset-Newman-Moore modularity-max community detection.
Functions for small world analysis, directed clustering and perfect matchings,
eulerizing a graph, depth-limited BFS, percolation centrality,
planarity checking.
The shortest_path generic and convenience functions now have a `method`
parameter to choose between dijkstra and bellmon-ford in the weighted case.
Default is dijkstra (which was the only option before).
API Changes
-----------
empty_graph has taken over the functionality from
nx.convert._prep_create_using which was removed.
The `create_using` argument (used in many functions) should now be a
Graph Constructor like nx.Graph or nx.DiGraph.
It can still be a graph instance which will be cleared before use, but the
preferred use is a constructor.
New Base Class Method: update
H.update(G) adds the nodes, edges and graph attributes of G to H.
H.update(edges=e, nodes=n) add the edges and nodes from containers e and n.
H.update(e), and H.update(nodes=n) are also allowed.
First argument is a graph if it has `edges` and `nodes` attributes.
Otherwise the first argument is treated as a list of edges.
The bellman_ford predecessor dicts had sentinel value `[None]` for
source nodes. That has been changed so source nodes have pred value '[]'
Deprecations
------------
Graph class method `fresh_copy` - simply use `__class__`.
The GraphView classes are deprecated in preference to the function
interface. Specifically, `ReverseView` and `ReverseMultiView` are
replaced by `reverse_view`. `SubGraph`, `SubDiGraph`, `SubMultiGraph`
and `SubMultiDiGraph` are replaced by `subgraph_view`.
And `GraphView`, `DiGraphView`, `MultiGraphView`, `MultiDiGraphView`
are deprecated in favor of `generic_graph_view(graph, create_using)`.
Contributors
------------
- Luca Baldesi
- William Bernoudy
- Alexander Condello
- Saurav Das
- Dormir30
- Graham Fetterman
- Robert Gmyr
- Thomas Grainger
- Benjamin M. Gyori
- Ramiro Gómez
- Darío Hereñú
- Mads Jensen
- Michael Johnson
- Pranay Kanwar
- Aabir Abubaker Kar
- Jacek Karwowski
- Mohammed Kashif
- David Kraeutmann
- Winni Kretzschmar
- Ivan Laković
- Daniel Leicht
- Katrin Leinweber
- Alexander Lenail
- Lonnen
- Ji Ma
- Erwan Le Merrer
- Jarrod Millman
- Baurzhan Muftakhidinov
- Neil
- Jens P
- Edward L Platt
- Guillaume Plique
- Miguel Sozinho Ramalho
- Lewis Robbins
- Romain
- Federico Rosato
- Tom Russell
- Dan Schult
- Gabe Schwartz
- Aaron Smith
- Leo Torres
- Martin Váňa
- Ruaridh Williamson
- Huon Wilson
- Haochen Wu
- Yuto Yamaguchi
- Felix Yan
- Jean-Gabriel Young
- aparamon
- armando1793
- aweltsch
- chebee7i
- hongshaoyang
- komo-fr
- leamingrad
- luzpaz
- mtrenfield
- regstrtn
---
### Doc Release Release 2.3 (`doc/release/release_2.3.rst`)
NetworkX 2.3
============
Release date: 11 April 2019
Supports Python 3.5, 3.6 and 3.7.
This is our first Python 3 only release.
We're happy to announce the release of NetworkX 2.3!
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our `gallery of examples
<https://networkx.org/documentation/latest/auto_examples/index.html>`_.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
This release is the result of 6 months of work with over 92 pull requests by
30 contributors. Highlights include:
- Dropped support for Python 2. We are no longer supporting Python 2.7 and we will
start changing code to take advantage of Python 3 features we couldn't before.
- Added some Moral Graph analysis functions.
- Enable matplotlib drawing using curved arrows via connectionstyle parameter.
- Remove ticks and axes labels from matplotlib plots.
- Two new generators of Harary Graphs.
- Added Dual Barabasi-Albert model
- Added VoteRank algorithm
- Added Equitable coloring algorithms
- Added planar layout algorithms
- Les Miserables network example
- JavaScript example update
Improvements
------------
- Change default colors to be color-blind friendly
- Many bug fixes and documentation improvements
- Speed up of simple_cycles
- Improvements for reading various formats like GML, GEXF, Graphml
- Allow subclassing to access node_attr_dict_factory
API Changes
-----------
- The G.fresh_copy() mechanism for creating an empty_graph of the same
type (introduced in v2.0) does not playing nicely with pickle and others.
So, we have removed the code that caused a need for that. Instead you
should use the more natural G.__class__() syntax to get an empty_graph
of the same type as G.
Deprecations
------------
- The Graph.fresh_copy() method should now use Graph.__class__()
- ReverseView class removed in favor of reverse_view() function.
Contributors
------------
- Mike Babst
- Jonathan Barnoud
- Scott Chow
- Jon Crall
- Clayton A Davis
- Michaël Defferrard
- Fredrik Erlandsson
- Eyal
- Tanay Gahlot
- Matthew Gilbert
- Øyvind Heddeland Instefjord
- Hongwei Jin
- Kieran
- Dongkwan Kim
- Julien Klaus
- Warren W. Kretzschmar
- Elias Kuthe
- Eric Ma
- Christoph Martin
- Jarrod Millman
- Issa Moradnejad
- Moradnejad
- Niema Moshiri
- Ramil Nugmanov
- Jens P
- Benjamin Peterson
- Edward L Platt
- Matteo Pozza
- Antoine Prouvost
- Mickaël Schoentgen
- Dan Schult
- Johannes Schulte
- Mridul Seth
- Weisheng Si
- Utkarsh Upadhyay
- damianos
- guidoeco
- jeanfrancois8512
- komo-fr
- last2sword
---
### Doc Release Release 2.4 (`doc/release/release_2.4.rst`)
NetworkX 2.4
============
Release date: 16 October 2019
Supports Python 3.5, 3.6, 3.7, and 3.8.
This is the last release to support Python 3.5.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our `gallery of examples
<https://networkx.org/documentation/latest/auto_examples/index.html>`_.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
This release is the result of 6 months of work with over 200 commits by
67 contributors. Highlights include:
- Remove deprecated code from 1.x
- Support for Python 3.8
- Switched to pytest for testing
- Last release to support Python 3.5
New Functions:
- barycenter functions
- Bethe Hessian matrix function
- Eulerian Path methods
- group centrality measures
- subgraph monomorphisms
- k-truss algorithms
- onion decomposition
- resistance distance
- asteroidal triples
- non-randomness measures
- linear prufing
- minimum weight bipartite matching
- Incremental closeness centrality
- ISMAGS subgraph isomorphism algorithm
- create chordal graph of a graph
New generators
- Binomial tree generator
- Directed joint degree generator
- Random internet AS graph generator
New for Layouts
- spiral node layout routine
- support for 3d layouts
Improvements
------------
- allow average shortest path to use Floyd-Warshall method
- improve read/write of GML, GEXF, GraphML
- allow string or json object as input to jit_graph
- attempt to allow numpy.array input in place of lists in more places
- faster strongly connected components
- faster Floyd-Warshall Optimization
- faster global efficiency
- faster transitive closure
- fix unionfind; betweenness_subset; lexico-topo-sort; A*;
inverse_line_graph; async label propagation; edgelist reading;
Gomory-Hu flow method; label_propagation; partial_duplication;
shell_layout with 1 node in shell; from_pandas_edgelist
- Documentation improvement and fixes
API Changes
-----------
A utility function is_list_of_ints became is_bunch_of_ints
and now tests int(item)==item instead of isinstance(_, int)
This allows e.g. floats whose values are integer.
Added utility make_list_of_ints to convert containers of
integer values to lists of integers
Deprecations
------------
Removed functions (marked as deprecated in NetworkX 2.1):
- attracting_component_subgraphs
- connected_component_subgraphs
- weakly_connected_component_subgraphs
- strongly_connected_component_subgraphs
- biconnected_component_subgraphs
- See docs for component functions for how to get subgraphs.
Graph Object methods removed (marked as deprecated 2.1)
- G.add_path
- G.add_cycle
- G.add_star
- G.nodes_with_selfloops
- G.number_of_selfloops
- G.selfloop_edges
- These are now NetworkX functions, e.g. nx.add_star(G, 5)
- G.node --> use G.nodes
- G.fresh_copy --> use G.__class__
Remove old names for graphview functions.
- ReverseView
- SubGraph
- SubMultiGraph
- SubMultiDiGraph
- SubDiGraph
- GraphView
- DiGraphView
- MultiGraphView
- MultiDiGraphView
- MultiReverseView
- Use reverse_view, subgraph_view and generic_graph_view.
Merged PRs
----------
A total of 205 changes have been committed.
- Bump release version
- algorithms/traversal/edgebfs name fix (#3397)
- Add see also links (#3403)
- Add the reference for the Harary graph generators (#3407)
- typo: swap source and target (#3413)
- Fix spring_layout bug with fixed nodes (#3415)
- Move LFR_benchmark to generators (#3411)
- Add barycenter algorithm (#2939)
- Add bethe hessian matrix (#3401)
- Binomial trees generator (#3409)
- Fix edge_color inconsistency with node_color and description. (#3395)
- Adding module for group centrality measures (#3421)
- Improve edgelist See Also (#3423)
- Typo fix (#3424)
- Add doc warning about self-loops for adamic_adar_index (#3427)
- Fix UnionFind set extraction (#3224)
- add required argument to `write_graphml` example (#3429)
- Fix centrality betweenness subset (#3425)
- Add two versions of Simrank similarity (#3222)
- Fixed typo
- Merge pull request #3436 from nandahkrishna/fix-typo-betweenness-centrality-subset-test
- Reorder and complete doc (#3438)
- added topo_order parameter to functions that rely on topological_sort (#3447)
- Implemented subgraph monomorphism (#3435)
- Set seed in random_degree_sequence_graph docstring test (#3451)
- Replace cb.iterable with np.iterable (#3458)
- don't remove ticks of other pyplot axes (#3476)
- Fix typo in "G>raph Modelling Language" (#3468)
- Naive k-truss algorithm implementation. (#3462)
- Adding onion decomposition (#3461)
- New Feature - Resistance Distance (#3385)
- No multigraphs for betweenness (#3454)
- Wheels are python 3 only
- Fix deprecation warning with Python 3.7 (#3487)
- Fix dfs_preorder_nodes docstring saying "edges" instead of "nodes" (#3484)
- Added group closeness and group degree centralities (#3437)
- Fixed incorrect docs (#3495)
- Fixes Issue #3493 - Bug in lexicographical_topological_sort() (#3494)
- AT-free graph recognition (#3377)
- Update introduction.rst (#3504)
- Full join operation and cograph generator (#3503)
- Optimize the strongly connected components algorithm. (#3516)
- Adding non-randomness measures for graphs (#3515)
- Added safeguards (input graph G) for non-randomness measures (#3526)
- Optimize the strongly connected components algorithm - Take 2 (#3519)
- Small fix for bug found @ issue #3524 (#3529)
- Restore checking PyPy3 (#3514)
- Linear prufer coding (#3535)
- Fix inverse_line_graph. (#3507)
- Fix A* returning wrong solution (#3508)
- Implement minimum weight full matching of bipartite graphs (#3527)
- Get chordal graph for #1054 (#3353)
- Faster transitive closure computation for DAGs (#3445)
- Write mixed-type attributes correctly in write_graphml_lxml (#3536)
- Fixes some edge cases for inverse_line_graph(). (#3538)
- explicitly stated i.j convention in to_numpy_array
- Incremental Closeness Centrality (undirected, unweighted graphs) (#3444)
- Implement ISMAGS subgraph isomorphism algorithm (#3312)
- Fixes bug in networkx.algorithms.community.label_propagation.asyn_lpa_communities (#3545)
- When exporting to GML, write non 32-bit numbers as strings. (#3540)
- Try to bug Fix #3552 (#3554)
- add Directed Joint Degree Graph generator (#3551)
- typo (#3557)
- Fix a few documentation issues for the bipartite algorithm reference (#3555)
- i,j convention in adj mat i/o in relevant funcs
- Merge pull request #3542 from malch2/doc/update
- Add 3.8-dev to travis
- Fix dict iteration for Py3.8
- Ignore other failures for now
- Fix a typo in docstring for get_edge_data (#3564)
- Fix wrong title (#3566)
- Fix typo in docstring (#3568)
- Fix and Improve docstrings in graph.py (#3569)
- Improved graph class selection table (#3570)
- Add spiral layout for graph drawing (#3534)
- #3575 return coordinates of 3d layouts (#3576)
- Handle k==n within the Watts-Strogatz graph generator (#3579)
- Floyd-Warshall Optimization (#3400)
- Use Sphinx 2.2
- Add missing link to asteroidal docs
- Fix Sphinx warnings
- Fix Sphinx latexpdf build
- Updated Contributor list (#3592)
- Prim from list to set (#3512)
- Fix issue 3491 (#3588)
- Make Travis fail on Python 3.8 failures
- Fix test_gexf to handle default serialisation order of the XML attributes
- Remove future imports needed by Py2
- add internet_as_graph generator (#3574)
- remove cyclical references from OutEdgeDataView (#3598)
- Add minimum source and target margin to draw_networkx_edges. (#3390)
- fix to_directed function (#3599)
- Fixes #3573:GEXF output problem (#3606)
- Global efficiency attempt to speed up (#3604)
- Bugfix: Added flexibility in reading values for label and id (#3603)
- Add method floyd-warshall to average_shortest_path_length (#3267)
- Replaced is with == and minor pycodestyle fixes (#3608)
- Fix many documentation based Issues (#3609)
- Resolve many documentation issues (#3611)
- Fixes #3187 transitive_closure now returns self-loops when cycles present (#3613)
- Add support for initializing pagerank_scipy (#3183)
- Add last 7 lines of Gomory-hu algorithm Fixes #3293 (#3614)
- Implemented Euler Path functions (#3399)
- Fix the direction of edges in label_propagation.py (#3619)
- Removed unused import of random module (#3620)
- Fix operation order in partial_duplication_graph (#3626)
- Keep shells with 1 node away from origin in shell_layout (#3629)
- Allow jit_graph to read json string or json object (#3628)
- Fix typo within incode documentation (#3621)
- pycodestyle and update docs for greedy_coloring.py+tests (#3631)
- Add version badges
- Load long description from README
- Add missing code block (#3630)
- Change is_list_of_ints to make_list_of_ints (#3617)
- Handle edgeattr in from_pandas_edgelist when no columns match request (#3634)
- Make draft of release notes for v2.4
- Shift notes from dev to v2.4 filename.
- Use recent pypy
- Test Py 3.8 on macos
- add check of attr type before converting inf/nan in GEXF (#3636)
- Fix sphinx errors And add links to single_source_dijkstra in docs for dijkstra_path/length (#3638)
- Document subgraph_view (#3627)
- First round of pytest fixes
- Use class methods for class setup/teardown
- Have CIs use pytest
- Use class methods for class setup/teardown, cont.
- Do less testing (until we get it working)
- replace idiom from networkx import * in test files
- Fix assert funcs override
- Fix static methods in link_prediction
- Partially fix v2userfunc tests
- Fix graph/digraph tests
- Fix multigraph checks
- Fix multidigraph checks
- Fix test_function checks
- Fix distance_measures tests
- Fix decorators tests
- Fix some raises in test_mst
- Fix clique tests
- Fix yaml tests
- Fix tests in reportviews
- Fix vf2 tests
- Fix mst tests
- Fix gdal tests
- Convert nose.tools.assert_* functions into asserts
- Remove unused imports
- Fix some warnings
- Update testing instructions
- Re-enable all test platforms
- Fix some __init__ warnings
- replace nose yield tests in test_coloring.py
- Add testing, coverage, and dev environment info
- Try pytestimportorskip
- Another pair of variations on pytest.importorskip
- fix typo and try again
- Remove deprecated weakly_connected_component_subgraphs
- replace assert_almost_equal and raises in algorithms/tests
- set places=0 on tests that use old almost_equal
- Update nx.test()
- Have pytest run doctests / not sphinx
- Revert "Remove deprecated weakly_connected_component_subgraphs"
- remove warnings for using deprecated function
- Remove deprecated functions and methods. add to release notes.
- Fix subgraph_view testing
- remove tests of deprecated views and fix use of deprecated G.node
- tracking down use of deprecated functions
- Fix deprecated use of add_path/star/cycle
- reduce warnings for deprecated functions
- skirt issues with raises in test_harmonic
- reduce the number of warnings by removing deprecated functions
- convert_matrix demo of one way to get doctests to work
- Remove deprecated from examples
- Changes to convert_matrix and others that depend on np.matrix
- clean up doctest deprecated code
- More doctest corrections
- Fix examples
- Remove nose from generators
- Remove nose from utils
- Remove nose from classes
- Replace nose.assert_raises with pytest.raises
- Replace nose.raises with pytest.raises context manager
- Replace `eq_`, `ok_` with assert
- Use pytest for doctest
- Highlight switch to pytest in release notes
- Remove `from nose.tools import *`
- Remove nose.tools.SkipTest
- Finalize transition to pytest
- Merge pull request #3639 from stefanv/pytest-port
- Test Python 3.8 with AppVeyor
- Merge pull request #3648 from jarrodmillman/windows-py3.8
- Remove deprecated weakly_connected_component_subgraphs
- Update release notes
- Update README
- Announce Python 3.8 support
- Designate 2.4rc1 release
- Bump release version
- Remove remaining SkipTests
- fix documentation notes (#3644) (#3645)
- Test Py 3.8.0 on AppVeyor
- Speed up AppVeyor
- Cleanup travis config
- Improve CI caching
- Update Py 3.8 on travis
- Merge pull request #3652 from jarrodmillman/speedup-appveyor
- Finalize release notes
It contained the following 5 merges:
- Fixed typo in betweenness centrality subset test (#3436)
- explicitly stated i.j convention in to_numpy_array (#3542)
- pytest port (#3639)
- Test Python 3.8 with AppVeyor (#3648)
- Cleanup and speedup CI (#3652)
Contributors
------------
- Rajendra Adhikari
- Antoine Allard
- Antoine
- Salim BELHADDAD
- Luca Baldesi
- Tamás Bitai
- Tobias Blass
- Malayaja Chutani
- Peter Cock
- Almog Cohen
- Diogo Cruz
- Martin Darmüntzel
- Elan Ernest
- Jacob Jona Fahlenkamp
- Michael Fedell
- Andy Garfield
- Ramiro Gómez
- Haakon
- Alex Henrie
- Steffen Hirschmann
- Martin James McHugh III
- Jacob
- Søren Fuglede Jørgensen
- Omer Katz
- Julien Klaus
- Matej Klemen
- Nanda H Krishna
- Peter C Kroon
- Anthony Labarre
- Anton Lodder
- MCer4294967296
- Eric Ma
- Fil Menczer
- Erwan Le Merrer
- Alexander Metz
- Jarrod Millman
- Subhendu Ranajn Mishra
- Jamie Morton
- James Myatt
- Kevin Newman
- Aaron Opfer
- Aditya Pal
- Pascal-Ortiz
- Peter
- Jose Pinilla
- Alexios Polyzos
- Michael Recachinas
- Efraim Rodrigues
- Adam Rosenthal
- Dan Schult
- William Schwartz
- Weisheng Si
- Kanishk Tantia
- Ivan Tham
- George Valkanas
- Stefan van der Walt
- Hsi-Hsuan Wu
- Haochen Wu
- Xiangyu Xu
- Jean-Gabriel Young
- bkief
- daniel-karl
- michelb7398
- mikedeltalima
- nandahkrishna
- skhiuk
- tbalint
---
### Doc Release Release 2.5 (`doc/release/release_2.5.rst`)
NetworkX 2.5
============
Release date: 22 August 2020
Supports Python 3.6, 3.7, and 3.8.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our `gallery of examples
<https://networkx.org/documentation/latest/auto_examples/index.html>`_.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
This release is the result of 10 months of work with over 200 commits by
92 contributors. Highlights include:
- Dropped support for Python 3.5.
- add Pathlib support to work with files.
- improve performance.
- Updated docs and tests.
- Removed code designed to work with Python 2.
New Functions:
- lukes_partitioning
- triadic analysis functions
- functions for trophic levels analysis
- d_separated
- is_regular and other regular graph measures
- graph_hash using Weisfeiler Lehman methods
- common_neighbor_centrality (CCPA link prediction)
- max_weight_clique
- path_weight and is_path
- rescale_layout_dict
- junction_tree
New generators:
- paley_graph
- interval_graph
New layouts:
- multipartite_layout
Improvements
------------
- Add governance documents, developer guide and community structures
- Implement explicit deprecation policy.
- Initiate an NX Enhancement Proposal (NXEP) system
- optimize single_source_shortest_path
- improved consistent "weight" specification in shortest_path routines
- Reduce numpy.matrix usage which is discouraged by numpy.
- improved line color
- better search engine treatment of docs
- lattice and grid_graph and grid_2d_graph can use dim=tuple
- fix initializer of kamada_kawai_layout algorithm
- moral and threshold functions now included in namespace and docs
- scale arrows better when drawing
- more uniform creation of random lobster graphs
- allow editing graph during iteration over connected_components
- better column handling in conversion of pandas DataFrame
- allow simrank_similarity with directed graph input
- ensure VoteRank ability is nonnegative
- speedup kernighan_lin_bisection
- speedup negative weight cycle detection
- tree_isomorphism
- rooted_tree_isomorphism
- Gexf edge attribute "label" is available
API Changes
-----------
- enabled "copy" flag parameter in `contracted_nodes`
- allow partially periodic lattices
- return value for minimum_st_node_cut now always a set
- removed unused "has_numpy" argument from create_py_random_state
- fixed return values when drawing empty nodes and edges
- allow sets and frozensets of edges as input to nx.Graph()
- "weight" can be function for astar, directional_dijkstra, all_shortest_path
- allow named key ids for GraphML edge writing
- all keywords are now checked for validity in nx.draw and friends
- EdgeDataView "in" operator checks if nodes are "in nbunch"
- remove completeness condition from minimum weight full matching
- option to sort neighbors in bfs traversal
- draw_networkx accepts numpy array for edgelist
- relabel_nodes with 2 nodes mapped to same node can now create multiedge
- steiner_tree works with MultiGraph
- Add `show` kwarg to view_pygraphviz (#4155)
- Prepare for turning chordal_graph_cliques into a generator (#4162)
- GraphML reader keyword force_multigraph creates MultiGraph even w/o multiedges
Deprecations
------------
- [`#3680 <https://github.com/networkx/networkx/pull/3680>`_]
Deprecate `make_str(x)` for `str(x)`.
Deprecate `is_string_like(obj)` for `isinstance(obj, str)`.
- [`#3725 <https://github.com/networkx/networkx/pull/3725>`_]
Deprecate `literal_stringizer` and `literal_destringizer`.
- [`#3983 <https://github.com/networkx/networkx/pull/3983>`_]
Deprecate `reversed` context manager.
- [`#4155 <https://github.com/networkx/networkx/pull/4155>`_]
Deprecate `display_pygraphviz`.
- [`#4162 <https://github.com/networkx/networkx/pull/4162>`_]
Deprecate `chordal_graph_cliques` returning a set.
- [`#4161 <https://github.com/networkx/networkx/pull/4161>`_]
Deprecate `betweenness_centrality_source`.
- [`#4161 <https://github.com/networkx/networkx/pull/4161>`_]
Deprecate `edge_betweenness`.
- [`#4161 <https://github.com/networkx/networkx/pull/4161>`_]
Rename `_naive_greedy_modularity_communities` as `naive_greedy_modularity_communities`.
Merged PRs
----------
A total of 256 changes have been committed.
- Bump release version
- Update release process
- Drop support for Python 3.5
- fix typo docs
- Remove old Python 2 code
- Enable more doctests
- Fix pydot tests
- Unclear how to test the test helper function
- Pathlib introduced in Py 3.4
- Remove code using sys.version_info to detect Python 2
- Use yield from
- PEP8 fixes to tests
- Remove unused imports
- Use pytest.importorskip
- PEP8 fixes
- Remove unused imports
- Add pep8_speaks conf
- Use itertools accumulate
- Fixes issue 3610: Bug in version attribute of gexf.py
- Ignore W503
- Run doctest without optional dependencies
- Skip doctests when missing dependencies
- Remove sed imports
- Enable tests (#3678)
- `contracted_nodes` copy flag added (#3646)
- Deprecate make_str
- Deprecate is_string_like
- Fix PEP8 issues
- Enable ThinGraph tests (#3681)
- Optimize _single_shortest_path_length (#3647)
- Fix issue 3431: Return error in case of bad input to make_small_graph (#3676)
- avoid duplicate tests due to imports (#3684)
- Fix typo: Laplacian -> Laplacian (#3689)
- Add tests
- Lukes algorithm implementation (#3666)
- Remove shim that worked around using starmap
- Add back to gallery
- Add colormap and color limits to LineCollection (#3698)
- Fix matplotlib deprecation (#3697)
- Adapt SciPy CoC
- Update docs to be more accurate about speed of G.neighbors (#3699)
- Use canonical url to help search engines
- Remove duplicate license parameter (#3710)
- Fix documentation issues for exceptions in a few places
- Fix more documentation issues with exceptions
- Remove old Python 2 code
- Remove boiler plate from top of modules
- Remove superfluous encoding information
- Update examples
- Simplify package docstring
- Remove shebang from non-executables
- Add contributors
- K-truss is defined for edges being in (k-2) triangles and not for k triangles (#3713)
- Enable optional tests on Python 3.8
- Fix test_numpy_type to pass under Python 3.8
- Add links to data files
- Deprecate Python 2/3 compatibility code
- Update style
- Update style
- Separate easy and hard to install optional requirements
- Install optional dependencies by default
- Refactor tests
- Sample code for subgraph copy: add parenthesis to is_multigraph (#3734)
- Fixed typo (#3735)
- fix citation links (#3741)
- remove f strings from setup.py for clear error message < py3.6 (#3738)
- 3511 gml list support (#3649)
- added linestyle as argument (#3747)
- Link to files needed for example (#3752)
- fixed a typo
- Merge pull request #3759 from yohm/patch-1
- remove unused variable so grid_graph supports dim=tuple (#3760)
- Sudoku generator issue 3756 (#3757)
- Fix scaling of single node shells in shall_layout (#3764)
- Adding triadic analysis functions (#3742)
- Improve test coverage
- Update contribs script
- Convert %-format to fstring
- Upgrade to Py36 syntax
- Upgrade to Py36 syntax
- Update string format
- Fix scipy deprecation warnings
- Update year
- Silence known warnings (#3770)
- Fix docstring for asyn_fluidc (#3779)
- Fix #3703 (#3784)
- fix initializer for kamada_kawai_layout (networkx #3658) (#3782)
- Minor comments issue (#3787)
- Adding moral and threshold packages to main namespace (#3788)
- Add weight functions to bidirectional_dijkstra and astar (#3799)
- Shrink the source side of an arrow properly when drawing a directed edge. #3805 (#3806)
- option for partially-periodic lattices (networkx #3586) (#3807)
- Prevent KeyError on subgraph_is_monomorphic (#3798)
- Trophic Levels #3736 (#3804)
- UnionFind's union doesn't accurately track set sizes (#3810)
- Remove whitespace (#3816)
- reconsider the lobster generator (#3822)
- Fix typo (#3838)
- fix typo slightly confusing the meaning (#3840)
- Added fix for issue #3846 (#3848)
- Remove unused variable has_numpy from create_py_random_state (#3852)
- Fix return values when drawing empty nodes and edges #3833 (#3854)
- Make connected_components safe to component set mutation (#3859)
- Fix example in docstring (#3866)
- Update README.rst website link to https (#3888)
- typo (#3894)
- Made CONTRIBUTING.rst more clearer (#3895)
- Fixing docs for nx.info(), along with necessary tests (#3893)
- added default arg for json dumps for jit_data func (#3891)
- Fixed nx.Digraph to nx.DiGraph (#3909)
- Use Sphinx 3.0.1
- Fix Sphinx deprecation
- Add logo to docs
- allow set of edge nodes (#3907)
- Add extra information when casting 'id' to int() fails. (Resolves #3910) (#3916)
- add paley graph (#3900)
- add paley graph to doc (#3927)
- Update astar.py (#3947)
- use keywords for positional arguments (#3952)
- fix documentation (#3959)
- Add option for named key ids to GraphML writing. (#3960)
- fix documentation (#3958)
- Correct handling of zero-weight edges in all_shortest_paths (#3783)
- Fix documentation typo (#3965)
- Fix: documentation of simrank_similarity_numpy (#3954)
- Fix for #3930 (source & target columns not overwritten when converting to pd.DataFrame) (#3935)
- Add weight function for shortest simple paths for #3948 (#3949)
- Fix definition of communicability (#3973)
- Fix simrank_similarity with directed graph input (#3961)
- Fixed weakening of voting ability (#3970)
- implemented faster sweep algorithm for kernighan_lin_bisection (#3858)
- Fix issue #3926 (#3928)
- Update CONTRIBUTORS.rst (#3982)
- Deprecate context_manager reversed in favor of reversed_view (#3983)
- Update CONTRIBUTORS.rst (#3987)
- Enhancement for voterank (#3972)
- add d-separation algorithm (#3974)
- DOC: added see also section to find_cycle (#3999)
- improve docs for subgraph_view filter_edge (#4010)
- Fix exception causes in dag.py (#4000)
- use raise from for exceptions in to_networkx_graph (#4009)
- Fix exception causes and messages in 12 modules (#4012)
- Fix typo: `np.int` -> `np.int_` (#4013)
- fix a typo (#4017)
- change documentation (#3981)
- algorithms for regular graphs (#3925)
- Typo Hand should be Hans (#4025)
- DOC: Add testing bullet to CONTRIBUTING. (#4035)
- Update Sphinx
- Update optional/test deps
- Add governance/values/nexp/roadmap
- Improve formatting of None in tutorial (#3986)
- Fixes DiGraph spelling in docstring (#3892)
- Update links to Py3 docs (#4042)
- Add method to clear edges only (#3477)
- Fix exception causes and messages all over the codebase (#4015)
- Handle kwds explicitly in draw_networkx (#4033)
- return empty generator instead of empty list (#3967)
- Correctly infer numpy float types (#3919)
- MAINT: Update from_graph6_bytes arg/docs. (#4034)
- Add URLs/banner/titlebar to documentation (#4044)
- Add negative cycle detection heuristic (#3879)
- Remove unused imports (#3855)
- Fixed Bug in generate_gml(G, stringizer=None) (#3841)
- Raise NetworkXError when k < 2 (#3761)
- MAINT: rm np.matrix from alg. conn. module
- MAINT: rm np.matrix from attribute_ac.
- MAINT,TST: Parametrize methods in TestAlgebraicConnectivity.
- MAINT,TST: parametrize buckminsterfullerene test.
- MAINT,TST: Remove unused _methods class attr
- MAINT,TST: Parametrize TestSpectralOrdering.
- excluded self/recursive edges (#4037)
- WIP: Change EdgeDataView __contains__ feature (2nd attempt) (#3845)
- Index edges for multi graph simple paths (#3358)
- ENH: Add new graph_hashing feature
- Fix pandas deprecation
- Organize removal of deprecated code
- Update sphinx
- ENH: Add roots and timeout to GED (#4026)
- Make gallery more prominent
- Add an implementation for interval_graph and its unit tests (#3705)
- Fixed typo in kamada_kawai_layout docstring (#4059)
- Remove completeness condition from minimum weight full matching (#4057)
- Implemented multipartite_layout (#3815)
- added new Link Prediction algorithm (CCPA) (#4028)
- add the option of sorting node's neighbors during bfs traversal (#4029)
- TST: remove int64 specification from test. (#4055)
- Ran pyupgrade --py36plus
- Remove trailing spaces
- Tell psf/black to ignore specific np.arrays
- Format w/ black
- Add pre-commit hook to for psf/black
- Merge pull request #4060 from jarrodmillman/black
- Fix a few typos in matching docstrings (#4063)
- fix bug for to_scipy_sparse_matrix function (#3985)
- Update documentation of minimum weight full matching (#4062)
- Add maximum weight clique algorithm (#4016)
- Clear pygraphviz object after creating networkx object (#4070)
- Use newer osx on travis (#4075)
- Install Python after updating brew (#4079)
- Add link to black (#4078)
- Improves docs regarding aliases of erdos-reyni graph generators (#4074)
- MAINT: Remove dependency version info from INSTALL (#4081)
- Simplify top-level directory (#4087)
- DOC: Fix return types in laplacianmatrix. (#4090)
- add modularity to the docs (#4096)
- Allow G.remove_edges_from(nx.selfloops_edges(G)) (#4080)
- MAINT: rm private fn in favor of numpy builtin. (#4094)
- Allow custom keys for multiedges in from_pandas_edgelist (#4076)
- Fix planar_layout docstring (#4097)
- DOC: Rewording re: numpy.matrix
- MAINT: rm to/from_numpy_matrix internally
- Merge pull request #4093 from rossbar/rm_npmatrix
- Remove copyright boilerplate (#4105)
- Update contributor guide (#4088)
- Add function to calculate path cost for a specified path (#4069)
- Update docstring for from_pandas_edgelist (#4108)
- Add max_weight_clique to doc (#4110)
- Update deprecation policy (#4112)
- Improve modularity calculation (#4103)
- Add team gallery (#4117)
- CI: Setup circle CI for documentation builds (#4119)
- Build pdf (#4123)
- DOC: Suggestions and improvements from tutorial readthrough (#4121)
- Enable 3.9-dev on travis (#4124)
- Fix parse_edgelist behavior with multiple attributes (#4125)
- CI: temporary fix for CI latex installation issues (#4131)
- Updated draw_networkx to accept numpy array for edgelist (#4132)
- Add tree isomorphism (#4067)
- MAINT: Switch to abc-based isinstance checks in to_networkx_graph (#4136)
- Use dict instead of OrderedDict since dict is ordered by default from Python 3.6. (#4145)
- MAINT: fixups to parse_edgelist. (#4128)
- Update apt-get on circleci image (#4147)
- add rescale_layout_dict to change scale of the layout_dicts (#4154)
- Update dependencies
- Remove gdal from requirements
- relabel_nodes now preserves edges in multigraphs (#4066)
- MAINT,TST: Improve coverage of nx_agraph module (#4156)
- Get steiner_tree to work with MultiGraphs by postprocessing (#4160)
- junction_tree for #1012 (#4004)
- API: Add `show` kwarg to view_pygraphviz. (#4155)
- Prepare for turning chordal_graph_cliques into a generator (#4162)
- Docs update (#4161)
- Remove unnecessary nx imports from doctests (#4163)
- MultiGraph from graphml with explicit edge ids #3470 (#3763)
- Update sphinx dep (#4164)
- Add edge label in GEXF writer as an optional attribute (#3347)
- First Draft of Release Notes for v2.5 (#4159)
- Designate 2.5rc1 release
- Bump release version
- Update deprecations in release notes (#4166)
- DOC: Update docstrings for public functions in threshold module (#4167)
- Format python in docstrings (#4168)
- DOC,BLD: Fix doc build warning from markup error. (#4174)
It contained the following 3 merges:
- fixed a typo (#3759)
- Use psf/black (#4060)
- MAINT: Replace internal usage of to_numpy_matrix and from_numpy_matrix (#4093)
Contributors
------------
- Adnan Abdulmuttaleb
- Abhi
- Antoine-H
- Salim BELHADDAD
- Ross Barnowski
- Lukas Bernwald
- Isaac Boates
- Kelly Boothby
- Matthias Bruhns
- Mahmut Bulut
- Rüdiger Busche
- Gaetano Carpinato
- Nikos Chan
- Harold Chan
- Camden Cheek
- Daniel
- Daniel-Davies
- Bastian David
- Christoph Deil
- Tanguy Fardet
- 赵丰 (Zhao Feng)
- Andy Garfield
- Oded Green
- Drew H
- Alex Henrie
- Kang Hong Jin
- Manas Joshi
- Søren Fuglede Jørgensen
- Aabir Abubaker Kar
- Folgert Karsdorp
- Suny Kim
- Don Kirkby
- Katherine Klise
- Steve Kowalik
- Ilia Kurenkov
- Whi Kwon
- Paolo Lammens
- Zachary Lawrence
- Sanghack Lee
- Anton Lodder
- Lukas Lösche
- Eric Ma
- Mackyboy12
- Christoph Martin
- Alex Marvin
- Mattwmaster58
- James McDermott
- Jarrod Millman
- Ibraheem Moosa
- Yohsuke Murase
- Neil
- Harri Nieminen
- Danny Niquette
- Carlos G. Oliver
- Juan Orduz
- Austin Orr
- Pedro Ortale
- Aditya Pal
- PalAditya
- Jose Pinilla
- PranayAnchuri
- Jorge Martín Pérez
- Pradeep Reddy Raamana
- Ram Rachum
- David Radcliffe
- Federico Rosato
- Tom Russell
- Craig Schmidt
- Jonathan Schneider
- Dan Schult
- Mridul Seth
- Karthikeyan Singaravelan
- Songyu-Wang
- Kanishk Tantia
- Jeremias Traub
- James Trimble
- Shashi Tripathi
- Stefan van der Walt
- Jonatan Westholm
- Kazimierz Wojciechowski
- Jangwon Yie
- adnanmuttaleb
- anentropic
- arunwise
- beckedorf
- ernstklrb
- farhanbhoraniya
- fj128
- gseva
- haochenucr
- johnthagen
- kiryph
- muratgu
- ryan-duve
- sauxpa
- tombeek111
- willpeppo
---
### Doc Release Release 2.6 (`doc/release/release_2.6.rst`)
.. _networkx_2.6:
NetworkX 2.6
============
Release date: 08 July 2021
Supports Python 3.7, 3.8, and 3.9.
This release has a larger than normal number of changes in preparation for the upcoming 3.0 release.
The current plan is to release 2.7 near the end of summer and 3.0 in late 2021.
See :doc:`migration_guide_from_2.x_to_3.0` for more details.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
This release is the result of 11 months of work with over 363 pull requests by
91 contributors. Highlights include:
- Dropped support for Python 3.6
- Dropped "decorator" library dependency
- Improved example gallery
- Removed code for supporting Jython/IronPython
- The ``__str__`` method for graph objects is more informative and concise.
- Improved import time
- Improved test coverage
- New documentation theme
- Add functionality for drawing self-loop edges
- Add approximation algorithms for Traveling Salesman Problem
New functions:
- Panther algorithm
- maximum cut heuristics
- equivalence_classes
- dedensification
- random_ordered_tree
- forest_str
- snap_aggregation
- networkx.approximation.diameter
- partition_quality
- prominent_group
- prefix_tree_recursive
- topological_generations
NXEPs
-----
**N**\etwork\ **X** **E**\nhancement **P**\roposals capture changes
that are larger in scope than typical pull requests, such as changes to
fundamental data structures.
The following proposals have come under consideration since the previous
release:
- :ref:`NXEP2`
- :ref:`NXEP3`
Improvements
------------
- [`#3886 <https://github.com/networkx/networkx/pull/3886>`_]
Adds the Panther algorithm for top-k similarity search.
- [`#4138 <https://github.com/networkx/networkx/pull/4138>`_]
Adds heuristics for approximating solution to the maximum cut problem.
- [`#4183 <https://github.com/networkx/networkx/pull/4183>`_]
Adds ``equivalence_classes`` to public API.
- [`#4193 <https://github.com/networkx/networkx/pull/4193>`_]
``nx.info`` is more concise.
- [`#4198 <https://github.com/networkx/networkx/pull/4198>`_]
Improve performance of ``transitivity``.
- [`#4206 <https://github.com/networkx/networkx/pull/4206>`_]
UnionFind.union selects the heaviest root as the new root
- [`#4240 <https://github.com/networkx/networkx/pull/4240>`_]
Adds ``dedensification`` function in a new ``summarization`` module.
- [`#4294 <https://github.com/networkx/networkx/pull/4294>`_]
Adds ``forest_str`` for string representation of trees.
- [`#4319 <https://github.com/networkx/networkx/pull/4319>`_]
pagerank uses scipy by default now.
- [`#4841 <https://github.com/networkx/networkx/pull/4841>`_]
simrank_similarity uses numpy by default now.
- [`#4317 <https://github.com/networkx/networkx/pull/4317>`_]
New ``source`` argument to ``has_eulerian_path`` to look for path starting at
source.
- [`#4356 <https://github.com/networkx/networkx/pull/4356>`_]
Use ``bidirectional_dijkstra`` in ``shortest_path`` for weighted graphs
to improve performance.
- [`#4361 <https://github.com/networkx/networkx/pull/4361>`_]
Adds ``nodelist`` argument to ``triadic_census``
- [`#4435 <https://github.com/networkx/networkx/pull/4435>`_]
Improve ``group_betweenness_centrality``.
- [`#4446 <https://github.com/networkx/networkx/pull/4446>`_]
Add ``sources`` parameter to allow computing ``harmonic_centrality`` from a
subset of nodes.
- [`#4463 <https://github.com/networkx/networkx/pull/4463>`_]
Adds the ``snap`` summarization algorithm.
- [`#4476 <https://github.com/networkx/networkx/pull/4476>`_]
Adds the ``diameter`` function for approximating the lower bound on the
diameter of a graph.
- [`#4519 <https://github.com/networkx/networkx/pull/4519>`_]
Handle negative weights in clustering algorithms.
- [`#4528 <https://github.com/networkx/networkx/pull/4528>`_]
Improved performance of ``edge_boundary``.
- [`#4560 <https://github.com/networkx/networkx/pull/4560>`_]
Adds ``prominent_group`` function to find prominent group of size k in
G according to group_betweenness_centrality.
- [`#4588 <https://github.com/networkx/networkx/pull/4588>`_]
Graph intersection now works when input graphs don't have the same node sets.
- [`#4607 <https://github.com/networkx/networkx/pull/4607>`_]
Adds approximation algorithms for solving the traveling salesman problem,
including ``christofides``, ``greedy_tsp``, ``simulated_annealing_tsp``,
and ``threshold_accepting_tsp``.
- [`#4640 <https://github.com/networkx/networkx/pull/4640>`_]
``prefix_tree`` now uses a non-recursive algorithm. The original recursive
algorithm is still available via ``prefix_tree_recursive``.
- [`#4659 <https://github.com/networkx/networkx/pull/4659>`_]
New ``initial_graph`` argument to ``barabasi_albert_graph`` and
``dual_barabasi_albert_graph`` to supply an initial graph to the model.
- [`#4690 <https://github.com/networkx/networkx/pull/4690>`_]
``modularity_max`` now supports edge weights.
- [`#4727 <https://github.com/networkx/networkx/pull/4727>`_]
Improved performance of ``scale_free_graph``.
- [`#4739 <https://github.com/networkx/networkx/pull/4739>`_]
Added `argmap` function to replace the decorator library dependence
- [`#4757 <https://github.com/networkx/networkx/pull/4757>`_]
Adds ``topological_generations`` function for DAG stratification.
- [`#4768 <https://github.com/networkx/networkx/pull/4768>`_]
Improved reproducibility of geometric graph generators.
- [`#4769 <https://github.com/networkx/networkx/pull/4769>`_]
Adds ``margins`` keyword to ``draw_networkx_nodes`` to control node clipping
in images with large node sizes.
- [`#4812 <https://github.com/networkx/networkx/pull/4812>`_]
Use ``scipy`` implementation for ``hits`` algorithm to improve performance.
- [`#4847 <https://github.com/networkx/networkx/pull/4847>`_]
Improve performance of ``scipy`` implementation of ``hits`` algorithm.
API Changes
-----------
- [`#4183 <https://github.com/networkx/networkx/pull/4183>`_]
``partition`` argument of `quotient_graph` now accepts dicts
- [`#4190 <https://github.com/networkx/networkx/pull/4190>`_]
Removed ``tracemin_chol``. Use ``tracemin_lu`` instead.
- [`#4216 <https://github.com/networkx/networkx/pull/4216>`_]
In `to_*_array/matrix`, nodes in nodelist but not in G now raise an exception.
Use G.add_nodes_from(nodelist) to add them to G before converting.
- [`#4360 <https://github.com/networkx/networkx/pull/4360>`_]
Internally `.nx_pylab.draw_networkx_edges` now always generates a
list of `matplotlib.patches.FancyArrowPatch` rather than using
a `matplotlib.collections.LineCollection` for un-directed graphs. This
unifies interface for all types of graphs. In
addition to the API change this may cause a performance regression for
large graphs.
- [`#4384 <https://github.com/networkx/networkx/pull/4384>`_]
Added ``edge_key`` parameter for MultiGraphs in to_pandas_edgelist
- [`#4461 <https://github.com/networkx/networkx/pull/4461>`_]
Added ``create_using`` parameter to ``binomial_tree``
- [`#4466 <https://github.com/networkx/networkx/pull/4466>`_]
`relabel_nodes` used to raise a KeyError for a key in `mapping` that is not
a node in the graph, but it only did this when `copy` was `False`. Now
any keys in `mapping` which are not in the graph are ignored.
- [`#4502 <https://github.com/networkx/networkx/pull/4502>`_]
Moves ``maximum_independent_set`` to the ``clique`` module in ``approximation``.
- [`#4536 <https://github.com/networkx/networkx/pull/4536>`_]
Deprecate ``performance`` and ``coverage`` in favor of ``partition_quality``,
which computes both metrics simultaneously and is more efficient.
- [`#4573 <https://github.com/networkx/networkx/pull/4573>`_]
`label_propagation_communities` returns a `dict_values` object of community
sets of nodes instead of a generator of community sets. It is still iterable,
so likely will still work in most user code and a simple fix otherwise:
e.g., add ``iter( ... )`` surrounding the function call.
- [`#4545 <https://github.com/networkx/networkx/pull/4545>`_]
`prefix_tree` used to return `tree, root` but root is now always 0
instead of a UUID generate string. So the function returns `tree`.
- [`#4545 <https://github.com/networkx/networkx/pull/4545>`_]
The variable `NIL` ="NIL" has been removed from `networkx.generators.trees`
- [`#3620 <https://github.com/networkx/networkx/pull/3620>`_]
The function `naive_greedy_modularity_communities` now returns a
list of communities (like `greedy_modularity_communities`) instead
of a generator of communities.
- [`#4786 <https://github.com/networkx/networkx/pull/4786>`_]
Deprecate the ``attrs`` keyword argument in favor of explicit keyword
arguments in the ``json_graph`` module.
- [`#4843 <https://github.com/networkx/networkx/pull/4843>`_]
The unused ``normalized`` parameter has been removed
from ``communicability_betweenness_centrality``
- [`#4850 <https://github.com/networkx/networkx/pull/4850>`_]
Added ``dtype`` parameter to adjacency_matrix
- [`#4851 <https://github.com/networkx/networkx/pull/4851>`_]
Output of `numeric_mixing_matrix` and `degree_mixing_matrix` no longer
includes rows with all entries zero by default. The functions now accept
a parameter `mapping` keyed by value to row index to identify each row.
- [`#4867 <https://github.com/networkx/networkx/pull/4867>`_]
The function ``spring_layout`` now ignores 'fixed' nodes not in the graph
Deprecations
------------
- [`#4238 <https://github.com/networkx/networkx/pull/4238>`_]
Deprecate ``to_numpy_matrix`` and ``from_numpy_matrix``.
- [`#4279 <https://github.com/networkx/networkx/pull/4279>`_]
Deprecate ``networkx.utils.misc.is_iterator``.
Use ``isinstance(obj, collections.abc.Iterator)`` instead.
- [`#4280 <https://github.com/networkx/networkx/pull/4280>`_]
Deprecate ``networkx.utils.misc.is_list_of_ints`` as it is no longer used.
See ``networkx.utils.misc.make_list_of_ints`` for related functionality.
- [`#4281 <https://github.com/networkx/networkx/pull/4281>`_]
Deprecate ``read_yaml`` and ``write_yaml``.
- [`#4282 <https://github.com/networkx/networkx/pull/4282>`_]
Deprecate ``read_gpickle`` and ``write_gpickle``.
- [`#4298 <https://github.com/networkx/networkx/pull/4298>`_]
Deprecate ``read_shp``, ``edges_from_line``, and ``write_shp``.
- [`#4319 <https://github.com/networkx/networkx/pull/4319>`_]
Deprecate ``pagerank_numpy``, ``pagerank_scipy``.
- [`#4355 <https://github.com/networkx/networkx/pull/4355>`_]
Deprecate ``copy`` method in the coreview Filtered-related classes.
- [`#4384 <https://github.com/networkx/networkx/pull/4384>`_]
Deprecate unused ``order`` parameter in to_pandas_edgelist.
- [`#4428 <https://github.com/networkx/networkx/pull/4428>`_]
Deprecate ``jit_data`` and ``jit_graph``.
- [`#4449 <https://github.com/networkx/networkx/pull/4449>`_]
Deprecate ``consume``.
- [`#4448 <https://github.com/networkx/networkx/pull/4448>`_]
Deprecate ``iterable``.
- [`#4536 <https://github.com/networkx/networkx/pull/4536>`_]
Deprecate ``performance`` and ``coverage`` in favor of ``partition_quality``.
- [`#4545 <https://github.com/networkx/networkx/pull/4545>`_]
Deprecate ``generate_unique_node``.
- [`#4599 <https://github.com/networkx/networkx/pull/4599>`_]
Deprecate ``empty_generator``.
- [`#4600 <https://github.com/networkx/networkx/pull/4600>`_]
Deprecate ``default_opener``.
- [`#4617 <https://github.com/networkx/networkx/pull/4617>`_]
Deprecate ``hub_matrix`` and ``authority_matrix``
- [`#4629 <https://github.com/networkx/networkx/pull/4629>`_]
Deprecate the ``Ordered`` graph classes.
- [`#4802 <https://github.com/networkx/networkx/pull/4802>`_]
The ``nx_yaml`` function has been removed along with the dependency on
``pyyaml``. Removal implemented via module ``__getattr__`` to patch security
warnings related to ``pyyaml.Loader``.
- [`#4826 <https://github.com/networkx/networkx/pull/4826>`_]
Deprecate ``preserve_random_state``.
- [`#4827 <https://github.com/networkx/networkx/pull/4827>`_]
Deprecate ``almost_equal``.
- [`#4833 <https://github.com/networkx/networkx/pull/4833>`_]
Deprecate ``run``.
- [`#4829 <https://github.com/networkx/networkx/pull/4829>`_]
Deprecate ``assert_nodes_equal``, ``assert_edges_equal``, and ``assert_graphs_equal``.
- [`#4850 <https://github.com/networkx/networkx/pull/4850>`_]
Deprecate ``adj_matrix``.
- [`#4841 <https://github.com/networkx/networkx/pull/4841>`_]
Deprecate ``simrank_similarity_numpy``.
- [`#4923 <https://github.com/networkx/networkx/pull/4923>`_]
Deprecate ``numeric_mixing_matrix``.
- [`#4937 <https://github.com/networkx/networkx/pull/4937>`_]
Deprecate ``k_nearest_neighbors``.
Merged PRs
----------
- Bump release version
- Update release process
- Update website doc
- fix issue #4173: cytoscape_graph(input_data) did modify the original data (#4176)
- Some docstring fixes for draw_networkx_edge_labels() in nx_pylab.py + one typo (#4182)
- TST: add dtype to pandas test (#4185)
- Partitions for quotient graphs (#4183)
- graphml: re-add graph attribute type 'long' after 857aa81 removed it (#4189)
- Test mac osx via actions (#4201)
- DOC: Update docstrings in cytoscape module (#4180)
- rewrite add_nodes_from to relax code meant to allow ironpython pre-2.7.5 (#4200)
- Speed up transitivity, remove redundant call (#4198)
- NXEP 2 — API design of view slices (#4101)
- Cleanup old platforms (#4202)
- Fixed "topological_sort" typo (#4211)
- Make optional dependencies default on CPython
- Simplify imports
- Populate setup.py requires from requirements
- Update dependencies
- Remove _CholeskySolver
- to_numpy/scipy array functions should not allow non-nodes in nodelist (#4216)
- fix "see also" links in json_graph.tree (#4222)
- MAINT: changed is_string_like to isinstance (#4223)
- Fix UnionFind.union to select the heaviest root as the new root (#4206)
- CI: Configure circleCI to deploy docs. (#4134)
- MAINT: Update nx.info (#4193)
- Fix indexing in kernighan_lin_bisection (#4177)
- CI: Add GH fingerprint (#4229)
- Create ssh dir for circleci
- CI: update circleci doc deployment. (#4230)
- Revert "CI: Configure circleCI to deploy docs. (#4134)" (#4231)
- DOC: Add discussion to NXEP 2.
- Update format dependencies
- Use black for linting
- Format w/ black==20.8b1
- Check formatting of PRs via black (#4235)
- TST: Modify heuristic for astar path test. (#4237)
- MAINT: Deprecate numpy matrix conversion functions (#4238)
- Add roadmap (#4234)
- Add nx.info to str dunder for graph classes (#4241)
- DOC: Minor reformatting of contract_nodes docstring. (#4245)
- Fix betweenness_centrality doc paper links (#4257)
- Fix bug in has_eulerian_path for directed graphs (#4246)
- Add PR template (#4258)
- Use seed to make plot fixed (#4260)
- Update giant component example (#4267)
- Update "house with colors" gallery example (#4263)
- Replace degree_histogram and degree_rank with a single example (#4265)
- Update Knuth miles example. (#4251)
- Update "four_grids" gallery example (#4264)
- Improve legibility of labels in plot_labels_and_colors example (#4266)
- Improve readability of chess_example in gallery (#4252)
- Fix contracted_edge for multiple edges (#4274)
- Add seeds to gallery examples for reproducibility (#4276)
- Add a 3D plotting example with matplotlib to the gallery (#4268)
- Deprecate `utils.is_iterator` (#4279)
- Deprecate utils.is_list_of_ints (#4280)
- Improve axes layout in plot_decomposition example (#4278)
- Update homepage URL (#4285)
- Build docs for deployment on Travis CI (#4286)
- Add simple graph w/ manual layout (#4291)
- Deprecate nx_yaml (#4281)
- Deprecate gpickle (#4282)
- Improve relabel coverage, tweak docstrings (#4299)
- Switch to travis-ci.com
- TST: Increase test coverage of convert_matrix (#4301)
- Add descriptive error message for Node/EdgeView slicing. NEXP2 (#4300)
- Don't import other people's version.py (#4289)
- TST: Refactor to improve coverage. (#4307)
- Improve readwrite test coverage (#4310)
- Fix typo (#4312)
- Update docstring of to_dict_of_dicts.
- Add tests for edge_data param.
- Minor touchups to docstring
- adds dedensification function (#4240)
- TST: improve multigraph test coverage to 100% (#4340)
- Add rainbow coloring example to gallery. (#4330)
- Test on Python 3.9 (#4303)
- Sphinx33 (#4342)
- fix order of yield and seen.update in all cc routines (see #4331 & #3859 & 3823) (#4333)
- Updates to slicing error message for reportviews (#4304)
- Eulerian path fix (#4317)
- Add FutureWarning in preparation for simplifying cytoscape function signatures. (#4284)
- Move a few imports inside functions to improve import speed of the library (#4296)
- Address comments from code review.
- Cleanup algebraicconnectivity (#4287)
- Switch from travis to gh actions (#4320)
- Fix (#4345)
- Fix travis doc deployment
- Fix gdal version on travis
- Update to_dict_of_dict edge_data (#4321)
- Update adjacency_iter to adjacency (#4339)
- Test and document missing nodes/edges in set_{node/edge}_attributes (#4346)
- Update tests and docs for has_eulerian_path (#4344)
- Deprecate nx_shp (#4298)
- Refactor and improve test coverage for restricted_view and selfloop_edges (#4351)
- Enable mayavi in sphinx gallery. (#4297)
- CI: Add mayavi conf to travis and GH for doc deploy (#4354)
- Fix doc build w/ GH actions
- Install vtk before mayavi
- Install vtk before mayavi
- Install vtk before mayavi
- Use bidirectional_dijkstra as default in weighted shortest_path (#4356)
- Add unit tests for utils.misc.flatten (#4359)
- Improve test coverage for coreviews.py (#4355)
- Update tutorial.rst - Fixes #4249 (#4358)
- Bugfix for issue 4336, moving try/except and adding else clause (#4365)
- Added nodelist attribute to triadic_census (#4361)
- API: always use list of FancyArrowPatch rather than LineCollection (#4360)
- MNT: make the self-loop appear in all cases (#4370)
- Add additional libraries to intersphinx mapping (#4372)
- Make nx.pagerank a wrapper around different implementations, use scipy one by default (#4319)
- MAINT: remove deprecated numpy type aliases. (#4373)
- DOC: Fix return type for random_tournament and hamiltonian_path (#4376)
- Skip memory leak test for PyPy (#4385)
- add OSMnx example (#4383)
- Update docstring for to_pandas_edgelist and add edgekey parameter (#4384)
- TST: Boost test coverage of nx_pylab module (#4375)
- Fixed issue where edge attributes were being silently overwritten during node contraction (#4273)
- CI: Fix CircleCI doc build failure (#4388)
- Improve test coverage of convert module (#4306)
- Add gene-gene network (#4269)
- Ignore expected warnings (#4391)
- Use matrix multiplication operator (#4390)
- code and doc fix for square_clustering algorithm in cluster.py (#4392)
- Remove xml import checks (#4393)
- fix typo in NXEP template (#4396)
- Add Panther algorithm per #3849 (#3886)
- Pagerank followup (#4399)
- Don't import nx from networkx (#4403)
- Modify and document behavior of nodelist param in draw_networkx_edges. (#4378)
- Add circuit plot (#4408)
- Add words graph plot (#4409)
- DOC: Remove repeated words (#4410)
- Add plot for rcm example (#4411)
- Fix small index iteration bug in kernighan_lin algorithm (#4398)
- Use str dunder (#4412)
- Use xetex for uft8 latex backend (#4326)
- Add recommended fonts to travis.yml. (#4414)
- CI: Workaround font naming bug. (#4416)
- DOC: geospatial example using lines (#4407)
- Add plotting examples for geospatial data (#4366)
- Increase coverage in graphviews.py (#4418)
- Refactor gallery (#4422)
- Safer repr format of variables (#4413)
- Updates to docs and imports for classic.py (#4424)
- Remove advanced example section (#4429)
- Add coreview objects to documentation (#4431)
- Add gallery example for drawing self-loops. (#4430)
- Add igraph example (#4404)
- Standard imports (#4401)
- Collect graphviz examples (#4427)
- NXEP 3: Allow generators to yield from edgelists (#4395)
- Update geospatial readme (#4417)
- DOC: Fix broken links in shortest_path docstrings (#4434)
- Improves description bfs_predecessors and bfs_successors. (#4438)
- Deprecate jit (#4428)
- JavaScript example: fix link (#4450)
- Deprecate utils.misc.consume (#4449)
- DOC: Switch from napoleon to numpydoc sphinx extension (#4447)
- Correct networkxsimplex docstring re: multigraph
- Correct networkxsimplex docstring re: multigraph (#4455)
- Maxcut heuristics (#4138)
- binomial_tree() with "create_using parameter (#4461)
- Reorganize tests (#4467)
- Drop Py3.6 support per NEP 29 (#4469)
- Add random_ordered_tree and forest_str (#4294)
- Deprecate iterable (#4448)
- Allow relabel_nodes mapping to have non-node keys that get ignored (#4466)
- Fixed docs + added decorator for k_components approx (#4474)
- Update docs for clustering Fixes #4348 (#4477)
- Handle self-loops for single self-loop (drawing) (#4425)
- Update GH actions links in README (#4482)
- Improve code coverage for cuts.py (#4473)
- Re-enable tests (#4488)
- Update Sphinx (#4494)
- Update pre-commit (#4495)
- Simplify example dependencies (#4506)
- Update geospatial readme (#4504)
- Update year (#4509)
- Drop Travis CI (#4510)
- Run pypy tests separately (#4512)
- Simplify version information (#4492)
- Delete old test (#4513)
- Gallery support for pygraphviz examples (#4464)
- TST: An approach to parametrizing read_edgelist tests. (#4292)
- Setup cross-repo doc deploy via actions. (#4480)
- use issue templates to redirect to discussions tab, add a bug report template (#4524)
- Fix performance issue in nx.edge_boundary (#4528)
- clean up list comp (#4499)
- Improve code coverage of swap.py (#4529)
- Clustering for signed weighted graphs (#4519)
- Fix docstrings and remove unused variables (#4501)
- Improving code coverage of chordal.py (#4471)
- Cliques on multigraph/directed graph types (#4502)
- Approximated Diameter (#4476)
- `arrows` should be True by default for directed graphs (#4522)
- Remove unnecessary node_list from gallery example (#4505)
- fixing the width argument description of the function draw_networkx (#4479)
- Partially revert #4378 - Modify behavior of nodelist param in draw_networkx_edges. (#4531)
- Replace generate_unique_node internally where not needed (#4537)
- Extend harmonic centrality to include source nodes (#4446)
- improve group betweenness centrality (#4435)
- fixes GitHub Actions failures (#4548)
- updated cutoff def in weighted.py (#4546)
- Less strict on mayavi constraint for doc building. (#4547)
- Update docstring for ancestor and descendents (#4550)
- TST: Fix error in katz centrality test setup. (#4554)
- Correct mu parameter documentation for LFR (#4557)
- Pin pygeos==0.8 (#4563)
- Unpin pygeos (#4570)
- Test Windows via GH actions (#4567)
- Update documentation and testing of arbitrary_element (#4451)
- added test for max_iter argument
- reformatted test_kernighan_lin.py
- Simplify test pylab (#4577)
- Update README.rst
- Fix search (#4580)
- Add test Kernighan Lin Algorithm (#4575)
- Fix typos (#4581)
- Boiler plate for mentored projects documentation (#4576)
- Deprecate generate_unique_node (#4545)
- Check nodelist input to floyd_warshall (#4589)
- Improve intersection function (#4588)
- Pygraphviz choco (#4583)
- Add prominent group algorithm (#4560)
- Add partition_quality to compute coverage and performance (coverage and perfor… (#4536)
- Use Pillow for viewing AGraph output and deprecate default_opener (#4600)
- Remove mktemp usage (#4593)
- Add an FAQ to the developer guide for new contributors (#4556)
- Improve test coverage and docs for nonrandomness (#4613)
- Collect label propagation communities in one go (#4573)
- Deprecate networkx.utils.empty_generator. (#4599)
- return earlier from `clique.graph_clique_number` (#4622)
- More for projects page: TSP and Graph Isomorphism (#4620)
- add recommended venv directory to .gitignore (#4619)
- adding weight description to centrality metrics (#4610)
- Add a good first issue badge to README (#4627)
- add test to regular (#4624)
- Add scipy-1.6.1 to blocklist. (#4628)
- Deprecate hub_matrix and authority_matrix (#4617)
- Fix issue #3153: generalized modularity maximization (#3260)
- Improve doc example for find_cycle. (#4639)
- Correct and update Atlas example (#4635)
- Remove attr_dict from parameters list in the docstring (#4642)
- Verify edges are valid in is_matching() (#4638)
- Remove old file reference (#4646)
- Deprecate Ordered graph classes (#4629)
- Update CI to use main (#4651)
- Make main default branch (and remove gitwash) (#4649)
- Fix link for Katz centrality definition (#4655)
- fix for negative_edge_cycle weight kwarg to bellman_ford (#4658)
- Refactor bipartite and multipartite layout (#4653)
- Volunteering for mentorship (#4671)
- Adding an iterative version of prefix tree (#4640)
- Increase code coverage tournament (#4665)
- Fix to_vertex_cover (#4667)
- Reorganize minor submodule as subpackage (#4349)
- modularity_max: account for edge weights (#4690)
- Remove instances of random.sample from sets (deprecated in Python 3.9) (#4602)
- Fixing Bug in Transitive Reduction, resulting in loss of node/edge attributes (#4684)
- direct links to the tutorial and discussions in README (#4711)
- Pin upper bound of decorator dep. (#4721)
- fix typo (#4724)
- Updating average_clustering() documentation - Issue #4734 (#4735)
- rm nx import from docstring example. (#4738)
- CI: persist pip cache between circleci runs (#4714)
- Use pydata sphinx theme (#4741)
- O(n^2) -> O(n) implementation for scale_free_graph (#4727)
- TST: be more explicit about instance comparison. (#4748)
- fix typo in docstring (ismorphism -> isomorphism) (#4756)
- CI: Fix cartopy build failure in docs workflow (#4751)
- Add missing __all__'s to utils modules + test. (#4753)
- Add 2 articles for TSP project as references (#4758)
- Improve reproducibility of geometric graphs (#4768)
- Updated decorator requirement for #4718 (#4773)
- Gallery Example: Drawing custom node icons on network using MPL (#4633)
- Get rid of invalid escape sequences. (#4789)
- imread(url) is deprecated, use pillow + urllib to load image from URL (#4790)
- Add auto-margin scaling in draw_networkx_nodes function (fix for issue 3443) (#4769)
- Update documentation dependencies (#4794)
- Fix sphinx warnings during doc build. (#4795)
- Remove mayavi and cartopy dependencies (#4800)
- make plots less dense, enable plotting for igraph (#4791)
- fix urllib import (#4793)
- Improve documentation look (#4801)
- Add approximation algorithms for traveling salesman problem (#4607)
- adds implementation of SNAP summarization algorithm (#4463)
- Update black (#4814)
- Restructure documentation (#4744)
- Pin upper bound on decorator for 2.6 release. (#4815)
- Use `callable()` to check if the object is callable (#1) (#4678)
- Remove dictionary from signature of tree_graph and tree_data (#4786)
- Make nx.hits a wrapper around different implementations, use scipy one by default (#4812)
- restructured networksimplex.py and added test_networksimplex.py (#4685)
- Update requirements (#4625)
- Fix Sphinx errors (#4817)
- Add topological_generations function (#4757)
- Add `initial_graph` parameter to simple and dual Barábasi-Albert random graphs (#4659)
- Link to guides (#4818)
- switch alias direction of spring_layout and fruchterman_reingold_layout (#4820)
- Fix to_undirected doc typo (#4821)
- Deprecate preserve_random_state (#4826)
- Fixes read/write_gml with nan/inf attributes (#4497)
- Remove pyyaml dependency via module getattr (#4802)
- Use pytest.approx (#4827)
- DOC: Clarify behaviour of k_crust(G, k) (#4831)
- Limit number of threads used by OMP in circleci. (#4830)
- Deprecate run (#4833)
- Fix a few broken links in the html docs (#4572)
- Refactor testing utilities (#4829)
- Fix edge drawing performance regression (#4825)
- Draft 2.6 release notes (#4828)
- Fix bad import pattern (#4839)
- Add info about testing and examples (#4582)
- Remove unused `normalized` parameter from communicability_betweenness_centrality (#4843)
- add special processing of `multigraph_input` upon graph init (#4823)
- Add dtype argument to adjacency_matrix (#4850)
- Use scipy to compute eigenvalues (#4847)
- Default to NumPy for simrank_similarity (#4841)
- Remove "networkx" from top-level networkx namespace (#4840)
- Designate 2.6rc1 release
- Bump release version
- DOC: point towards web archive link in GML docs (#4864)
- Fix docstring typo (#4871)
- Reformatted table to address issue #4852 (#4875)
- spring_layout: ignore 'fixed' nodes not in the graph nodes (#4867)
- Deserializing custom default properties graph ml (#4872)
- DOC: Fix links, use DOI links, wayback machine where required (#4868)
- Fix conda instructions (#4884)
- Decode GraphML/yEd shape type (#4694)
- bugfix-for-issue-4353: modify default edge_id format (#4842)
- Raise ValueError if None is added as a node. (#4892)
- Update arrows default value in draw_networkx. (#4883)
- Doc/fix 403 error drawing custom icons (#4906)
- Remove decorator dependency (#4739)
- Update docstrings for dfs and bfs edges and fix cross links (#4900)
- Fix graph_class usage in to_undirected method (#4912)
- Fix assortativity coefficient calculation (#4851)
- Deprecate numeric_mixing_matrix. (#4923)
- Update read_gml docstring with destringizer ex (#4916)
- Update release process (#4866)
- Designate 2.6rc2 release
- Bump release version
- Add 3.0 migration guide (#4927)
- quotient_graph doc fix (#4930)
- Page number for Katz centrality reference (#4932)
- Expand destringizer example in read_gml docstring (#4925)
- move partition checking outside private _quotient_graph function (#4931)
- Fixes #4275 - Add comment to parallel betweenness example (#4926)
- Minor Improvements on Networkx/algorithms/community/quality.py (#4939)
- Fix numeric and degree assortativity coefficient calculation (#4928)
- fix spelling in docstring of conftest.py (#4945)
- fix trouble with init_cycle argument to two TSP functions (#4938)
- split out deprecation. remove all changes to neighbor_degree (#4937)
- Add matrix market to readwrite reference (#4934)
- fix typo for PR number of deprecation (#4949)
- Fix neighbor degree for directed graphs (#4948)
- `descendants_at_distance` also for non-DiGraphs (#4952)
- Changes to rst files to make doctests pass (#4947)
- Fix version pull down (#4954)
- Finalize 2.6 release notes (#4958)
Contributors
------------
- AbhayGoyal
- Suvayu Ali
- Alexandre Amory
- Francesco Andreuzzi
- Salim BELHADDAD
- Ross Barnowski
- Raffaele Basile
- Jeroen Bergmans
- R. Bernstein
- Geoff Boeing
- Kelly Boothby
- Jeff Bradberry
- Erik Brendel
- Justin Cai
- Thomas A Caswell
- Jonas Charfreitag
- Berlin Cho
- ChristopherReinartz
- Jon Crall
- Michael Dorner
- Harshal Dupare
- Andrew Eckart
- Tomohiro Endo
- Douglas Fenstermacher
- Martin Fleischmann
- Martha Frysztacki [frɨʂtat͡skʲ]
- Debargha Ganguly
- CUI Hao
- Floris Hermsen
- Ward Huang
- Elgun Jabrayilzade
- Han Jaeseung
- Mohammed Kashif
- Alex Korbonits
- Mario Kostelac
- Sebastiaan Lokhorst
- Lonnen
- Delille Louis
- Xiaoyan Lu
- Alex Malins
- Oleh Marshev
- Jordan Matelsky
- Fabio Mazza
- Chris McBride
- Abdulelah S. Al Mesfer
- Attila Mester
- Jarrod Millman
- Miroslav Šedivý
- Harsh Mishra
- S Murthy
- Matthias Nagel
- Attila Nagy
- Mehdi Nemati
- Dimitrios Papageorgiou
- Vitaliy Pozdnyakov
- Bharat Raghunathan
- Randy
- Michael Recachinas
- Carlos González Rotger
- Taxo Rubio
- Dan Schult
- Mridul Seth
- Kunal Shah
- Eric Sims
- Ludovic Stephan
- Justin Timmons
- Andrea Tomassilli
- Matthew Treinish
- Milo Trujillo
- Danylo Ulianych
- Alex Walker
- Stefan van der Walt
- Anthony Wilder Wohns
- Levi John Wolf
- Xiangyu Xu
- Shichu Zhu
- alexpsimone
- as1371
- cpurmessur
- dbxnr
- wim glenn
- goncaloasimoes
- happy
- jason-crowley
- jebogaert
- josch
- ldelille
- marcusjcrook
- guy rozenberg
- tom
- walkeralexander
---
### Doc Release Release 2.7.1 (`doc/release/release_2.7.1.rst`)
.. _networkx_2.7.1:
NetworkX 2.7.1
==============
Release date: 5 March 2022
Supports Python 3.8, 3.9, and 3.10
Minor bug fixes.
Merged PRs
----------
A total of 7 changes have been committed.
- Designate 2.7 release
- Bump release version
- Fix release notes
- Change dev version to 2.7.1
- Fix line graph construction for heterogeneous nodes (#5357)
- Fix development banner (#5370)
- Simplify DelayedImportErrorModule (#5371)
- [nx_pylab] fix StopIteration, if empty dict is passed for labels. (#5372)
Contributors
------------
- Jarrod Millman
- Martin K. Scherer
- Stefan van der Walt
- jkudla
---
### Doc Release Release 2.7 (`doc/release/release_2.7.rst`)
.. _networkx_2.7:
NetworkX 2.7
============
Release date: 28 February 2022
Supports Python 3.8, 3.9, and 3.10
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
This release is the result of 7 months of work with over 166 pull requests by
33 contributors. Highlights include:
.. warning::
Hash values observed in outputs of
`~networkx.algorithms.graph_hashing.weisfeiler_lehman_graph_hash`
have changed in version 2.7 due to bug fixes. See gh-4946_ for details.
This means that comparing hashes of the same graph computed with different
versions of NetworkX (i.e. before and after version 2.7)
could wrongly fail an isomorphism test (isomorphic graphs always have matching
Weisfeiler-Lehman hashes). Users are advised to recalculate any stored graph
hashes they may have on upgrading.
.. _gh-4946: https://github.com/networkx/networkx/pull/4946#issuecomment-914623654
- Dropped support for Python 3.7.
- Added the Asadpour algorithm for solving the asymmetric traveling salesman
problem: `~networkx.algorithms.approximation.traveling_salesman.asadpour_atsp`.
- Added the Louvain community detection algorithm:
`~networkx.algorithms.community.louvain.louvain_communities` and
`~networkx.algorithms.community.louvain.louvain_partitions`
- Removed all internal usage of the `numpy.matrix` class, and added a
`FutureWarning` to all functions that return a `numpy.matrix` instance.
The `numpy.matrix` class will be replaced with 2D `numpy.ndarray` instances
in NetworkX 3.0.
- Added support for the `scipy.sparse` array interface. This includes
`~networkx.convert_matrix.to_scipy_sparse_array` and
`~networkx.convert_matrix.from_scipy_sparse_array`. In NetworkX 3.0,
sparse arrays will replace sparse matrices as the primary interface to
`scipy.sparse`. New code should use ``to_scipy_sparse_array`` and
``from_scipy_sparse_array`` instead of their matrix counterparts.
In addition, many functions that currently return sparse matrices now raise
a `FutureWarning` to indicate that they will return sparse arrays instead in
NetworkX 3.0.
- Added generic dtype support to `~networkx.convert_matrix.to_numpy_array`.
This adds support for generic attributes, such as adjacency matrices with
complex weights. This also adds support for generic reduction functions in
handling multigraph weights, such as ``mean`` or ``median``. Finally, this
also includes support for structured dtypes, which enables the creation of
multi-attribute adjacency matrices and replaces the less generic
``to_numpy_recarray``.
- Added support for computing betweenness centrality on multigraphs
- Added support for directed graphs and multigraphs to ``greedy_modularity_communities``.
GSoC PRs
--------
We added the work from four Google Summer of Code projects:
- `Louvain community detection algorithm`_
- Program: Google Summer of Code 2021
- Contributor: `@z3y50n <https://github.com/z3y50n/>`__
- Link to Proposal: `GSoC 2021: Community Detection Algorithms <https://github.com/networkx/archive/blob/main/proposals-gsoc/GSoC-2021-Community-Detection-Algorithms.pdf>`__
- `Asadpour algorithm for directed travelling salesman problem`_
- Program: Google Summer of Code 2021
- Contributor: `@mjschwenne <https://github.com/mjschwenne/>`__
- Link to Proposal: `GSoC 2021: Asadpour algorithm <https://github.com/networkx/archive/blob/main/proposals-gsoc/GSoC-2021-Asadpour-Asymmetric-Traveling%20Salesman-Problem.pdf>`__
- Pedagogical notebook: `Directed acyclic graphs and topological sort`_
- Program: Google Summer of Code 2021
- Contributor: `@vdshk <https://github.com/vdshk>`__
- Pedagogical notebooks: `Graph assortativity`_ & `Network flow analysis and Dinitz algorithm`_
- Program: Google Summer of Code 2021
- Contributor: `@harshal-dupare <https://github.com/harshal-dupare/>`__
.. _`Louvain community detection algorithm`: https://github.com/networkx/networkx/pull/4929
.. _`Asadpour algorithm for directed travelling salesman problem`: https://github.com/networkx/networkx/pull/4740
.. _`Directed acyclic graphs and topological sort`: https://github.com/networkx/nx-guides/pull/44
.. _`Graph assortativity`: https://github.com/networkx/nx-guides/pull/42
.. _`Network flow analysis and Dinitz algorithm`: https://github.com/networkx/nx-guides/pull/46
Improvements
------------
- [`#4740 <https://github.com/networkx/networkx/pull/4740>`_]
Add the Asadpour algorithm for solving the asymmetric traveling salesman
problem.
- [`#4897 <https://github.com/networkx/networkx/pull/4897>`_]
Improve the validation and performance of ``nx.is_matching``,
``nx.is_maximal_matching`` and ``nx.is_perfect_matching``.
- [`#4924 <https://github.com/networkx/networkx/pull/4924>`_]
Fix handling of disconnected graphs when computing
``nx.common_neighbor_centrality``.
- [`#4929 <https://github.com/networkx/networkx/pull/4929>`_]
Add Louvain community detection.
- [`#4946 <https://github.com/networkx/networkx/pull/4946>`_]
Add Weisfeiler-Lehman hashing subgraph hashing.
- [`#4950 <https://github.com/networkx/networkx/pull/4950>`_]
Add an ``n_communities`` parameter to ``greedy_modularity_communities`` to
terminate the search when the desired number of communities is found.
- [`#4965 <https://github.com/networkx/networkx/pull/4965>`_] and
[`#4996 <https://github.com/networkx/networkx/pull/4996>`_]
Fix handling of relabeled nodes in ``greedy_modularity_communities``.
- [`#4976 <https://github.com/networkx/networkx/pull/4976>`_]
Add betweenness centrality for multigraphs.
- [`#4999 <https://github.com/networkx/networkx/pull/4999>`_]
Fix ``degree_assortativity_coefficient`` for directed graphs.
- [`#5007 <https://github.com/networkx/networkx/pull/5007>`_]
Add support for directed graphs and multigraphs to ``greedy_modularity_communities``.
- [`#5017 <https://github.com/networkx/networkx/pull/5017>`_]
Improve implementation and documentation of ``descendants`` and ``ancestors``
- [`#5019 <https://github.com/networkx/networkx/pull/5019>`_]
Improve documentation and testing for directed acyclic graph module.
- [`#5029 <https://github.com/networkx/networkx/pull/5029>`_]
Improve documentation and testing of ``descendants_at_distance``.
- [`#5032 <https://github.com/networkx/networkx/pull/5032>`_]
Improve performance of ``complement_edges``.
- [`#5045 <https://github.com/networkx/networkx/pull/5045>`_]
Add ``geometric_edges`` to the ``nx`` namespace.
- [`#5051 <https://github.com/networkx/networkx/pull/5051>`_]
Add support for comment characters for reading data with ``read_edgelist``.
- [`#5052 <https://github.com/networkx/networkx/pull/5052>`_]
Improve performance and add support for undirected graphs and multigraphs to
``transitive_closure``.
- [`#5058 <https://github.com/networkx/networkx/pull/5058>`_]
Improve exception handling for writing data in GraphML format.
- [`#5065 <https://github.com/networkx/networkx/pull/5065>`_]
Improve support for floating point weights and resolution values in
``greedy_modularity_communities``.
- [`#5077 <https://github.com/networkx/networkx/pull/5077>`_]
Fix edge probability in ``fast_gnp_random_graph`` for directed graphs.
- [`#5086 <https://github.com/networkx/networkx/pull/5086>`_]
Fix defect in ``lowest_common_ancestors``.
- [`#5089 <https://github.com/networkx/networkx/pull/5089>`_]
Add ``find_negative_cycle`` for finding negative cycles in weighted graphs.
- [`#5099 <https://github.com/networkx/networkx/pull/5099>`_]
Improve documentation and testing of binary operators.
- [`#5104 <https://github.com/networkx/networkx/pull/5104>`_]
Add support for self-loop edges and improve performance of ``vertex_cover``.
- [`#5121 <https://github.com/networkx/networkx/pull/5121>`_]
Improve performance of ``*_all`` binary operators.
- [`#5131 <https://github.com/networkx/networkx/pull/5131>`_]
Allow ``edge_style`` to be a list of styles when drawing edges for DiGraphs.
- [`#5139 <https://github.com/networkx/networkx/pull/5139>`_]
Add support for the `scipy.sparse` array interface.
- [`#5144 <https://github.com/networkx/networkx/pull/5144>`_]
Improve readability of ``node_classification`` functions.
- [`#5145 <https://github.com/networkx/networkx/pull/5145>`_]
Adopt `math.hypot` which was added in Python 3.8.
- [`#5153 <https://github.com/networkx/networkx/pull/5153>`_]
Fix ``multipartite_layout`` for graphs with non-numeric nodes.
- [`#5154 <https://github.com/networkx/networkx/pull/5154>`_]
Allow ``arrowsize`` to be a list of arrow sizes for drawing edges.
- [`#5172 <https://github.com/networkx/networkx/pull/5172>`_]
Add a ``nodes`` keyword argument to ``find_cliques`` to add support for
finding maximal cliques containing only a set of nodes.
- [`#5197 <https://github.com/networkx/networkx/pull/5197>`_]
Improve ``resistance_distance`` with advanced indexing.
- [`#5216 <https://github.com/networkx/networkx/pull/5216>`_]
Make ``omega()`` closer to the published algorithm. The value changes slightly.
The ``niter`` parameter default changes from 1->5 in ``lattice_reference()``
and from 100->5 in ``omega``.
- [`#5217 <https://github.com/networkx/networkx/pull/5217>`_]
Improve performance and readability of ``betweenness_centrality``.
- [`#5232 <https://github.com/networkx/networkx/pull/5232>`_]
Add support for `None` edge weights to bidirectional Dijkstra algorithm.
- [`#5247 <https://github.com/networkx/networkx/pull/5247>`_]
Improve performance of asynchronous label propagation algorithm for
community detection, ``asyn_lpa_communities``.
- [`#5250 <https://github.com/networkx/networkx/pull/5250>`_]
Add generic dtype support to ``to_numpy_array``.
- [`#5285 <https://github.com/networkx/networkx/pull/5285>`_]
Improve ``karate_club_graph`` by updating to the weighted version from the original
publication.
- [`#5287 <https://github.com/networkx/networkx/pull/5287>`_]
Improve input validation for ``json_graph``.
- [`#5288 <https://github.com/networkx/networkx/pull/5288>`_]
Improve performance of ``strongly_connected_components``.
- [`#5324 <https://github.com/networkx/networkx/pull/5324>`_]
Add support for structured dtypes to ``to_numpy_array``.
- [`#5336 <https://github.com/networkx/networkx/pull/5336>`_]
Add support for the `numpy.random.Generator` interface for random number
generation.
API Changes
-----------
- The values in the dictionary returned by
`~networkx.drawing.layout.rescale_layout_dict` are now `numpy.ndarray` objects
instead of tuples. This makes the return type of ``rescale_layout_dict``
consistent with that of all of the other layout functions.
- A ``FutureWarning`` has been added to ``google_matrix`` to indicate that the
return type will change from a ``numpy.matrix`` object to a ``numpy.ndarray``
in NetworkX 3.0.
- A ``FutureWarning`` has been added to ``attr_matrix`` to indicate that the
return type will change from a ``numpy.matrix`` object to a ``numpy.ndarray``
object in NetworkX 3.0.
- The ``is_*_matching`` functions now raise exceptions for nodes not in G in
any edge.
Deprecations
------------
- [`#5055 <https://github.com/networkx/networkx/pull/5055>`_]
Deprecate the ``random_state`` alias in favor of ``np_random_state``
- [`#5114 <https://github.com/networkx/networkx/pull/5114>`_]
Deprecate the ``name`` kwarg from ``union`` as it isn't used.
- [`#5143 <https://github.com/networkx/networkx/pull/5143>`_]
Deprecate ``euclidean`` in favor of ``math.dist``.
- [`#5166 <https://github.com/networkx/networkx/pull/5166>`_]
Deprecate the ``hmn`` and ``lgc`` modules in ``node_classification``.
- [`#5262 <https://github.com/networkx/networkx/pull/5262>`_]
Deprecate ``to_scipy_sparse_matrix`` and ``from_scipy_sparse_matrix`` in
favor of ``to_scipy_sparse_array`` and ``from_scipy_sparse_array``, respectively.
- [`#5283 <https://github.com/networkx/networkx/pull/5283>`_]
Deprecate ``make_small_graph`` and ``make_small_undirected_graph`` from the
``networkx.generators.small`` module.
- [`#5330 <https://github.com/networkx/networkx/pull/5330>`_]
Deprecate ``to_numpy_recarray`` in favor of ``to_numpy_array`` with a
structured dtype.
- [`#5341 <https://github.com/networkx/networkx/pull/5341>`_]
Deprecate redundant ``info``.
Merged PRs
----------
A total of 166 changes have been committed.
- Support `comments=None` in read/parse edgelist (#5051)
- Add see also refs to de/stringizers in gml docstrings. (#5053)
- Add weisfeiler lehman subgraph hashing (#4946)
- Deprecate `random_state` decorator (#5055)
- Bug fix for issue #5023 : corner-case bug in single_source_dijkstra (#5033)
- More informative GraphML exceptions (#5058)
- Minor updates to tutorial.rst and add docstring for data method of nodes/edges (#5039)
- Document `geometric_edges` and add it to main namespace (#5045)
- Fix small typo in `trophic_levels` documentation (#5087)
- Refactor `transitive_closure` (#5052)
- Fix fast_gnp_random_graph for directed graphs (issue #3389) (#5077)
- Get number of edges by calling the proper method (#5095)
- Update mentored projects section in docs (#5056)
- Parametrize shortest path node-checking tests. (#5078)
- Create FUNDING.yml
- Deprecate union name param (#5114)
- Update FUNDING.yml
- vertex_cover: Added support for self-loop nodes (#5104)
- Update core dev team (#5119)
- Faster operators in algorithms/operators/all.py (#5121)
- DOC: Add links to proposals for completed projects (#5122)
- Consistent return type in dictionary output of rescale_layout and rescale_layout_dict (#5091)
- Change exception varname e to err (#5130)
- minor tweaks in assortativity docs and code (#5129)
- Allow edge style to be a list of styles for DiGraphs (#5131)
- Add examples and minor documentation refactor for operators/binary.py (#5099)
- Improve random graphs test suite for gnp generators (issue #5092) (#5115)
- Add note about checking for path existence to all_simple_paths. (#5059)
- Fix message of raised exception in decorators. (#5136)
- Refactor linestyle test for FancyArrowPatches. (#5132)
- Drop Py37 (#5143)
- Use math.hypot (#5145)
- Add pyupgrade to pre-commit (#5146)
- Test on Python 3.10 (#4807)
- Use black 21.9b0 (#5148)
- Use sphinx 4.2 (#5150)
- Update example requirements (#5151)
- Update nx_pylab drawing edge color and width tests (#5134)
- Refactor node_classification to improve conciseness and readability (#5144)
- Add temporary pyparsing pin to fix CI. (#5156)
- Add option for arrowsize to be a list (#5154)
- List policies (#5159)
- Bugfix for issue 5123 (#5153)
- Test scipy and pandas on py3.10 (#5174)
- Deprecate `hmn` and `lgc` modules from the `node_classification` package (#5166)
- Rm passing ax.transOffset to LineCollection. (#5173)
- Add a function to find the negative cycle using bellman_ford (#5089)
- Add a Q&A to the contributor FAQ about algorithm acceptance policy. (#5177)
- DOC: Fix typo in docs for weighted shortest paths (#5181)
- Revert "Add temporary pyparsing pin to fix CI. (#5156)" (#5180)
- Only compute shortest path lengths when used (#5183)
- Add Mypy type checking infrastructure (#5127)
- xfail pydot tests. (#5187)
- Remove unused internal solver from algebraicconnectivity (#5190)
- Remove check/comment for scipy 1.1 behavior. (#5191)
- Test on Python 3.10 (#5185)
- Add regression test for ancestors/descendants w/ undir. G. (#5188)
- Rm internal function, use advanced indexing instead. (#5197)
- Fix missing import + tests in laplacian fns. (#5194)
- Investigate pre-release test failures (#5208)
- Rm assertion method in favor of assert statements. (#5214)
- Remove unused variable in mycielski.py (#5210)
- used queue instead of ordinary list (#5217)
- Add FutureWarning about matrix->array output to `google_matrix` (#5219)
- A few `np.matrix` cleanups (#5218)
- Rm internal laplacian in favor of laplacian_matrix. (#5196)
- [MRG] Create plot_subgraphs.py example (#5165)
- Add traveling salesman problem to example gallery (#4874)
- Fixed inconsistent documentation for nbunch parameter in DiGraph.edges() (#5037)
- Compatibility updates from testing with numpy/scipy/pytest rc's (#5226)
- Replace internal `close` fn with `math.isclose`. (#5224)
- Fix Python 3.10 deprecation warning w/ int div. (#5231)
- Touchups and suggestions for subgraph gallery example (#5225)
- Use new package name (#5234)
- Allowing None edges in weight function of bidirectional Dijkstra (#5232)
- Add an FAQ about assigning issues. (#5182)
- Update dev deps (#5243)
- Update minor doc issues with tex notation (#5244)
- Minor changes to speed up asynchronous label propagation for community detection. (#5247)
- Docstrings for the small.py module (#5240)
- Use scipy.sparse array datastructure (#5139)
- Update sphinx (#5272)
- Update year (#5273)
- Update extra dependencies (#5263)
- Update gexf website link in documentation (#5275)
- Update numpydoc (#5274)
- Initial setup of lazy_import functions. (#4909)
- Deprecate scipy sparse matrix conversion functions (#5262)
- Fix lowest_common_ancestors (issue #4942) (#5086)
- Make small graph generator node test more specific. (#5282)
- Use from_dict_of_lists instead of make_small_graph in generators.small (#5267)
- Refactor `to_numpy_array` with advanced indexing (#5250)
- Fix: Update louvain_partitions for threshold (update mod to new_mod in each level) (#5284)
- Add exception for unconnected graph (#5287)
- Fixing Tarjan's strongly connected components algorithm implementation to have `O(|E|+|V|)` time complexity instead of `O(|V|^3)`. (#5288)
- Add weights to karate club graph (#5285)
- Fix functions appearing in variables `__all__` but not in docs for NX2.7 (#5289)
- Update to stable version of black (#5296)
- Add FutureWarning to `attr_matrix` to notify users of return type change (#5300)
- DOC: change status to accepted for NXEP2, add resolution (#5297)
- Update test requirements (#5304)
- Update scipy (#5276)
- DOC: Update documentation to include callables for weight argument (#5307)
- Update pygraphviz (#5314)
- Document default dtype in to_numpy_recarray docstring. (#5315)
- Rm unused AbstractSet. (#5317)
- Deprecate `make_small_graph` and `make_small_undirected_graph` (#5283)
- Update `draw_<layout>` docstrings with usage examples (#5264)
- More numpy.matrix cleanups for NX2.7 (#5319)
- MAINT: Cleanup assortativity module, remove unused variables (#5301)
- Add informative exception for drawing multiedge labels. (#5316)
- Potential resolution to full paths to functions in docs (#5049)
- MAINT: Cleanup link analysis module, remove unused variables (#5306)
- Use pytest-mpl (#4579)
- Keep omega within [-1, 1] bounds (#5216)
- Add support for finding maximal cliques containing a set of nodes (#5172)
- MAINT: Remove unnecessary helper functions, use inbuilt methods for line graph generator (#5327)
- sampling from dict_keys objects is deprecated. (#5337)
- Add support for `numpy.random.Generator` (#5336)
- Update matching functions for error validation and speed (#4897)
- Update release requirements (#5338)
- Add structured dtypes to `to_numpy_array` (#5324)
- Deprecate `to_numpy_recarray` (#5330)
- First pass at 2.7 release notes. (#5342)
- Add pickle and yaml migration info (#5345)
- Deprecate info (#5341)
- Fix pandas warning (#5346)
- Test on 3.11-dev (#5339)
- Designate 2.7rc1 release
- Bump release version
- Update release process (#5348)
- Update mentored project info with the expected time commitment (#5349)
- Use np.random.default_rng in example + other updates. (#5356)
- Remove stuff conda doesn't support (#5361)
- Fix spiral_layout when equidistant=True (#5354)
- Fix docs (#5364)
Contributors
------------
- Will Badart
- Ross Barnowski
- Mathieu Bastian
- Martin Becker
- Anutosh Bhat
- Alejandro Candioti
- Divyansh
- Andrew Eckart
- Yossi Eliaz
- Casper van Elteren
- Simone Gasperini
- Daniel Haden
- Leo Klarner
- Andrew Knyazev
- Fabrizio Kuruc
- Paarth Madan
- Jarrod Millman
- Achille Nazaret
- NikHoh
- Sultan Orazbayev
- Dimitrios Papageorgiou
- Aishwarya Ramasethu
- Ryuki
- Katalin Schmidt
- Dan Schult
- Mridul Seth
- Cirus Thenter
- James Trimble
- Vadim
- Hnatiuk Vladyslav
- Aaron Z
- eskountis
- kpberry
---
### Doc Release Release 2.8.1 (`doc/release/release_2.8.1.rst`)
NetworkX 2.8.1
==============
Release date: 18 May 2022
Supports Python 3.8, 3.9, and 3.10
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
Minor documentation and bug fixes.
Improvements
------------
- Changed the treatment of directed graphs for `has_eulerian_path` which
used to allow graphs with isolated nodes, i.e. nodes with zero degree to have
an eulerian path. For undirected graphs, on the other hand, `has_eulerian_path`
does not allow isolated nodes. For example:
>>> G = nx.DiGraph([(0, 1), (1, 2), (2, 0)])
>>> G.add_node(3)
>>> nx.has_eulerian_path(G)
The above snippet used to produce `True` whereas the below one used to produce `False`.
>>> G = nx.Graph([(0, 1), (1, 2), (2, 0)])
>>> G.add_node(3)
>>> nx.has_eulerian_path(G)
The change makes the method consistent for both undirected and directed graph types so
that it does not allow isolated nodes. (Both examples produce `False` now.)
- `is_bipartite_node_set` now raises an exception when the tested nodes are
not distinct (previously this would not affect the outcome).
This is to avoid surprising behaviour when using node sets in other bipartite
algorithms, for example it yields incorrect results for `weighted_projected_graph`.
Merged PRs
----------
A total of 52 changes have been committed.
- Fix release notes
- Bump release version
- Change default value of arrowstyle for undirected graphs (#5514)
- added edge labels in weighted graph (#5521)
- Added examples in is_forest() and is_tree() (#5524)
- a hack to force self edges to be ignored on the first node inspected (#5516)
- De-Regression: eagerly evaluate not_implemented_for in decorated generators (#5537)
- Improve documentation of PlanarEmbedding class (#5523)
- PlanarEmbedding in autosummary instead of autoclass. (#5548)
- Added examples in tournament and tree functions (#5536)
- Fixup PlanarEmbedding See Also (#5556)
- Fix min_edge_cover in special cases (#5538) and correct documentation (#5549)
- Add is_planar function. Solves issue #5109 (#5544)
- Improve bridges documentation (#5519)
- fix greedy_modularity when multiple components exist. (#5550)
- Fix issue probably-meant-fstring found at https://codereview.doctor (#5574)
- MAINT: Fix sphinx build errors and warnings (#5571)
- replace induced_subgraph example with directly relevant example (#5576)
- Add examples to compose operation (#5583)
- Fix reference in label_propagation_communities docstring (#5588)
- Use sets instead of lists for collecting flowfuncs in tests. (#5589)
- Update .degree() docs: outdated return type (#5529)
- Update numpydoc (#5580)
- Add a space in an error (#5601)
- improve docstring for read_doc, see issue #5604 (#5605)
- Cache `nodes` property on Graph (#5600)
- Fixes #5403: Errors on non-distinct bipartite node sets (#5442)
- Added documentation for branching_weight() solving issue #5553 (#5558)
- Distance measures example (#5608)
- Corrected the documentation of find_negative_cycle() solving issue #5610 (#5613)
- Added examples in connected and strongly connected functions (#5559)
- Update GH actions (#5622)
- Remove `_mat_spect_approx` in favor of simpler procedure (#5624)
- Replace np.flip with indexing in layouts. (#5623)
- Cache edges, degree, adj properties of Graph classes (#5614)
- Disallow isolated nodes for Eulerian Path (#5616)
- Fix triadic census (#5575)
- Adjust the usage of nodes_or_number decorator (#5599)
- Use new ubuntu LTS release (#5630)
- Build docs with Py 3.9 (#5632)
- added example on moral graph (#5633)
- Added examples in weakly_connected.py (#5593)
- Designate 2.8.1rc1 release
- Bump release version
- Rm unnecessary input validation from moral_graph. (#5638)
- DOC: fix up links, remove references to directed graphs, add proper cites (#5635)
- Added example under unary operators (#5625)
- Added docstring examples to matching functions (#5617)
- doc: fix typos in docstring and comment (#5647)
- DOC: remove note re: nonexistent param (#5648)
- added examples to covering.py (#5646)
- added examples on chain decomposition (#5641)
- Fix typo (#5652)
Contributors
------------
- William Allen
- Ross Barnowski
- Kelly Boothby
- Brit
- Guillem Francès
- Brian A. Heckman
- Horst JENS
- Lukong123
- Jarrod Millman
- Omkaar
- Dan Schult
- Mridul Seth
- Nikita Sharma
- Tatsuya Shimoda
- Dilara Tekinoglu
- Stefan van der Walt
- Aaron Z
- code-review-doctor
- danielolsen
- sheldonkhall
---
### Doc Release Release 2.8.2 (`doc/release/release_2.8.2.rst`)
NetworkX 2.8.2
==============
Release date: 21 May 2022
Supports Python 3.8, 3.9, and 3.10.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
Minor documentation and bug fixes.
Merged PRs
----------
- Fix doc deploy
- Bump release version
- MAINT: Update dfs_test with more comprehensive tests (#5654)
- Bump release version
- Fix __setstate__ for OutEdgeView subclasses, read _adjdict from state (#5657)
- Add examples & improve documentation of voterank (#5500)
Contributors
------------
- Jarrod Millman
- Mridul Seth
- Dilara Tekinoglu
---
### Doc Release Release 2.8.3 (`doc/release/release_2.8.3.rst`)
NetworkX 2.8.3
==============
Release date: 4 June 2022
Supports Python 3.8, 3.9, and 3.10.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
Minor documentation and bug fixes.
Merged PRs
----------
- Bump release version
- Update release process
- added example to closeness.py (#5645)
- Extract valid kwds from the function signature for draw_networkx_* (#5660)
- Error out when pydot fails to correctly parse node names (#5667)
- Remove redundant py2 numeric conversions (#5661)
- Correcting a typo in the references (#5677)
- Add workaround for pytest failures on 3.11-beta2 (#5680)
- Moved random_spanning_tree to public API (#5656)
- More tests for clustering (upstreaming from graphblas-algorithms) (#5673)
- Remove unused logic in nonisomorphic_trees (#5682)
- equitable_coloring: Get lazily first item instead of creating whole list (#5668)
- Update subgraph views tests to pass with out of order execution (#5683)
- Use isort with pre-commit to enforce import guidelines (#5659)
- ignore isort commit from git blame (#5684)
- Another catch by pytest-randomly (#5685)
- Remove unused file from utils.test (#5687)
- Update release requirements (#5690)
- Update developer requirements (#5689)
- Fix old release notes
Contributors
------------
- Ross Barnowski
- Jon Crall
- Lukong123
- Jarrod Millman
- RATCOinc
- Matt Schwennesen
- Mridul Seth
- Matus Valo
- Erik Welch
---
### Doc Release Release 2.8.4 (`doc/release/release_2.8.4.rst`)
NetworkX 2.8.4
==============
Release date: 13 June 2022
Supports Python 3.8, 3.9, and 3.10.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
Minor documentation and bug fixes.
Merged PRs
----------
- Bump release version
- Clean up maximal_independent_set tests (#5567)
- MAINT: Cleanup centrality module, remove unused variables (#5308)
- importorskip scipy instead of numpy for total spanning tree (#5693)
- Add initial_graph parameter to scale_free_graph and deprecate create_using (#5697)
- Add docstring example for attr transfer to linegraph. (#5698)
- Update ISMAGS.analyze_symmetry docstring. (#5696)
- Add default value p=2 for minkowski distance metric. (#5700)
- Update inline code to inline math in docstring (#5701)
- Update multigraph docstrings to reflect `remove_edges_from` behavior. (#5699)
- Update simple_cycles docstring w/ yields and examples (#5709)
- Chromatic polynomial (#5675)
- Catch ':' explicitly while working with pydot (#5710)
- Revert "Add workaround for pytest failures on 3.11b2" (#5717)
- Default to lightmode for documentation (#5715)
- Dont compute all biconnected components in `is_biconnected()` (#5688)
- Some more changes to make pytest-randomly happy (#5719)
- Add durations flag to coverage run on CI. (#5718)
- Recover order of layers in multipartite_layout when layers are sortable (#5705)
- Update doc requirements (#5711)
- Touchups to MG and MDG edges docstrings. (#5708)
- Add PendingDeprecation for pydot (#5721)
- Add example of topo_order kwarg to dag_longest_path (#5728)
- CI: add pytest-randomly workflow. (#4553)
Contributors
------------
- Ross Barnowski
- Szabolcs Horvát
- Lucas H. McCabe
- Jarrod Millman
- Mridul Seth
- Matus Valo
---
### Doc Release Release 2.8.5 (`doc/release/release_2.8.5.rst`)
NetworkX 2.8.5
==============
Release date: 18 July 2022
Supports Python 3.8, 3.9, and 3.10.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
Minor documentation and bug fixes.
Merged PRs
----------
- Bump release version
- Check that nodes have "pos" attribute in geometric_edges (#5707)
- Correct louvain formula, solve infinite loops (#5713)
- Add more comprehensive tests for pydot (#5792)
- Compute `is_strongly_connected` lazily (#5793)
- Compute `is_weakly_connected` lazily (#5795)
- Updated astar docstring (#5797)
- Fix typo in bipartite closeness_centrality and thought-o in tests (#5800)
- Fix pydot colon check node-to-str conversion (#5809)
- Temporary fix for failing tests w/ scipy1.9. (#5816)
- Update distance parameter description. (#5819)
- Fix #5817 (#5822)
- Attempt to reverse slowdown from hasattr needed for cached_property (#5836)
- Update tests in base class and simple rename in convert.py (#5848)
- Move factory attributes to the class instead of instance. (#5850)
- Point to the latest URL for the description. (#5852)
- Gallery example: Morse code alphabet as a prefix tree (#5867)
- make lazy_import private and remove its internal use (#5878)
- Run CI against v2.8 branch
- CI: add explicit path while installing pygraphviz wheels on macOS in GHA (#5805)
- Deploy docs on v2.8 branch
Contributors
------------
- Ross Barnowski
- Shaked Brody
- Lior
- Jarrod Millman
- Tomoya Nishide
- Dimitrios Papageorgiou
- Dan Schult
- Matt Schwennesen
- Mridul Seth
- Matus Valo
---
### Doc Release Release 2.8.6 (`doc/release/release_2.8.6.rst`)
NetworkX 2.8.6
==============
Release date: 22 August 2022
Supports Python 3.8, 3.9, and 3.10.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
Minor documentation and bug fixes.
Merged PRs
----------
- Add random_spanning_tree to documentation (#5810)
- DOC: Switch to enumerated list in quotient_graph docstring (#5837)
- Add warning to nx_agraph about layout nondeterminism. (#5832)
- Update docs to include description of the `return_seen` kwarg (#5891)
- Add cache reset for when G._node is changed (#5894)
- Allow classes to relabel nodes -- casting (#5903)
- Update lattice.py (#5914)
- Add to about_us.rst (#5919)
- Update precommit hooks (#5923)
- Remove old Appveyor cruft (#5924)
- signature change for `node_link` functions: for issue #5787 (#5899)
- Allow unsortable nodes in approximation.treewidth functions (#5921)
- Fix Louvain_partitions by yielding a copy of the sets in the partition gh-5901 (#5902)
- Adds ```nx.bfs_layers``` method (#5879)
- Add function bfs_layers to docs (#5932)
- Propose to make new node_link arguments keyword only. (#5928)
- Bump nodelink args deprecation expiration to v3.2 (#5933)
- Add examples to lowest common ancestors algorithms (#5531)
- Naive lowest common ancestor implementation (#5736)
- Add examples for the condensation function (#5452)
- Minor doc fixups (#5868)
- update all_pairs_lca docstrings (#5876)
- Improve LCA input validation (#5877)
- Replace LCA with naive implementations (#5883)
- Update release notes
- docstring update to lexicographical_topological_sort issue 5681 (#5930)
- Support matplotlib 3.6rc1 failure (#5937)
Improvements
------------
- [`#5883 <https://github.com/networkx/networkx/pull/5883>`_]
Replace the implementation of ``lowest_common_ancestor`` and
``all_pairs_lowest_common_ancestor`` with a "naive" algorithm to fix
several bugs and improve performance.
Contributors
------------
- Tanmay Aeron
- Ross Barnowski
- Kevin Brown
- Matthias Bussonnier
- Tigran Khachatryan
- Dhaval Kumar
- Jarrod Millman
- Sultan Orazbayev
- Dan Schult
- Matt Schwennesen
- Dilara Tekinoglu
- kpetridis
---
### Doc Release Release 2.8.7 (`doc/release/release_2.8.7.rst`)
NetworkX 2.8.7
==============
Release date: 1 October 2022
Supports Python 3.8, 3.9, and 3.10.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
Minor documentation and bug fixes.
Merged PRs
----------
- Bump release version
- Fixed unused root argument in has_bridges (#5846)
- docstring updates for `union`, `disjoint_union`, and `compose` (#5892)
- Updated networkx/classes/function.py . Solves Issue #5463 (#5474)
- Improved documentation for all_simple_paths (#5944)
- Change is_path to return False when node not in G instead of raising exception (#5943)
- Minor docstring touchups and test refactor for `is_path` (#5967)
- Update documentation header links for latest pydata-sphinx-theme (#5966)
- Fix failing example due to mpl 3.6 colorbar. (#5994)
- Add Tidelift security vulnerability link (#6001)
- Update linters (#6006)
Improvements
------------
- [`#5943 <https://github.com/networkx/networkx/pull/5943>`_]
``is_path`` used to raise a `KeyError` when the ``path`` argument contained
a node that was not in the Graph. The behavior has been updated so that
``is_path`` returns `False` in this case rather than raising the exception.
Contributors
------------
- Juanita Gomez
- Kevin Brown
- 0ddoes
- pmlpm1986
- Dan Schult
- Jarrod Millman
---
### Doc Release Release 2.8.8 (`doc/release/release_2.8.8.rst`)
NetworkX 2.8.8
==============
Release date: 1 November 2022
Supports Python 3.8, 3.9, 3.10, and 3.11.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
Minor documentation and bug fixes.
Merged PRs
----------
- Bump release version
- Fix warnings from running tests in randomized order (#6014)
- Update pydata-sphinx-theme (#6012)
- update security link to tidelift (#6019)
- Update numpydoc (#6022)
- Support Python 3.11 (#6023)
- Update linters (#6024)
- Minor updates to expanders generator tests (#6027)
- Add missing asserts to tests (#6039)
- fixes #6036 (#6080)
- Improve test coverage expanders line graph generators solved (PR for issue #6034) (#6071)
- Replace .A call with .toarray for sparse array in example. (#6106)
- Improve test coverage for algorithms/richclub.py (#6089)
- Tested boykov_kolmogorov and dinitz with cutoff (#6104)
- Improve test coverage for multigraph class (#6101)
- Improve test coverage for algorithms in dominating_set.py (PR for issue 6032) (#6068)
- Improve test coverage for graph class (#6105)
- added coverage in generators/tree.py (#6082)
- DOC: Specifically branch off main, instead of current branch (#6127)
- Improve test coverage for multidigraph class (#6131)
- Improve test coverage for digraph class (#6130)
- Improve test coverage for algorithms in dispersion.py (#6100)
- Test on Python 3.11 (#6159)
- Improve test coverage in algorithms shortest paths unweighted.py (#6121)
- Increased test coverage algorithms/matching.py (#6095)
- Renamed test functions in test_lowest_common_ancestors (#6110)
- Increase covering coverage (#6099)
- Add example for fiedler_vector (#6155)
- Improve test coverage for cycles.py (#6152)
- Added an example in all_pairs_node_connectivity (#6126)
- Amount of nodes and edges have mistakes when reading adjlist file (#6132)
- Update pytest (#6165)
Contributors
------------
- Ross Barnowski
- Paula Pérez Bianchi
- DiamondJoseph
- Jarrod Millman
- Mjh9122
- Alimi Qudirah
- Okite chimaobi Samuel
- Jefter Santiago
- Dan Schult
- Mridul Seth
- Tindi Sommers
---
### Doc Release Release 2.8 (`doc/release/release_2.8.rst`)
NetworkX 2.8
============
Release date: 9 April 2022
Supports Python 3.8, 3.9, and 3.10
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
This release is the result of over five weeks of work with 48 pull requests by
18 contributors. This is the last release before NetworkX 3.0. For a preview of the
upcoming 3.0 release, please see the draft of our
`migration guide <https://networkx.org/documentation/latest/release/migration_guide_from_2.x_to_3.0.html>`_
for people moving from 2.X to 3.0.
Improvements
------------
- Correction to the treatment of directed graphs for `average_neighbor_degree`
which used to sum the degrees of outgoing neighbors only but then divide by
the number of "in" or "out" or "in+out" neighbors. So it wasn't even an average.
The correction makes it an average degree of whatever population of neighbors
is specified by `source` = "in" or "out" or "in+out".
For example:
>>> G = nx.path_graph(3, create_using=nx.DiGraph)
>>> print(nx.average_neighbor_degree(G, source="in", target="in"))
{0: 0.0, 1: 1.0, 2: 1.0}
This used to produce `{0: 0.0, 1: 1.0, 2: 0.0}`
Note: node 0 and 2 were treated nonsensically.
Node 0 had calculated value 1/0 which was converted to 0.
(numerator looking at successors while denominator counting predecessors)
Node 2 had caluated value 0/1 = 0.0 (again succs on top, but preds in bottom)
Now node 0 has calculated value 0.0/0 which we treat as 0.0. And node 2 has
calculated value 1/1 = 1.0. Both handle the same nbrhood on top and bottom.
API Changes
-----------
- [`#5394 <https://github.com/networkx/networkx/pull/5394>`_]
The function ``min_weight_matching`` no longer acts upon the parameter ``maxcardinality``
because setting it to False would result in the min_weight_matching being no edges
at all. The only reasonable option is True. The parameter will be removed completely in v3.0.
Deprecations
------------
- [`#5227 <https://github.com/networkx/networkx/pull/5227>`_]
Deprecate the ``n_communities`` parameter name in ``greedy_modularity_communities``
in favor of ``cutoff``.
- [`#5422 <https://github.com/networkx/networkx/pull/5422>`_]
Deprecate ``extrema_bounding``. Use the related distance measures with
``usebounds=True`` instead.
- [`#5427 <https://github.com/networkx/networkx/pull/5427>`_]
Deprecate ``dict_to_numpy_array1`` and ``dict_to_numpy_array2`` in favor of
``dict_to_numpy_array``, which handles both.
- [`#5428 <https://github.com/networkx/networkx/pull/5428>`_]
Deprecate ``utils.misc.to_tuple``.
Merged PRs
----------
- Fix docs
- Fix release notes
- Bump release version
- Fix missing backticks (#5381)
- Add Generator support to create_py_random_state. (#5380)
- modularity_max: introduce enforce_n_communities parameter (#5227)
- First draft. (#5359)
- Updated MultiDiGraph documentation to include more examples of actually (#5387)
- Multigraph docs update (#5389)
- Updates to greedy_modularity_communities docs (#5390)
- Finish up NXEP 4 first draft (#5391)
- Correct typo in docstring (int -> float) (#5398)
- DOC: examples code blacks needs a blank line (#5401)
- Add support for multigraphs to nx.bridges. (#5397)
- Update extrema bounding method for compute="eccentricities" parameter (#5409)
- Add Tutte polynomial (#5265)
- Update sparse6 urls to use https (#5424)
- Deprecate extrema bounding (#5422)
- Add NXEP4 to developer toctree and fix broken links (#5420)
- Rm _inherit_doc - default behavior as of Python 3.5. (#5416)
- Minor improvements from general code readthrough (#5414)
- Ignore formatting changes with black, pep8 for git blame (#5405)
- Deprecate dict to numpy helpers (#5427)
- Deprecate `to_tuple` (#5430)
- Fix average_neighbor_degree calculations for directed graph (#5404)
- Parametrize tutte polynomial tests (#5431)
- Update black (#5438)
- Ignore black formatting (#5440)
- Update sphinx (#5439)
- Use https links for conference.scipy.org (#5441)
- Don't use graph6 with directed graphs (#5443) (#5444)
- Fix min_weight_matching to convert edge weights without reciprocal (#5394)
- Make sympy extra dep (#5454)
- Optimize prim for mst (#5455)
- Adding more examples for to_numpy_array method's usage (#5451)
- MAINT: Prim MST test didn't pass algorithm name to all unit tests (#5457)
- Fixed wrong dict factory usage on MultiDiGraph (#5456)
- added extra condition for fancy arrow colors (#5407)
- Update dependencies (#5468)
- Update release notes
- Designate 2.8rc1 release
- Bump release version
- DOCS: add some guidelines for references (#5476)
- Fix for issue 5212 (#5471)
- shortest_path() example (#5491)
- Rm incorrect reference from spiral_layout docstring. (#5503)
- Improve docstring for bethe_hessian_matrix (#5458)
- Add notes about NumPy/SciPy integration to NX 2->3 migration guide (#5505)
- Run black on docs (#5513)
Contributors
------------
- Ross Barnowski
- Riccardo Bucco
- Matthias Bussonnier
- FabianBall
- Martha Frysztacki
- Chris Keefe
- Lukong123
- Peter Mawhorter
- Lucas H. McCabe
- Jarrod Millman
- Sultan Orazbayev
- Dan Schult
- Seon82
- Mridul Seth
- Nikita Sharma
- Dilara Tekinoglu
- blokhinnv
- yusuf-csdev
---
### Doc Release Release 3.0 (`doc/release/release_3.0.rst`)
NetworkX 3.0
============
Release date: 7 January 2023
Supports Python 3.8, 3.9, 3.10, and 3.11.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
This release is the result of 8 months of work with over 180 changes by
41 contributors. We also have a `guide for people moving from NetworkX 2.X
to NetworkX 3.0 <https://networkx.org/documentation/latest/release/migration_guide_from_2.x_to_3.0.html>`_. Highlights include:
- Better syncing between G._succ and G._adj for directed G.
And slightly better speed from all the core adjacency data structures.
G.adj is now a cached_property while still having the cache reset when
G._adj is set to a new dict (which doesn't happen very often).
Note: We have always assumed that G._succ and G._adj point to the same
object. But we did not enforce it well. If you have somehow worked
around our attempts and are relying on these private attributes being
allowed to be different from each other due to loopholes in our previous
code, you will have to look for other loopholes in our new code
(or subclass DiGraph to explicitly allow this).
- If your code sets G._succ or G._adj to new dictionary-like objects, you no longer
have to set them both. Setting either will ensure the other is set as well.
And the cached_properties G.adj and G.succ will be rest accordingly too.
- If you use the presence of the attribute `_adj` as a criteria for the object
being a Graph instance, that code may need updating. The graph classes
themselves now have an attribute `_adj`. So, it is possible that whatever you
are checking might be a class rather than an instance. We suggest you check
for attribute `_adj` to verify it is like a NetworkX graph object or type and
then `type(obj) is type` to check if it is a class.
- We have added an `experimental plugin feature <https://github.com/networkx/networkx/pull/6000>`_,
which let users choose alternate backends like GraphBLAS, CuGraph for computation. This is an
opt-in feature and may change in future releases.
- Improved integration with the general `Scientific Python ecosystem <https://networkx.org/documentation/latest/release/migration_guide_from_2.x_to_3.0.html#improved-integration-with-scientific-python>`_.
- New drawing feature (module and tests) from NetworkX graphs to the TikZ library of TeX/LaTeX.
The basic interface is ``nx.to_latex(G, pos, **options)`` to construct a string of latex code or
``nx.write_latex(G, filename, as_document=True, **options)`` to write the string to a file.
- Added an improved subgraph isomorphism algorithm called VF2++.
Improvements
------------
- [`#5663 <https://github.com/networkx/networkx/pull/5663>`_]
Implements edge swapping for directed graphs.
- [`#5883 <https://github.com/networkx/networkx/pull/5883>`_]
Replace the implementation of ``lowest_common_ancestor`` and
``all_pairs_lowest_common_ancestor`` with a "naive" algorithm to fix
several bugs and improve performance.
- [`#5912 <https://github.com/networkx/networkx/pull/5912>`_]
The ``mapping`` argument of the ``relabel_nodes`` function can be either a
mapping or a function that creates a mapping. ``relabel_nodes`` first checks
whether the ``mapping`` is callable - if so, then it is used as a function.
This fixes a bug related for ``mapping=str`` and may change the behavior for
other ``mapping`` arguments that implement both ``__getitem__`` and
``__call__``.
- [`#5898 <https://github.com/networkx/networkx/pull/5898>`_]
Implements computing and checking for minimal d-separators between two nodes.
Also adds functionality to DAGs for computing v-structures.
- [`#5943 <https://github.com/networkx/networkx/pull/5943>`_]
``is_path`` used to raise a `KeyError` when the ``path`` argument contained
a node that was not in the Graph. The behavior has been updated so that
``is_path`` returns `False` in this case rather than raising the exception.
- [`#6003 <https://github.com/networkx/networkx/pull/6003>`_]
``avg_shortest_path_length`` now raises an exception if the provided
graph is directed but not strongly connected. The previous test (weak
connecting) was wrong; in that case, the returned value was nonsensical.
API Changes
-----------
- [`#5813 <https://github.com/networkx/networkx/pull/5813>`_]
OrderedGraph and other Ordered classes are replaced by Graph because
Python dicts (and thus networkx graphs) now maintain order.
- [`#5899 <https://github.com/networkx/networkx/pull/5899>`_]
The `attrs` keyword argument will be replaced with keyword only arguments
`source`, `target`, `name`, `key` and `link` for `json_graph/node_link` functions.
Deprecations
------------
- [`#5723 <https://github.com/networkx/networkx/issues/5723>`_]
``nx.nx_pydot.*`` will be deprecated in the future if pydot isn't being
actively maintained. Users are recommended to use pygraphviz instead.
- [`#5899 <https://github.com/networkx/networkx/pull/5899>`_]
The `attrs` keyword argument will be replaced with keyword only arguments
`source`, `target`, `name`, `key` and `link` for `json_graph/node_link` functions.
Merged PRs
----------
- Bump release version
- Add characteristic polynomial example to polynomials docs (#5730)
- Remove deprecated function is_string_like (#5738)
- Remove deprecated function make_str (#5739)
- Remove unused 'name' parameter from `union` (#5741)
- Remove deprecated function is_iterator (#5740)
- Remove deprecated `euclidean` from geometric.py (#5744)
- Remove deprecated function utils.consume (#5745)
- Rm `to_numpy_recarray` (#5737)
- Remove deprecated function utils.empty_generator (#5748)
- Rm jit.py (#5751)
- Remove deprecated context managers (#5752)
- Remove deprecated function utils.to_tuple (#5755)
- Remove deprecated display_pygraphviz (#5754)
- Remove to_numpy_matrix & from_numpy_matrix (#5746)
- Remove deprecated decorator preserve_random_state (#5768)
- Remove deprecated function is_list_of_ints (#5743)
- Remove decorator random_state (#5770)
- remove `adj_matrix` from `linalg/graphmatrix.py` (#5753)
- Remove betweenness_centrality_source (#5786)
- Remove deprecated simrank_similarity_numpy (#5783)
- Remove networkx.testing subpackage (#5782)
- Change PyDot PendingDeprecation to Deprecation (#5781)
- Remove deprecated numeric_mixing_matrix (#5777)
- Remove deprecated functions make_small_graph and make_small_undirected_graph (#5761)
- Remove _naive_greedy_modularity_communities (#5760)
- Make chordal_graph_cliques a generator (#5758)
- update cytoscape functions to drop old signature (#5784)
- Remove deprecated functions dict_to_numpy_array2 and dict_to_numpy_array1 (#5756)
- Remove deprecated function utils.default_opener (#5747)
- Remove deprecated function iterable (#5742)
- remove old attr keyword from json_graph/tree (#5785)
- Remove generate_unique_node (#5780)
- Replace node_classification subpackage with a module (#5774)
- Remove gpickle (#5773)
- Remove deprecated function extrema_bounding (#5757)
- Remove coverage and performance from quality (#5775)
- Update return type of google_matrix to numpy.ndarray (#5762)
- Remove deprecated k-nearest-neighbors (#5769)
- Remove gdal dependency (#5766)
- Update return type of attrmatrix (#5764)
- Remove unused deprecated argument from to_pandas_edgelist (#5778)
- Remove deprecated function edge_betweenness (#5765)
- Remove pyyaml dependency (#5763)
- Remove copy methods for Filter* coreviews (#5776)
- Remove deprecated function nx.info (#5759)
- Remove deprecated n_communities argument from greedy_modularity_communities (#5789)
- Remove deprecated functions hub_matrix and authority_matrix (#5767)
- Make HITS numpy and scipy private functions (#5771)
- Add Triad example plot (#5528)
- Add gallery example visualizing DAG with multiple layouts (#5432)
- Make pagerank numpy and scipy private functions (#5772)
- Implement directed edge swap (#5663)
- Update relabel.py to preserve node order (#5258)
- Modify DAG example to show topological layout. (#5835)
- Add docstring example for self-ancestors/descendants (#5802)
- Update precommit linters (#5839)
- remove to/from_scipy_sparse_matrix (#5779)
- Clean up from PR #5779 (#5841)
- Corona Product (#5223)
- Add direct link to github networkx org sponsorship (#5843)
- added examples to efficiency_measures.py (#5643)
- added examples to regular.py (#5642)
- added examples to degree_alg.py (#5644)
- Add docstring examples for triads functions (#5522)
- Fix docbuild warnings: is_string_like is removed and indentation in corona product (#5845)
- Use py_random_state to control randomness of random_triad (#5847)
- Remove OrderedGraphs (#5813)
- Drop NumPy 1.19 (#5856)
- Speed up unionfind a bit by not adding root node in the path (#5844)
- Minor doc fixups (#5868)
- Attempt to reverse slowdown from hasattr needed for cached_property (#5836)
- make lazy_import private and remove its internal use (#5878)
- strategy_saturation_largest_first now accepts partial colorings (#5888)
- Add weight distance metrics (#5305)
- docstring updates for `union`, `disjoint_union`, and `compose` (#5892)
- Update precommit hooks (#5923)
- Remove old Appveyor cruft (#5924)
- signature change for `node_link` functions: for issue #5787 (#5899)
- Replace LCA with naive implementations (#5883)
- Bump nodelink args deprecation expiration to v3.2 (#5933)
- Update mapping logic in `relabel_nodes` (#5912)
- Update pygraphviz (#5934)
- Further improvements to strategy_saturation_largest_first (#5935)
- Arf layout (#5910)
- [ENH] Find and verify a minimal D-separating set in DAG (#5898)
- Add Mehlhorn Steiner approximations (#5629)
- Preliminary VF2++ Implementation (#5788)
- Minor docstring touchups and test refactor for `is_path` (#5967)
- Switch to relative import for vf2pp_helpers. (#5973)
- Add vf2pp_helpers subpackage to wheel (#5975)
- Enhance biconnected components to avoid indexing (#5974)
- Update mentored projects list (#5985)
- Add concurrency hook to cancel jobs on new push. (#5986)
- Make all.py generator friendly (#5984)
- Only run scheduled pytest-randomly job in main repo. (#5993)
- Fix steiner tree test (#5999)
- Update doc requirements (#6008)
- VF2++ for Directed Graphs (#5972)
- Fix defect and update docs for MappedQueue, related to gh-5681 (#5939)
- Update pydata-sphinx-theme (#6012)
- Update numpydoc (#6022)
- Fixed test for average shortest path in the case of directed graphs (#6003)
- Update deprecations after 3.0 dep sprint (#6031)
- Use scipy.sparse array datastructure (#6037)
- Designate 3.0b1 release
- Bump release version
- Use org funding.yml
- Update which flow functions support the cutoff argument (#6085)
- Update GML parsing/writing to allow empty lists/tuples as node attributes (#6093)
- Warn on unused visualization kwargs that only apply to FancyArrowPatch edges (#6098)
- Fix weighted MultiDiGraphs in DAG longest path algorithms + add additional tests (#5988)
- Circular center node layout (#6114)
- Fix doc inconsistencies related to cutoff in connectivity.py and disjoint_paths.py (#6113)
- Remove deprecated maxcardinality parameter from min_weight_matching (#6146)
- Remove deprecated `find_cores` (#6139)
- Remove deprecated project function from bipartite package. (#6147)
- Improve test coverage for voterank algorithm (#6161)
- plugin based backend infrastructure to use multiple computation backends (#6000)
- Undocumented parameters in dispersion (#6183)
- Swap.py coverage to 100 (#6176)
- Improve test coverage for current_flow_betweenness module (#6143)
- Completed Testing in community.py resolves issue #6184 (#6185)
- Added an example to algebraic_connectivity (#6153)
- Add ThinGraph example to Multi*Graph doc_strings (#6160)
- Fix defect in eulerize, replace reciprocal edge weights (#6145)
- For issue #6030 Add test coverage for algorithms in beamsearch.py (#6087)
- Improve test coverage expanders stochastic graph generators (#6073)
- Update developer requirements (#6194)
- Designate 3.0rc1 release
- Bump release version
- Tests added in test_centrality.py (#6200)
- add laplacian_spectrum example (#6169)
- PR for issue #6033 Improve test coverage for algorithms in betweenness_subset.py #6033 (#6083)
- Di graph edges doc fix (#6108)
- Improve coverage for core.py (#6116)
- Add clear edges method as a method to be frozen by nx.freeze (#6190)
- Adds LCA test case for self-ancestors from gh-4458. (#6218)
- Minor Python 2 cleanup (#6219)
- Add example laplacian matrix (#6168)
- Revert 6219 and delete comment. (#6222)
- fix wording in error message (#6228)
- Rm incorrect test case for connected edge swap (#6223)
- add missing `seed` to function called by `connected_double_edge_swap` (#6231)
- Hide edges with a weight of None in A*. (#5945)
- Add dfs_labeled_edges reporting of reverse edges due to depth_limit. (#6240)
- Warn users about duplicate nodes in generator function input (#6237)
- Re-enable geospatial examples (#6252)
- Draft 3.0 release notes (#6232)
- Add 2.8.x release notes (#6255)
- doc: clarify allowed `alpha` when using nx.draw_networkx_edges (#6254)
- Add a contributor (#6256)
- Allow MultiDiGraphs for LCA (#6234)
- Update simple_paths.py to improve readability of the BFS. (#6273)
- doc: update documentation when providing an iterator over current graph to add/remove_edges_from. (#6268)
- Fix bug vf2pp is isomorphic issue 6257 (#6270)
- Improve test coverage for Eigenvector centrality (#6227)
- Bug fix in swap: directed_edge_swap and double_edge_swap (#6149)
- Adding a test to verify that a NetworkXError is raised when calling n… (#6265)
- Pin to sphinx 5.2.3 (#6277)
- Update pre-commit hooks (#6278)
- Update GH actions (#6280)
- Fix links in release notes (#6281)
- bug fix in smallworld.py: random_reference and lattice_reference (#6151)
- [DOC] Follow numpydoc standard in barbell_graph documentation (#6286)
- Update simple_paths.py: consistent behaviour for `is_simple_path` when path contains nodes not in the graph. (#6272)
- Correctly point towards 2.8.8 in release notes (#6298)
- Isomorphism improve documentation (#6295)
- Improvements and test coverage for `line.py` (#6215)
- Fix typo in Katz centrality comment (#6310)
- Broken link in isomorphism documentation (#6296)
- Update copyright years to 2023 (#6322)
- fix warnings for make doctest (#6323)
- fix whitespace issue in test_internet_as_graph (#6324)
- Create a Tikz latex drawing feature for networkx (#6238)
- Fix docstrings (#6329)
- Fix documentation deployment (#6330)
- Fix links to migration guide (#6331)
- Fix links to migration guide (#6331)
- Fix typo in readme file (#6312)
- Fix typos in the networkx codebase (#6335)
- Refactor vf2pp modules and test files (#6334)
Contributors
------------
- 0ddoe_s
- Abangma Jessika
- Adam Li
- Adam Richardson
- Ali Faraji
- Alimi Qudirah
- Anurag Bhat
- Ben Heil
- Brian Hou
- Casper van Elteren
- danieleades
- Dan Schult
- ddelange
- Dilara Tekinoglu
- Dimitrios Papageorgiou
- Douglas K. G. Araujo
- Erik Welch
- George Watkins
- Guy Aglionby
- Isaac Western
- Jarrod Millman
- Jim Kitchen
- Juanita Gomez
- Kevin Brown
- Konstantinos Petridis
- ladykkk
- Lucas H. McCabe
- Ludovic Stephan
- Lukong123
- Matt Schwennesen
- Michael Holtz
- Morrison Turnansky
- Mridul Seth
- nsengaw4c
- Okite chimaobi Samuel
- Paula Pérez Bianchi
- Radoslav Fulek
- reneechebbo
- Ross Barnowski
- Sebastiano Vigna
- stevenstrickler
- Sultan Orazbayev
- Tina Oberoi
---
### Doc Release Release 3.1 (`doc/release/release_3.1.rst`)
NetworkX 3.1
============
Release date: 4 April 2023
Supports Python 3.8, 3.9, 3.10, and 3.11.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
This release is the result of 3 months of work with over 85 pull requests by
26 contributors. Highlights include:
- Minor bug-fixes and speed-ups
- Improvements to plugin based backend infrastructure
- Minor documentation improvements
- Improved test coverage
- Last release supporting Python 3.8
- Stopped building PDF version of docs
- Use Ruff for linting
Improvements
------------
- [`#6461 <https://github.com/networkx/networkx/pull/6461>`_]
Add simple cycle enumerator for undirected class
- [`#6404 <https://github.com/networkx/networkx/pull/6404>`_]
Add spectral bisection for graphs using fiedler vector
- [`#6244 <https://github.com/networkx/networkx/pull/6244>`_]
Improve handling of create_using to allow Mixins of type Protocol
- [`#5399 <https://github.com/networkx/networkx/pull/5399>`_]
Add Laplace centrality measure
Deprecations
------------
- [`#6564 <https://github.com/networkx/networkx/pull/6564>`_]
Deprecate ``single_target_shortest_path_length`` to change return value to a dict in v3.3.
Deprecate ``shortest_path`` in case of all_pairs to change return value to a iterator in v3.3.
- [`#5602 <https://github.com/networkx/networkx/pull/5602>`_]
Deprecate ``forest_str`` function (use ``write_network_text`` instead).
Merged PRs
----------
- Designate 3.0 release
- Fix docs
- Bump release version
- Fix link in isomorphvf2.py (#6347)
- Add dev release notes template
- Update precommit hooks (#6348)
- Add clique examples and deprecate helper functions (#6186)
- Laplace centrality for issue 4973 (#5399)
- doc:improve doc of possible values of nodes and expected behaviour (#6333)
- add OrderedGraph removal as an API change in release_3.0.rst (#6354)
- Update release_3.0 authors (add Jim and Erik) (#6356)
- Fix broken link nx guide (#6361)
- Add nx-guide link in the tutorial (#6353)
- DOC: Minor formatting fixups to get rid of doc build warnings. (#6363)
- Fix equation in clustering documentation (#6369)
- Add reference to paper in vf2pp (#6373)
- provide tikz with degrees, not radians (#6360)
- Improve handling of create_using to allow Mixins of type Protocol (#6244)
- Remove an instance of random.sample from a set (deprecated in Python 3.9) (#6380)
- DOC: Add banner for user survey announcement (#6375)
- bump pre-commit hooks (and fix CI) (#6396)
- Add generate / write "network text" (formerly graph_str) (#5602)
- Improve doc regular graphs (#6397)
- Fix link vonoroi (#6398)
- Document PageRank algo convergence condition (#6212)
- Fix pre-commit on Python 3.10 (#6407)
- DOC: list pred method for MultiDiGraphs (#6409)
- Delete warning in approximation documentation (#6221)
- Comment out unused unlayered dict construction. (#6411)
- Update installation test instructions (#6303)
- Added new tests in test_clique.py (#6142)
- Improve testing of bipartite projection. (#6196)
- Add dispatching to more shortest path algorithms (#6415)
- Add Plausible Analytics to our docs (#6413)
- Fix docstring heading title. (#6424)
- Added tests to test_directed.py. (#6208)
- Gallery example for Maximum Independent Set (#5563)
- spectral bisection for graphs using fiedler vector (#6404)
- Update developer requirements (#6429)
- Fix reference in line.py-inverse_line_graph (#6434)
- Add project desc for visualization and ISMAGs (#6432)
- Lint using Ruff (#6371)
- add ruff commit to git-blame-ignore (#6440)
- NXEP 0 and NXEP 1 - change status to Accepted (#5343)
- Bump gh-pages deploy bot version. (#6446)
- Start using ruff for pyupgrade and isort (#6441)
- Add documentation building to contributor guide (#6437)
- Reset deploy-action param names for latest version. (#6451)
- Doc upgrade paley graph (#6399)
- Added two tests for convert_numpy (#6455)
- Clean up similarity.py and use dataclasses for storing state (#5831)
- Remove pdf latex builds of docs (#5572)
- Add docstring for dorogovtsev_goltsev_mendes generator (#6450)
- Allow first argument to be passed as kwarg in dispatcher (#6471)
- Fix negative edge cycle function raising exception for empty graph (#6473)
- Dispatch more BFS-based algorithms (#6467)
- Ignore weakrefs when testing for memory leak (#6466)
- Fix reference formatting in generator docstring. (#6493)
- tweak `test_override_dispatch` to allow G keyword (#6499)
- Improve test coverage for astar.py (#6504)
- Add docstring example to weighted.py (#6497)
- Fix len operation of UnionAtlas (#6478)
- Improve test coverage for edgelist.py (#6507)
- Improve test coverage for mst.py and bug fix in prim_mst_edges() (#6486)
- Add examples clarifying ambiguity of nbunch (#6513)
- Updating removing explicit import for communities (#6459)
- Use generator to limit memory footprint of read_graph6. (#6519)
- Update docstring of paley graph (#6529)
- Fixed bug k_truss doesn't raise exception for self loops (#6521)
- Update pre-commit (#6545)
- Update sphinx (#6544)
- Add docstring examples to dag.py (#6491)
- Add example script for mst (#6525)
- Add docstring examples to boundary.py (#6487)
- improve test coverage for branchings.py (#6523)
- Improve test coverage for redundancy.py (#6551)
- Fixed return type inconsistencies in shortest path methods documentation (#6528)
- Optimize _single_shortest_path_length function (#6299)
- Deprecate shortest_path functions to have consistent return values in v3.3 (#6567)
- Add community detection example to Gallery (#6526)
- add simple cycle enumerator for undirected class (#6461)
- Fix survey URL (#6548)
- Test dispatching via nx-loopback backend (#6536)
- Fixed return type inconsistencies in weighted.py (#6568)
- Update team galleries (#6569)
- Added Docstring Example for Bidirectional Shortest Path (#6570)
- Update release requirements (#6587)
- Designate 3.1rc0 release
- Bump release version
- corrections to docstring of `weisfeiler_lehman_subgraph_hashes` (#6598)
- Fixed method description in ismags.py (#6600)
- Minor docs/test maintenance (#6614)
- Better default alpha value for viz attributes in gexf writer (#6612)
- Fix module docstring format for ismags reference article. (#6611)
- Resolve NXEP4 with justification for not implementing it. (#6617)
- Fix typos (#6620)
- Draft release notes (#6621)
- Prep 3.1 release
Contributors
------------
- Navya Agarwal
- Lukong Anne
- Ross Barnowski
- Gabor Berei
- Paula Pérez Bianchi
- Kelly Boothby
- Purvi Chaurasia
- Jon Crall
- Michael Holtz
- Jim Kitchen
- Claudia Madrid
- Jarrod Millman
- Vanshika Mishra
- Harri Nieminen
- Tina Oberoi
- Omkaar
- Dima Pasechnik
- Alimi Qudirah
- Dan Schult
- Mridul Seth
- Eric Sims
- Tortar
- Erik Welch
- Aaron Z
- danieleades
- stanyas
---
### Doc Release Release 3.2.1 (`doc/release/release_3.2.1.rst`)
NetworkX 3.2.1
==============
Release date: 28 October 2023
Supports Python 3.9, 3.10, 3.11, and 3.12.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
API Changes
-----------
- Disallow negative number of nodes in ``complete_multipartite_graph`` (`#7057 <https://github.com/networkx/networkx/pull/7057>`_).
Enhancements
------------
- Add Tadpole graph (`#6999 <https://github.com/networkx/networkx/pull/6999>`_).
Bug Fixes
---------
- Fix listing of release notes on Releases page (`#7030 <https://github.com/networkx/networkx/pull/7030>`_).
- Fix syntax warning from bad escape sequence (`#7034 <https://github.com/networkx/networkx/pull/7034>`_).
- Fix triangles to avoid using ``is`` to compare nodes (`#7041 <https://github.com/networkx/networkx/pull/7041>`_).
- Fix error message for ``nx.mycielski_graph(0)`` (`#7056 <https://github.com/networkx/networkx/pull/7056>`_).
- Disallow negative number of nodes in ``complete_multipartite_graph`` (`#7057 <https://github.com/networkx/networkx/pull/7057>`_).
Documentation
-------------
- Update release process (`#7029 <https://github.com/networkx/networkx/pull/7029>`_).
- fix extendability function name in bipartite.rst (`#7042 <https://github.com/networkx/networkx/pull/7042>`_).
- Minor doc cleanups to remove doc build warnings (`#7048 <https://github.com/networkx/networkx/pull/7048>`_).
Maintenance
-----------
- fix: Explicitly check for None/False in edge_attr during import from np (`#6825 <https://github.com/networkx/networkx/pull/6825>`_).
- Add favicon (`#7043 <https://github.com/networkx/networkx/pull/7043>`_).
- Remove unused code resistance_distance (`#7053 <https://github.com/networkx/networkx/pull/7053>`_).
- Fix names of small graphs (`#7055 <https://github.com/networkx/networkx/pull/7055>`_).
- Improve error messages for misconfigured backend treatment (`#7062 <https://github.com/networkx/networkx/pull/7062>`_).
Other
-----
- Update convert_matrix.py (`#7018 <https://github.com/networkx/networkx/pull/7018>`_).
Contributors
------------
8 authors added to this release (alphabetically):
- `@peijenburg <https://github.com/peijenburg>`_
- AKSHAYA MADHURI (`@akshayamadhuri <https://github.com/akshayamadhuri>`_)
- Dan Schult (`@dschult <https://github.com/dschult>`_)
- Erik Welch (`@eriknw <https://github.com/eriknw>`_)
- Jarrod Millman (`@jarrodmillman <https://github.com/jarrodmillman>`_)
- Jonas Otto (`@ottojo <https://github.com/ottojo>`_)
- Jordan Matelsky (`@j6k4m8 <https://github.com/j6k4m8>`_)
- Ross Barnowski (`@rossbar <https://github.com/rossbar>`_)
6 reviewers added to this release (alphabetically):
- `@peijenburg <https://github.com/peijenburg>`_
- Dan Schult (`@dschult <https://github.com/dschult>`_)
- Jarrod Millman (`@jarrodmillman <https://github.com/jarrodmillman>`_)
- Mridul Seth (`@MridulS <https://github.com/MridulS>`_)
- Ross Barnowski (`@rossbar <https://github.com/rossbar>`_)
- Stefan van der Walt (`@stefanv <https://github.com/stefanv>`_)
_These lists are automatically generated, and may not be complete or may contain
duplicates._
---
### Doc Release Release 3.2 (`doc/release/release_3.2.rst`)
NetworkX 3.2
============
Release date: 18 October 2023
Supports Python 3.9, 3.10, 3.11, and 3.12.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
Highlights
----------
- Add ``@nx._dispatch`` decorator to most algorithms (`#6688 <https://github.com/networkx/networkx/pull/6688>`_).
API Changes
-----------
- Remove ``topo_order`` kwarg from ``is_semiconnected`` without deprecation (`#6651 <https://github.com/networkx/networkx/pull/6651>`_).
- deprecate Edmonds class (`#6785 <https://github.com/networkx/networkx/pull/6785>`_).
- Make weight part of the API for functions which had default assumptions (`#6814 <https://github.com/networkx/networkx/pull/6814>`_).
- ENH: let users set a default value in get_attr methods (`#6887 <https://github.com/networkx/networkx/pull/6887>`_).
- Rename function ``join`` as ``join_trees`` (`#6908 <https://github.com/networkx/networkx/pull/6908>`_).
- API: Add a decorator to deprecate positional args (`#6905 <https://github.com/networkx/networkx/pull/6905>`_).
- Expire deprecation for ``attrs`` kwarg in node_link module (`#6939 <https://github.com/networkx/networkx/pull/6939>`_).
- Minor touchup to the sort_neighbors deprecation (`#6942 <https://github.com/networkx/networkx/pull/6942>`_).
- Rm deprecated ``create_using`` kwarg from scale_free_graph (`#6940 <https://github.com/networkx/networkx/pull/6940>`_).
- Make position part of the API for geometric_edges (`#6816 <https://github.com/networkx/networkx/pull/6816>`_).
- Undeprecate literal_(de)stringizer (`#6943 <https://github.com/networkx/networkx/pull/6943>`_).
- Make new dtype param for incidence_matrix kwarg-only (`#6954 <https://github.com/networkx/networkx/pull/6954>`_).
- Make weight and seed for ``fast_label_propagation_communities`` kwarg only (`#6955 <https://github.com/networkx/networkx/pull/6955>`_).
- API: Rm default value from time_delta for cd_index (`#6953 <https://github.com/networkx/networkx/pull/6953>`_).
- Deprecate strongly_connected_components_recursive (`#6957 <https://github.com/networkx/networkx/pull/6957>`_).
- Rm deprecated clique helper functions (`#6941 <https://github.com/networkx/networkx/pull/6941>`_).
Enhancements
------------
- Update calculation of triangles (`#6258 <https://github.com/networkx/networkx/pull/6258>`_).
- Add single_source_all_shortest_paths and all_pairs_all_shortest_paths (`#5959 <https://github.com/networkx/networkx/pull/5959>`_).
- Add ``@nx._dispatch`` decorator to most algorithms (`#6688 <https://github.com/networkx/networkx/pull/6688>`_).
- Move benchmarks inside main repo (`#6835 <https://github.com/networkx/networkx/pull/6835>`_).
- ENH -- Replaced for-loops in :function:``rescale_layout`` with numpy vectorized methods (`#6879 <https://github.com/networkx/networkx/pull/6879>`_).
- Fast label propagation algorithm for community detection (`#6843 <https://github.com/networkx/networkx/pull/6843>`_).
- Add time series Visibility Graph generator (`#6880 <https://github.com/networkx/networkx/pull/6880>`_).
- Random trees & forests (`#6758 <https://github.com/networkx/networkx/pull/6758>`_).
- Add support for tuple-nodes to default gml parser (`#6950 <https://github.com/networkx/networkx/pull/6950>`_).
- Add Kemeny's constant (`#6929 <https://github.com/networkx/networkx/pull/6929>`_).
- Speedup resistance_distance (`#6925 <https://github.com/networkx/networkx/pull/6925>`_).
- Allow graph generators and conversion functions to be dispatched (`#6876 <https://github.com/networkx/networkx/pull/6876>`_).
- adding extendability problem (2nd try) (`#4890 <https://github.com/networkx/networkx/pull/4890>`_).
Bug Fixes
---------
- Fixing DOT format for to_agraph() (`#6474 <https://github.com/networkx/networkx/pull/6474>`_).
- Remove ``topo_order`` kwarg from ``is_semiconnected`` without deprecation (`#6651 <https://github.com/networkx/networkx/pull/6651>`_).
- Stabilize test of approximation.connected_components (`#6715 <https://github.com/networkx/networkx/pull/6715>`_).
- Fix minimum_cycle_basis and change to return cycle instead of set (`#6788 <https://github.com/networkx/networkx/pull/6788>`_).
- Refix minimum_cycle_basis and scipy.sparse conversions and add tests (`#6789 <https://github.com/networkx/networkx/pull/6789>`_).
- number_of_walks might use a weighted edge attribute (`#6815 <https://github.com/networkx/networkx/pull/6815>`_).
- GML: added support for reading multi-line values (`#6837 <https://github.com/networkx/networkx/pull/6837>`_).
- Avoid directed_laplacian_matrix causing nans in some cases (`#6866 <https://github.com/networkx/networkx/pull/6866>`_).
- Add test about zero weight cycles and fix goldberg-radzik (`#6892 <https://github.com/networkx/networkx/pull/6892>`_).
- Modify ``s_metric`` ``normalized`` default so function doesn't raise (`#6841 <https://github.com/networkx/networkx/pull/6841>`_).
- Error handling for invalid prufer sequence ``from_prufer_sequence``: issue #6420 (`#6457 <https://github.com/networkx/networkx/pull/6457>`_).
- FIX: Better default behaviour for percolation centrality with no node attrs (`#6894 <https://github.com/networkx/networkx/pull/6894>`_).
- FIX: MultiDiGraphs keys got lost in weighted shortest paths (`#6963 <https://github.com/networkx/networkx/pull/6963>`_).
- Handle edge cases in Laplacian centrality (`#6938 <https://github.com/networkx/networkx/pull/6938>`_).
- adding a formula that ignores self-loops at the each level of directed louvain algorithm (`#6630 <https://github.com/networkx/networkx/pull/6630>`_).
- Fix ``````is_k_edge_connected`````` for case of k=2 (`#7024 <https://github.com/networkx/networkx/pull/7024>`_).
Documentation
-------------
- Fix links in laplacian_centrality and laplacian_matrix (`#6623 <https://github.com/networkx/networkx/pull/6623>`_).
- Add Greedy Coloring Example to Gallery (`#6647 <https://github.com/networkx/networkx/pull/6647>`_).
- Add linting to contributor guide (`#6692 <https://github.com/networkx/networkx/pull/6692>`_).
- Minor fixups to equitable_coloring docstring (`#6673 <https://github.com/networkx/networkx/pull/6673>`_).
- Remove survey banner (`#6818 <https://github.com/networkx/networkx/pull/6818>`_).
- fix: make messages readable (`#6860 <https://github.com/networkx/networkx/pull/6860>`_).
- add docs for source input of dfs_predecessor and dfs_successor (`#6867 <https://github.com/networkx/networkx/pull/6867>`_).
- Clarify that basis generates simple cycles only (`#6882 <https://github.com/networkx/networkx/pull/6882>`_).
- Revert "Clarify that basis generates simple cycles only" (`#6885 <https://github.com/networkx/networkx/pull/6885>`_).
- updating TSP example docs (`#6794 <https://github.com/networkx/networkx/pull/6794>`_).
- MAINT: Point the PR template to pre-commit (`#6902 <https://github.com/networkx/networkx/pull/6902>`_).
- fix doc build errors/warnings (`#6907 <https://github.com/networkx/networkx/pull/6907>`_).
- DOC: stray backtick and double instead of simple backtick (`#6917 <https://github.com/networkx/networkx/pull/6917>`_).
- DOC: Add example for self loop multidigraph in contraction (`#6901 <https://github.com/networkx/networkx/pull/6901>`_).
- Fix sphinx docs rendering of dispatched functions (`#6895 <https://github.com/networkx/networkx/pull/6895>`_).
- added more examples on graphical degree sequence (`#5634 <https://github.com/networkx/networkx/pull/5634>`_).
- Minor touchup to the sort_neighbors deprecation (`#6942 <https://github.com/networkx/networkx/pull/6942>`_).
- Warning comment for float weights in betweenness.py (`#5171 <https://github.com/networkx/networkx/pull/5171>`_).
- DOC: Misc typos (`#6959 <https://github.com/networkx/networkx/pull/6959>`_).
- Fixing typo in effective_size documentation (`#6967 <https://github.com/networkx/networkx/pull/6967>`_).
- fix examples in tournament.py (`#6964 <https://github.com/networkx/networkx/pull/6964>`_).
- Fix a reference (`#6977 <https://github.com/networkx/networkx/pull/6977>`_).
- Add missing parameter to snap_aggregation docstring (`#6978 <https://github.com/networkx/networkx/pull/6978>`_).
- Update developer deprecation todo list (`#6985 <https://github.com/networkx/networkx/pull/6985>`_).
- Add "networkx.plugin_info" entry point and update docstring (`#6911 <https://github.com/networkx/networkx/pull/6911>`_).
- document graph type; add links; rm unused import (`#6992 <https://github.com/networkx/networkx/pull/6992>`_).
- Add GraphBLAS backend to online docs (`#6998 <https://github.com/networkx/networkx/pull/6998>`_).
- Add 3.2rc0 release notes (`#6997 <https://github.com/networkx/networkx/pull/6997>`_).
- Update release process for changelist (`#7005 <https://github.com/networkx/networkx/pull/7005>`_).
- Update contributing guide for changelist workflow (`#7004 <https://github.com/networkx/networkx/pull/7004>`_).
- Fix definition of $m$ parameter in docstring of ``modularity`` function (`#6990 <https://github.com/networkx/networkx/pull/6990>`_).
- updated docs of SA_tsp and TA_tsp (`#7013 <https://github.com/networkx/networkx/pull/7013>`_).
- Update katz_centrality missing default alpha value (`#7015 <https://github.com/networkx/networkx/pull/7015>`_).
Maintenance
-----------
- Replacing codecov Python CLI with gh action (`#6635 <https://github.com/networkx/networkx/pull/6635>`_).
- Bump pyupgrade minimum Python version to 3.9 (`#6634 <https://github.com/networkx/networkx/pull/6634>`_).
- MAINT: minor coverage cleanup (`#6674 <https://github.com/networkx/networkx/pull/6674>`_).
- Rm unreachable code for validating input (`#6675 <https://github.com/networkx/networkx/pull/6675>`_).
- Pin sphinx<7 as temporary fix for doc CI failures (`#6680 <https://github.com/networkx/networkx/pull/6680>`_).
- Example of improving test granularity related to #5092 (`#5094 <https://github.com/networkx/networkx/pull/5094>`_).
- MAINT: Bump scipy version and take advantage of lazy loading (`#6704 <https://github.com/networkx/networkx/pull/6704>`_).
- Drop support for Python 3.8 per SPEC0 (`#6733 <https://github.com/networkx/networkx/pull/6733>`_).
- Update pygraphviz (`#6724 <https://github.com/networkx/networkx/pull/6724>`_).
- Update core dependencies per SPEC0 (`#6734 <https://github.com/networkx/networkx/pull/6734>`_).
- Test on Python 3.12-beta2 (`#6737 <https://github.com/networkx/networkx/pull/6737>`_).
- update the OSMnx example (`#6775 <https://github.com/networkx/networkx/pull/6775>`_).
- Minor fixups to clear up numpy deprecation warnings (`#6776 <https://github.com/networkx/networkx/pull/6776>`_).
- Add label-check workflow (`#6797 <https://github.com/networkx/networkx/pull/6797>`_).
- Use dependabot (`#6799 <https://github.com/networkx/networkx/pull/6799>`_).
- Bump webfactory/ssh-agent from 0.7.0 to 0.8.0 (`#6800 <https://github.com/networkx/networkx/pull/6800>`_).
- Attach milestone to merged PRs (`#6802 <https://github.com/networkx/networkx/pull/6802>`_).
- Add preserve_all_attrs to convert_from_nx to make it concise (`#6812 <https://github.com/networkx/networkx/pull/6812>`_).
- Bump scientific-python/attach-next-milestone-action from f94a5235518d4d34911c41e19d780b8e79d42238 to bc07be829f693829263e57d5e8489f4e57d3d420 (`#6830 <https://github.com/networkx/networkx/pull/6830>`_).
- Relax threshold in test of ``betweenness_centrality`` (`#6827 <https://github.com/networkx/networkx/pull/6827>`_).
- Add @nx._dispatch to {single_source,all_pairs}_all_shortest_paths, cd_index (`#6832 <https://github.com/networkx/networkx/pull/6832>`_).
- ci: Add distribution verification checks to nightly wheel upload (`#6831 <https://github.com/networkx/networkx/pull/6831>`_).
- MAINT: fix link to nightly releases wheels (`#6845 <https://github.com/networkx/networkx/pull/6845>`_).
- Don't test numpy2 nightlies (`#6852 <https://github.com/networkx/networkx/pull/6852>`_).
- MAINT: replace numpy aliases in scipy namespace (`#6857 <https://github.com/networkx/networkx/pull/6857>`_).
- Unpin scipy upperbound for tests (`#6727 <https://github.com/networkx/networkx/pull/6727>`_).
- Temporary work-around for NEP 51 numpy scalar reprs + NX doctests (`#6856 <https://github.com/networkx/networkx/pull/6856>`_).
- Unpin numpy nightly wheels (`#6854 <https://github.com/networkx/networkx/pull/6854>`_).
- fix: make messages readable (`#6860 <https://github.com/networkx/networkx/pull/6860>`_).
- Revert "Pin sphinx<7 as temporary fix for doc CI failures (#6680)" (`#6859 <https://github.com/networkx/networkx/pull/6859>`_).
- Change ``_dispatch`` to a class instead of a closure (`#6840 <https://github.com/networkx/networkx/pull/6840>`_).
- Move random_state decorators before ``@nx._dispatch`` (`#6878 <https://github.com/networkx/networkx/pull/6878>`_).
- MAINT: Make GEXF and graphml writer work with numpy 2.0 (`#6900 <https://github.com/networkx/networkx/pull/6900>`_).
- Rename function ``join`` as ``join_trees`` (`#6908 <https://github.com/networkx/networkx/pull/6908>`_).
- add missing ``join`` deprecation stuff to release_dev and conftest (`#6933 <https://github.com/networkx/networkx/pull/6933>`_).
- MAINT: move dispatch test workflow as an independent CI job (`#6934 <https://github.com/networkx/networkx/pull/6934>`_).
- MAINT: Use importlib.resources instead of file dunder to access files (`#6936 <https://github.com/networkx/networkx/pull/6936>`_).
- DOC, MAINT: Deduplicate docs instructions (`#6937 <https://github.com/networkx/networkx/pull/6937>`_).
- MAINT: Raise clean error with random_triad for graph with <3 nodes (`#6962 <https://github.com/networkx/networkx/pull/6962>`_).
- Update numpydoc (`#6773 <https://github.com/networkx/networkx/pull/6773>`_).
- MAINT: update pre-commit tools deps (`#6965 <https://github.com/networkx/networkx/pull/6965>`_).
- MAINT: Clean up commented out code in triads (`#6961 <https://github.com/networkx/networkx/pull/6961>`_).
- MAINT: Scipy nightly failing with np alias (`#6969 <https://github.com/networkx/networkx/pull/6969>`_).
- Bump actions/checkout from 3 to 4 (`#6970 <https://github.com/networkx/networkx/pull/6970>`_).
- Add for testing new pydata-sphinx-theme PR (`#6982 <https://github.com/networkx/networkx/pull/6982>`_).
- MAINT: Disable building delaunay geospatial example temporarily (`#6981 <https://github.com/networkx/networkx/pull/6981>`_).
- Revert "MAINT: Disable building delaunay geospatial example temporarily" (`#6984 <https://github.com/networkx/networkx/pull/6984>`_).
- Enhancements change default join trees 6947 (`#6948 <https://github.com/networkx/networkx/pull/6948>`_).
- Update sphinx theme (`#6930 <https://github.com/networkx/networkx/pull/6930>`_).
- Generate requirements files from pyproject.toml (`#6987 <https://github.com/networkx/networkx/pull/6987>`_).
- Use trusted publisher (`#6988 <https://github.com/networkx/networkx/pull/6988>`_).
- Prefer "backend" instead of "plugin" (`#6989 <https://github.com/networkx/networkx/pull/6989>`_).
- CI: Pin scientific-python/upload-nightly-action to 0.2.0 (`#6993 <https://github.com/networkx/networkx/pull/6993>`_).
- Support Python 3.12 (`#7009 <https://github.com/networkx/networkx/pull/7009>`_).
- pip install nx-cugraph from git, not nightly wheels, for docs (`#7011 <https://github.com/networkx/networkx/pull/7011>`_).
- Fix typos (`#7012 <https://github.com/networkx/networkx/pull/7012>`_).
Other
-----
- Update release process (`#6622 <https://github.com/networkx/networkx/pull/6622>`_).
- Add Lowest Common Ancestor example to Gallery (`#6542 <https://github.com/networkx/networkx/pull/6542>`_).
- Add examples to bipartite centrality.py (`#6613 <https://github.com/networkx/networkx/pull/6613>`_).
- Remove Python 3.8 from CI (`#6636 <https://github.com/networkx/networkx/pull/6636>`_).
- Fix links in eigenvector.py and katz_centrality.py (`#6640 <https://github.com/networkx/networkx/pull/6640>`_).
- Use the correct namespace for girvan_newman examples (`#6643 <https://github.com/networkx/networkx/pull/6643>`_).
- Preserve node order in bipartite_layout (`#6644 <https://github.com/networkx/networkx/pull/6644>`_).
- Make cycle_basis() deterministic (`#6654 <https://github.com/networkx/networkx/pull/6654>`_).
- Added docstrings examples for clique.py (`#6576 <https://github.com/networkx/networkx/pull/6576>`_).
- Fix output of is_chordal for empty graphs (`#6563 <https://github.com/networkx/networkx/pull/6563>`_).
- Allow multiple graphs for ``@nx._dispatch`` (`#6628 <https://github.com/networkx/networkx/pull/6628>`_).
- Adding GitHub Links next to Dheeraj's name in the contributors list (`#6670 <https://github.com/networkx/networkx/pull/6670>`_).
- Adding is_tounament to main namespace (`#6498 <https://github.com/networkx/networkx/pull/6498>`_).
- Use unpacking operator on dicts to prevent constructing intermediate objects (`#6040 <https://github.com/networkx/networkx/pull/6040>`_).
- Added tests to test_correlation.py (`#6590 <https://github.com/networkx/networkx/pull/6590>`_).
- Improve test coverage for neighbor_degree.py (`#6589 <https://github.com/networkx/networkx/pull/6589>`_).
- Added docstring examples for nx_pylab.py (`#6616 <https://github.com/networkx/networkx/pull/6616>`_).
- Improve Test Coverage for current_flow_closeness.py (`#6677 <https://github.com/networkx/networkx/pull/6677>`_).
- try adding circleci artifact secret (`#6679 <https://github.com/networkx/networkx/pull/6679>`_).
- Improve test coverage for reaching.py (`#6678 <https://github.com/networkx/networkx/pull/6678>`_).
- added tests to euler.py (`#6608 <https://github.com/networkx/networkx/pull/6608>`_).
- codespell: pre-commit, config, typos fixed (`#6662 <https://github.com/networkx/networkx/pull/6662>`_).
- Improve test coverage for mst.py (`#6540 <https://github.com/networkx/networkx/pull/6540>`_).
- Handle weights as ``distance=`` in testing dispatch (`#6671 <https://github.com/networkx/networkx/pull/6671>`_).
- remove survey banner (`#6687 <https://github.com/networkx/networkx/pull/6687>`_).
- CircleCI: add token for image redirector (`#6695 <https://github.com/networkx/networkx/pull/6695>`_).
- MAINT: Add subgraph_view and reverse_view to nx namespace directly through graphviews (`#6689 <https://github.com/networkx/networkx/pull/6689>`_).
- Added docstring example for dense.py (`#6669 <https://github.com/networkx/networkx/pull/6669>`_).
- MAINT: Add a github action cron job to upload nightly wheels (`#6701 <https://github.com/networkx/networkx/pull/6701>`_).
- MAINT: fix file path in nightly build workflow (`#6702 <https://github.com/networkx/networkx/pull/6702>`_).
- Add example script for shortest path (`#6534 <https://github.com/networkx/networkx/pull/6534>`_).
- Added doctrings for generic_graph_view (`#6697 <https://github.com/networkx/networkx/pull/6697>`_).
- Doc: wrong underline length (`#6708 <https://github.com/networkx/networkx/pull/6708>`_).
- MAINT: cron job to test against nightly deps every week (`#6705 <https://github.com/networkx/networkx/pull/6705>`_).
- simplify stack in dfs (`#6366 <https://github.com/networkx/networkx/pull/6366>`_).
- optimize generic_bfs_edges function (`#6359 <https://github.com/networkx/networkx/pull/6359>`_).
- Optimize _plain_bfs functions (`#6340 <https://github.com/networkx/networkx/pull/6340>`_).
- Added girth computation function (`#6633 <https://github.com/networkx/networkx/pull/6633>`_).
- MAINT: Stop CI from uploading nightly on forks (`#6717 <https://github.com/networkx/networkx/pull/6717>`_).
- Performance improvement for astar_path (`#6723 <https://github.com/networkx/networkx/pull/6723>`_).
- Skip scipy-1.11.0rc1 due to known issue (`#6726 <https://github.com/networkx/networkx/pull/6726>`_).
- Add an optional argument to the incidence_matrix function to provide … (`#6725 <https://github.com/networkx/networkx/pull/6725>`_).
- Graph walks implementation by jfinkels & dtekinoglu (`#5908 <https://github.com/networkx/networkx/pull/5908>`_).
- DOCS: Add walks to algorithms.index (`#6736 <https://github.com/networkx/networkx/pull/6736>`_).
- Add note about using latex formatting in docstring in the contributor guide (`#6535 <https://github.com/networkx/networkx/pull/6535>`_).
- Fix intersection_all method (`#6744 <https://github.com/networkx/networkx/pull/6744>`_).
- Fix Johnson method for unweighted graphs (`#6760 <https://github.com/networkx/networkx/pull/6760>`_).
- MAINT: Ignore SciPy v1.11 in requirements (`#6769 <https://github.com/networkx/networkx/pull/6769>`_).
- Replace deprecated numpy.alltrue method (`#6768 <https://github.com/networkx/networkx/pull/6768>`_).
- keep out scipy 1.11.1 (`#6772 <https://github.com/networkx/networkx/pull/6772>`_).
- Document additional imports required for building the documentation (`#6766 <https://github.com/networkx/networkx/pull/6766>`_).
- modified max_weight_matching to be non-recursive (`#6684 <https://github.com/networkx/networkx/pull/6684>`_).
- Rewrite NXEP 3 (`#6648 <https://github.com/networkx/networkx/pull/6648>`_).
- Refactor edmonds algorithm (`#6743 <https://github.com/networkx/networkx/pull/6743>`_).
- Docstring improvement for nx_pylab.py (`#6602 <https://github.com/networkx/networkx/pull/6602>`_).
- Use pyproject.toml (`#6774 <https://github.com/networkx/networkx/pull/6774>`_).
- Include missing package_data (`#6780 <https://github.com/networkx/networkx/pull/6780>`_).
- [BUG] Patch doc and functionality for ``is_minimal_d_separator`` (`#6427 <https://github.com/networkx/networkx/pull/6427>`_).
- Update to the documentation of eigenvector centrality (`#6009 <https://github.com/networkx/networkx/pull/6009>`_).
- Fix typo in contributing page (`#6784 <https://github.com/networkx/networkx/pull/6784>`_).
- Fix empty graph zero division error for louvain (`#6791 <https://github.com/networkx/networkx/pull/6791>`_).
- Vertical chains for network text (`#6759 <https://github.com/networkx/networkx/pull/6759>`_).
- Time dependent module (`#6682 <https://github.com/networkx/networkx/pull/6682>`_).
- Allow user to opt out of edge attributes in from_numpy_array (`#6259 <https://github.com/networkx/networkx/pull/6259>`_).
- modifies ``````bfs_edges`````` and adds warning to ``````generic_bfs_edges`````` (`#5925 <https://github.com/networkx/networkx/pull/5925>`_).
- Spelling (`#6752 <https://github.com/networkx/networkx/pull/6752>`_).
- Added test cases for join operation and fixed join operation to handle label_attributes (`#6503 <https://github.com/networkx/networkx/pull/6503>`_).
- Remove serialisation artifacts on adjacency_graph (`#6041 <https://github.com/networkx/networkx/pull/6041>`_).
- Patch view signature (`#6267 <https://github.com/networkx/networkx/pull/6267>`_).
- Doc add nongraphical examples 6944 (`#6946 <https://github.com/networkx/networkx/pull/6946>`_).
- feat: docstring examples for algorithms/operators/all.py (`#6974 <https://github.com/networkx/networkx/pull/6974>`_).
Contributors
------------
70 authors added to this release (alphabetically):
- =510 (`@diohabara <https://github.com/diohabara>`_)
- `@achluma <https://github.com/achluma>`_
- `@anthonimes <https://github.com/anthonimes>`_
- `@axtavt <https://github.com/axtavt>`_
- `@cnfionawu <https://github.com/cnfionawu>`_
- `@dependabot[bot] <https://github.com/apps/dependabot>`_
- `@DiamondJoseph <https://github.com/DiamondJoseph>`_
- `@gsemer <https://github.com/gsemer>`_
- `@IbrH <https://github.com/IbrH>`_
- `@peijenburg <https://github.com/peijenburg>`_
- `@Tortar <https://github.com/Tortar>`_
- Adam Li (`@adam2392 <https://github.com/adam2392>`_)
- Adam Richardson (`@AdamWRichardson <https://github.com/AdamWRichardson>`_)
- Aditi Juneja (`@Schefflera-Arboricola <https://github.com/Schefflera-Arboricola>`_)
- AKSHAYA MADHURI (`@akshayamadhuri <https://github.com/akshayamadhuri>`_)
- Alex Markham (`@Alex-Markham <https://github.com/Alex-Markham>`_)
- Alimi Qudirah (`@Qudirah <https://github.com/Qudirah>`_)
- Andreas Wilm (`@andreas-wilm <https://github.com/andreas-wilm>`_)
- Anthony Labarre (`@alabarre <https://github.com/alabarre>`_)
- Arturo (`@ArturoSbr <https://github.com/ArturoSbr>`_)
- Dan Schult (`@dschult <https://github.com/dschult>`_)
- Davide Bonin (`@davidbonin92 <https://github.com/davidbonin92>`_)
- Davide D'Ascenzo (`@Kidara <https://github.com/Kidara>`_)
- Dhaval Kumar (`@still-n0thing <https://github.com/still-n0thing>`_)
- Dheeraj Ravindranath (`@dheerajrav <https://github.com/dheerajrav>`_)
- Dilara Tekinoglu (`@dtekinoglu <https://github.com/dtekinoglu>`_)
- Efrem Braun (`@EfremBraun <https://github.com/EfremBraun>`_)
- Eirini Kafourou (`@eirinikafourou <https://github.com/eirinikafourou>`_)
- Eran Rivlis (`@erivlis <https://github.com/erivlis>`_)
- Erik Welch (`@eriknw <https://github.com/eriknw>`_)
- Evgenia Pampidi (`@evgepab <https://github.com/evgepab>`_)
- Florine W. Dekker (`@FWDekker <https://github.com/FWDekker>`_)
- Geoff Boeing (`@gboeing <https://github.com/gboeing>`_)
- Haoyang Li (`@thirtiseven <https://github.com/thirtiseven>`_)
- Ian Thompson (`@it176131 <https://github.com/it176131>`_)
- Jarrod Millman (`@jarrodmillman <https://github.com/jarrodmillman>`_)
- Jeremy Foote (`@jdfoote <https://github.com/jdfoote>`_)
- Jim Kitchen (`@jim22k <https://github.com/jim22k>`_)
- Jon Crall (`@Erotemic <https://github.com/Erotemic>`_)
- Jordan Matelsky (`@j6k4m8 <https://github.com/j6k4m8>`_)
- Josh Soref (`@jsoref <https://github.com/jsoref>`_)
- Juanita Gomez (`@juanis2112 <https://github.com/juanis2112>`_)
- Kelly Boothby (`@boothby <https://github.com/boothby>`_)
- Kian-Meng Ang (`@kianmeng <https://github.com/kianmeng>`_)
- Koen van Walstijn (`@kbvw <https://github.com/kbvw>`_)
- Lovro Šubelj (`@lovre <https://github.com/lovre>`_)
- Lukong Anne (`@Lukong123 <https://github.com/Lukong123>`_)
- Matt Schwennesen (`@mjschwenne <https://github.com/mjschwenne>`_)
- Matthew Feickert (`@matthewfeickert <https://github.com/matthewfeickert>`_)
- Matthias Bussonnier (`@Carreau <https://github.com/Carreau>`_)
- Mohamed Rezk (`@mohamedrezk122 <https://github.com/mohamedrezk122>`_)
- Mridul Seth (`@MridulS <https://github.com/MridulS>`_)
- Navya Agarwal (`@navyagarwal <https://github.com/navyagarwal>`_)
- Nishant Bhansali (`@nishantb06 <https://github.com/nishantb06>`_)
- Omkar Yadav (`@yadomkar <https://github.com/yadomkar>`_)
- Paul Brodersen (`@paulbrodersen <https://github.com/paulbrodersen>`_)
- Paula Pérez Bianchi (`@paulitapb <https://github.com/paulitapb>`_)
- Pieter Eendebak (`@eendebakpt <https://github.com/eendebakpt>`_)
- Pieter Kuppens (`@pkuppens <https://github.com/pkuppens>`_)
- Purvi Chaurasia (`@PurviChaurasia <https://github.com/PurviChaurasia>`_)
- Ross Barnowski (`@rossbar <https://github.com/rossbar>`_)
- Salim BELHADDAD (`@salym <https://github.com/salym>`_)
- Sebastiano Vigna (`@vigna <https://github.com/vigna>`_)
- Siri (`@sirichandana-v <https://github.com/sirichandana-v>`_)
- Stefan van der Walt (`@stefanv <https://github.com/stefanv>`_)
- Sultan Orazbayev (`@SultanOrazbayev <https://github.com/SultanOrazbayev>`_)
- Vanshika Mishra (`@vanshika230 <https://github.com/vanshika230>`_)
- William Zijie Zhang (`@Transurgeon <https://github.com/Transurgeon>`_)
- Yaroslav Halchenko (`@yarikoptic <https://github.com/yarikoptic>`_)
- Zhaoyuan Deng (`@dzy49 <https://github.com/dzy49>`_)
41 reviewers added to this release (alphabetically):
- `@gsemer <https://github.com/gsemer>`_
- `@IbrH <https://github.com/IbrH>`_
- `@peijenburg <https://github.com/peijenburg>`_
- `@Tortar <https://github.com/Tortar>`_
- Aaron Z. (`@aaronzo <https://github.com/aaronzo>`_)
- Adam Li (`@adam2392 <https://github.com/adam2392>`_)
- Adam Richardson (`@AdamWRichardson <https://github.com/AdamWRichardson>`_)
- Alimi Qudirah (`@Qudirah <https://github.com/Qudirah>`_)
- Andreas Wilm (`@andreas-wilm <https://github.com/andreas-wilm>`_)
- Anthony Labarre (`@alabarre <https://github.com/alabarre>`_)
- Dan Schult (`@dschult <https://github.com/dschult>`_)
- Davide Bonin (`@davidbonin92 <https://github.com/davidbonin92>`_)
- Dilara Tekinoglu (`@dtekinoglu <https://github.com/dtekinoglu>`_)
- Efrem Braun (`@EfremBraun <https://github.com/EfremBraun>`_)
- Eirini Kafourou (`@eirinikafourou <https://github.com/eirinikafourou>`_)
- Eran Rivlis (`@erivlis <https://github.com/erivlis>`_)
- Erik Welch (`@eriknw <https://github.com/eriknw>`_)
- Evgenia Pampidi (`@evgepab <https://github.com/evgepab>`_)
- Ian Thompson (`@it176131 <https://github.com/it176131>`_)
- James Trimble's ONS work (`@jtrim-ons <https://github.com/jtrim-ons>`_)
- Jarrod Millman (`@jarrodmillman <https://github.com/jarrodmillman>`_)
- Jim Kitchen (`@jim22k <https://github.com/jim22k>`_)
- Jordan Matelsky (`@j6k4m8 <https://github.com/j6k4m8>`_)
- Josh Soref (`@jsoref <https://github.com/jsoref>`_)
- Kelly Boothby (`@boothby <https://github.com/boothby>`_)
- Lukong Anne (`@Lukong123 <https://github.com/Lukong123>`_)
- Matt Schwennesen (`@mjschwenne <https://github.com/mjschwenne>`_)
- Matthew Feickert (`@matthewfeickert <https://github.com/matthewfeickert>`_)
- Matthias Bussonnier (`@Carreau <https://github.com/Carreau>`_)
- Mridul Seth (`@MridulS <https://github.com/MridulS>`_)
- Navya Agarwal (`@navyagarwal <https://github.com/navyagarwal>`_)
- Nishant Bhansali (`@nishantb06 <https://github.com/nishantb06>`_)
- Orion Sehn (`@OrionSehn-personal <https://github.com/OrionSehn-personal>`_)
- Purvi Chaurasia (`@PurviChaurasia <https://github.com/PurviChaurasia>`_)
- Robert (`@ImHereForTheCookies <https://github.com/ImHereForTheCookies>`_)
- Ross Barnowski (`@rossbar <https://github.com/rossbar>`_)
- Salim BELHADDAD (`@salym <https://github.com/salym>`_)
- Sebastiano Vigna (`@vigna <https://github.com/vigna>`_)
- Sultan Orazbayev (`@SultanOrazbayev <https://github.com/SultanOrazbayev>`_)
- Vanshika Mishra (`@vanshika230 <https://github.com/vanshika230>`_)
- Yaroslav Halchenko (`@yarikoptic <https://github.com/yarikoptic>`_)
_These lists are automatically generated, and may not be complete or may contain
duplicates._
---
### Doc Release Release 3.3 (`doc/release/release_3.3.rst`)
NetworkX 3.3
============
Release date: 6 April 2024
Supports Python 3.10, 3.11, and 3.12.
NetworkX is a Python package for the creation, manipulation, and study of the
structure, dynamics, and functions of complex networks.
For more information, please visit our `website <https://networkx.org/>`_
and our :ref:`gallery of examples <examples_gallery>`.
Please send comments and questions to the `networkx-discuss mailing list
<http://groups.google.com/group/networkx-discuss>`_.
API Changes
-----------
- Disallow negative number of nodes in ``complete_multipartite_graph`` (`#7057 <https://github.com/networkx/networkx/pull/7057>`_).
- DEP: Deprecate the all_triplets one-liner (`#7060 <https://github.com/networkx/networkx/pull/7060>`_).
- [A-star] Added expansion pruning via cutoff if cutoff is provided (`#7073 <https://github.com/networkx/networkx/pull/7073>`_).
- Make HITS raise exceptions consistent with power iterations (`#7084 <https://github.com/networkx/networkx/pull/7084>`_).
- DEP: Deprecate random_triad (`#7061 <https://github.com/networkx/networkx/pull/7061>`_).
- Added feature modular graph product (`#7227 <https://github.com/networkx/networkx/pull/7227>`_).
- ENH: Speed up common/non_neighbors by using _adj dict operations (`#7244 <https://github.com/networkx/networkx/pull/7244>`_).
- Deprecate the ``create`` argument of ``nonisomorphic_trees`` (`#7316 <https://github.com/networkx/networkx/pull/7316>`_).
- Improve total_spanning_tree_weight (`#7100 <https://github.com/networkx/networkx/pull/7100>`_).
- Update __init__.py (`#7320 <https://github.com/networkx/networkx/pull/7320>`_).
- add \*\*kwargs to traveling_salesman_problem (`#7371 <https://github.com/networkx/networkx/pull/7371>`_).
Enhancements
------------
- Add Tadpole graph (`#6999 <https://github.com/networkx/networkx/pull/6999>`_).
- [A-star] Added expansion pruning via cutoff if cutoff is provided (`#7073 <https://github.com/networkx/networkx/pull/7073>`_).
- Implementation of $S^1$ model (`#6858 <https://github.com/networkx/networkx/pull/6858>`_).
- [Feat] Random expanders utilities (`#6761 <https://github.com/networkx/networkx/pull/6761>`_).
- Compare graphs for generator functions when running tests with backend (`#7066 <https://github.com/networkx/networkx/pull/7066>`_).
- Add Kirchhoff index / Effective graph resistance (`#6926 <https://github.com/networkx/networkx/pull/6926>`_).
- Changed return types of shortest path methods to improve consistency (`#6584 <https://github.com/networkx/networkx/pull/6584>`_).
- New PR for Fixes minimal d-separator function failing to handle cases where no d-separators exist (`#7019 <https://github.com/networkx/networkx/pull/7019>`_).
- ENH : Provide non-normalized and normalized directed laplacian matrix calculation (`#7199 <https://github.com/networkx/networkx/pull/7199>`_).
- feat: drop the use of node attribute "first_nbr" in PlanarEmbedding (`#7202 <https://github.com/networkx/networkx/pull/7202>`_).
- Add functions to compute Schultz and Gutman Index (`#3709 <https://github.com/networkx/networkx/pull/3709>`_).
- Divisive community algorithms (`#5830 <https://github.com/networkx/networkx/pull/5830>`_).
- Added feature modular graph product (`#7227 <https://github.com/networkx/networkx/pull/7227>`_).
- ENH : added ``sort_neighbors`` to all functions in ``depth_first_search.py`` (`#7196 <https://github.com/networkx/networkx/pull/7196>`_).
- New graph generator for the Kneser graph (`#7146 <https://github.com/networkx/networkx/pull/7146>`_).
- Draw MultiDiGraph edges and labels qa7008 (`#7010 <https://github.com/networkx/networkx/pull/7010>`_).
- Use github actions to run a comparison benchmark (`#7268 <https://github.com/networkx/networkx/pull/7268>`_).
- BFS layout implementation (`#5179 <https://github.com/networkx/networkx/pull/5179>`_).
- Add ``max_level=`` argument to ``louvain_communities`` to limit macro-iterations (`#6909 <https://github.com/networkx/networkx/pull/6909>`_).
- Review and update ``@nx._dispatchable`` usage since 3.2.1 (`#7302 <https://github.com/networkx/networkx/pull/7302>`_).
- Transmogrify ``_dispatchable`` objects into functions (`#7298 <https://github.com/networkx/networkx/pull/7298>`_).
- fix: make ``PlanarEmbedding.copy()`` use ``add_edges_from()`` from parent (closes #7223) (`#7224 <https://github.com/networkx/networkx/pull/7224>`_).
- Allow seed of np.random instance to exactly produce arbitrarily large integers (`#6869 <https://github.com/networkx/networkx/pull/6869>`_).
- Improve total_spanning_tree_weight (`#7100 <https://github.com/networkx/networkx/pull/7100>`_).
- add seed to ``nx.generate_random_paths`` (`#7332 <https://github.com/networkx/networkx/pull/7332>`_).
- Allow backends to implement ``should_run`` (`#7257 <https://github.com/networkx/networkx/pull/7257>`_).
- Adding tree broadcasting algorithm in a new module (`#6928 <https://github.com/networkx/networkx/pull/6928>`_).
- Option to include initial labels in ``weisfeiler_lehman_subgraph_hashes`` (`#6601 <https://github.com/networkx/networkx/pull/6601>`_).
- Add better error message when trying to get edge that is not present (`#7245 <https://github.com/networkx/networkx/pull/7245>`_).
- Make ``is_negatively_weighted`` dispatchable (`#7352 <https://github.com/networkx/networkx/pull/7352>`_).
- Add option to hide or show tick labels (`#6018 <https://github.com/networkx/networkx/pull/6018>`_).
- ENH: Cache graphs objects when converting to a backend (`#7345 <https://github.com/networkx/networkx/pull/7345>`_).
Bug Fixes
---------
- Fix listing of release notes on Releases page (`#7030 <https://github.com/networkx/networkx/pull/7030>`_).
- Fix syntax warning from bad escape sequence (`#7034 <https://github.com/networkx/networkx/pull/7034>`_).
- Fix triangles to avoid using ``is`` to compare nodes (`#7041 <https://github.com/networkx/networkx/pull/7041>`_).
- Fix error message for ``nx.mycielski_graph(0)`` (`#7056 <https://github.com/networkx/networkx/pull/7056>`_).
- Disallow negative number of nodes in ``complete_multipartite_graph`` (`#7057 <https://github.com/networkx/networkx/pull/7057>`_).
- Handle edge cases for greedy_modularity_communities (`#6973 <https://github.com/networkx/networkx/pull/6973>`_).
- FIX: Match the doc description while copying over data (`#7092 <https://github.com/networkx/networkx/pull/7092>`_).
- fix: Include singleton/trivial paths in all_simple_paths & other functions (`#6694 <https://github.com/networkx/networkx/pull/6694>`_).
- Dinitz correction (`#6968 <https://github.com/networkx/networkx/pull/6968>`_).
- Modify GML test to fix invalid octal character warning (`#7159 <https://github.com/networkx/networkx/pull/7159>`_).
- Fix random_spanning_tree() for single node and empty graphs (`#7211 <https://github.com/networkx/networkx/pull/7211>`_).
- PlanarEmbedding.remove_edge() now updates removed edge's neighbors (`#6798 <https://github.com/networkx/networkx/pull/6798>`_).
- add seed to graph creation (`#7241 <https://github.com/networkx/networkx/pull/7241>`_).
- add seed to tests of fast_label_propatation_communities (`#7242 <https://github.com/networkx/networkx/pull/7242>`_).
- Fix rich_club_coefficient() for single node and empty graphs (`#7212 <https://github.com/networkx/networkx/pull/7212>`_).
- Fix minimum_spanning_arborescence regression (`#7280 <https://github.com/networkx/networkx/pull/7280>`_).
- Move arrowstyle input munging after input validation (`#7293 <https://github.com/networkx/networkx/pull/7293>`_).
- Fix empty GraphML attribute is not parsed (`#7319 <https://github.com/networkx/networkx/pull/7319>`_).
- Add new test result to ``test_asadpour_tsp`` and change ``linprog`` method (`#7335 <https://github.com/networkx/networkx/pull/7335>`_).
- Fix custom weight attribute for Mehlhorn (`#6681 <https://github.com/networkx/networkx/pull/6681>`_).
Documentation
-------------
- Update release process (`#7029 <https://github.com/networkx/networkx/pull/7029>`_).
- Update convert_matrix.py (`#7018 <https://github.com/networkx/networkx/pull/7018>`_).
- fix extendability function name in bipartite.rst (`#7042 <https://github.com/networkx/networkx/pull/7042>`_).
- Minor doc cleanups to remove doc build warnings (`#7048 <https://github.com/networkx/networkx/pull/7048>`_).
- DOC: Add example to generic_bfs_edges to demonstrate the ``neighbors`` param (`#7072 <https://github.com/networkx/networkx/pull/7072>`_).
- Hierarchical clustering layout gallery example (`#7058 <https://github.com/networkx/networkx/pull/7058>`_).
- Fixed an error in the documentation of the katz centrality (`#6294 <https://github.com/networkx/networkx/pull/6294>`_).
- Create 3d_rotation_anime.py (`#7025 <https://github.com/networkx/networkx/pull/7025>`_).
- DOC: Add docstrings to filter view functions (`#7086 <https://github.com/networkx/networkx/pull/7086>`_).
- DOC: Add docstrings to Filter mapping views (`#7075 <https://github.com/networkx/networkx/pull/7075>`_).
- DOCS: Fix internal links to other functions in isomorphvf2 (`#6706 <https://github.com/networkx/networkx/pull/6706>`_).
- added note for the triangle inequality case in TSP (`#6995 <https://github.com/networkx/networkx/pull/6995>`_).
- Add note about importance of testing to contributor guide (`#7103 <https://github.com/networkx/networkx/pull/7103>`_).
- Proposal to add centrality overview to mentored projects (`#7104 <https://github.com/networkx/networkx/pull/7104>`_).
- Improve documentation of Component Algorithms (`#5473 <https://github.com/networkx/networkx/pull/5473>`_).
- Add dot io to readwrite (`#5061 <https://github.com/networkx/networkx/pull/5061>`_).
- Add Python versions to release notes (`#7113 <https://github.com/networkx/networkx/pull/7113>`_).
- DOC: Turn on inline plots in graph generators docstrings (`#6401 <https://github.com/networkx/networkx/pull/6401>`_).
- Fix duplicate numbering in contributor guide (`#7116 <https://github.com/networkx/networkx/pull/7116>`_).
- DOC: remove unnecessary 'or' in planted_partition_graph (`#7115 <https://github.com/networkx/networkx/pull/7115>`_).
- DOC: Link methods in functions to base Graph methods/properties (`#7125 <https://github.com/networkx/networkx/pull/7125>`_).
- Connect docs to doc_string for total_spanning_tree_weight (`#7098 <https://github.com/networkx/networkx/pull/7098>`_).
- Image (3D RGB data) segmentation by spectral clustering with 3D illustrations (`#7040 <https://github.com/networkx/networkx/pull/7040>`_).
- update triadic_census documentation for undirected graphs - issue 4386 (`#7141 <https://github.com/networkx/networkx/pull/7141>`_).
- added 3d and animation to plot_greedy_coloring.py (`#7090 <https://github.com/networkx/networkx/pull/7090>`_).
- DOC: fix URL econded links and doc references (`#7152 <https://github.com/networkx/networkx/pull/7152>`_).
- DOC: add reference to fast_label_propagation_communities (`#7167 <https://github.com/networkx/networkx/pull/7167>`_).
- updated See also sec of argmap class (`#7163 <https://github.com/networkx/networkx/pull/7163>`_).
- DOC : updated examples in mincost.py (`#7169 <https://github.com/networkx/networkx/pull/7169>`_).
- Document the walk_type argument default in directed_laplacian and similar functions (`#7171 <https://github.com/networkx/networkx/pull/7171>`_).
- DOC: Add plots to classic graph generators docs (`#7114 <https://github.com/networkx/networkx/pull/7114>`_).
- Fix a tiny typo in ``structuralholes.py::local_constraint`` docstring (`#7198 <https://github.com/networkx/networkx/pull/7198>`_).
- Added ``subgraph_is_monomorphic`` and ``subgraph_monomorphisms_iter`` in docs (`#7197 <https://github.com/networkx/networkx/pull/7197>`_).
- Fix online docs for ``_dispatch`` (`#7194 <https://github.com/networkx/networkx/pull/7194>`_).
- DOC : Updated docs for panther_similarity (`#7175 <https://github.com/networkx/networkx/pull/7175>`_).
- Fix warnings when building docs (`#7195 <https://github.com/networkx/networkx/pull/7195>`_).
- Improve docs for optimal_edit_paths (`#7130 <https://github.com/networkx/networkx/pull/7130>`_).
- DOC: build with nx-parallel extra documentation information (`#7220 <https://github.com/networkx/networkx/pull/7220>`_).
- Fixed typo in tensor product documentation (Fixes #7228) (`#7229 <https://github.com/networkx/networkx/pull/7229>`_).
- Add example for cycle detection (`#6560 <https://github.com/networkx/networkx/pull/6560>`_).
- Update general_k_edge_subgraphs docstring (`#7254 <https://github.com/networkx/networkx/pull/7254>`_).
- Update docstring of nonisomorphic_trees (`#7255 <https://github.com/networkx/networkx/pull/7255>`_).
- adding self loops related docs and tests for functions in ``cluster.py`` (`#7261 <https://github.com/networkx/networkx/pull/7261>`_).
- Add minimum_cycle_basis to cycle_basis See Also (`#7274 <https://github.com/networkx/networkx/pull/7274>`_).
- Update CONTRIBUTING.rst (`#7270 <https://github.com/networkx/networkx/pull/7270>`_).
- Fix all sphinx warnings during doc build (`#7289 <https://github.com/networkx/networkx/pull/7289>`_).
- Doc infrastructure: replace ``nb2plot`` with ``myst-nb`` (`#7237 <https://github.com/networkx/networkx/pull/7237>`_).
- Add explicit targets of missing modules for intersphinx (`#7313 <https://github.com/networkx/networkx/pull/7313>`_).
- DOC: add doc suggestions for arbitrarily large random integers tools (`#7322 <https://github.com/networkx/networkx/pull/7322>`_).
- Try/except intermittently failing basemaps in geospatial examples (`#7324 <https://github.com/networkx/networkx/pull/7324>`_).
- Update docstring example with future-proof pandas assignment (`#7323 <https://github.com/networkx/networkx/pull/7323>`_).
- Remove animation from spectral clustering example to improve performance (`#7328 <https://github.com/networkx/networkx/pull/7328>`_).
- Doc Improvements for Approximations Files (`#7338 <https://github.com/networkx/networkx/pull/7338>`_).
- Update ``LCF_graph`` docstring (`#7262 <https://github.com/networkx/networkx/pull/7262>`_).
- Option to include initial labels in ``weisfeiler_lehman_subgraph_hashes`` (`#6601 <https://github.com/networkx/networkx/pull/6601>`_).
- Add eriknw as contributor (`#7343 <https://github.com/networkx/networkx/pull/7343>`_).
- [DOC, DISPATCH] : updated and added ``backend.py``'s docs (`#7305 <https://github.com/networkx/networkx/pull/7305>`_).
- add \*\*kwargs to traveling_salesman_problem (`#7371 <https://github.com/networkx/networkx/pull/7371>`_).
- Move the backend docs and connect the config docs. Both in a single sidebar entry (`#7389 <https://github.com/networkx/networkx/pull/7389>`_).
Maintenance
-----------
- Drop Python 3.9 support (`#7028 <https://github.com/networkx/networkx/pull/7028>`_).
- fix: Explicitly check for None/False in edge_attr during import from np (`#6825 <https://github.com/networkx/networkx/pull/6825>`_).
- Add favicon (`#7043 <https://github.com/networkx/networkx/pull/7043>`_).
- Remove unused code resistance_distance (`#7053 <https://github.com/networkx/networkx/pull/7053>`_).
- Fix names of small graphs (`#7055 <https://github.com/networkx/networkx/pull/7055>`_).
- Improve error messages for misconfigured backend treatment (`#7062 <https://github.com/networkx/networkx/pull/7062>`_).
- MAINT: Fixup union exception message (`#7071 <https://github.com/networkx/networkx/pull/7071>`_).
- MAINT: Minor touchups to tadpole and lollipop graph (`#7049 <https://github.com/networkx/networkx/pull/7049>`_).
- Add ``@not_implemented_for("directed")`` to ``number_connected_components`` (`#7074 <https://github.com/networkx/networkx/pull/7074>`_).
- remove unused code (`#7076 <https://github.com/networkx/networkx/pull/7076>`_).
- Minor touchups to the beamsearch module (`#7059 <https://github.com/networkx/networkx/pull/7059>`_).
- Fix annoying split strings on same line (`#7079 <https://github.com/networkx/networkx/pull/7079>`_).
- Update dispatch decorator for ``hits`` to use ``"weight"`` edge weight (`#7081 <https://github.com/networkx/networkx/pull/7081>`_).
- Remove nbconvert upper pin (revert #6984) (`#7083 <https://github.com/networkx/networkx/pull/7083>`_).
- Add a step to CI to check for warnings at import time (`#7077 <https://github.com/networkx/networkx/pull/7077>`_).
- Added few tests for /generators/duplication.py and /generators/geomet… (`#6976 <https://github.com/networkx/networkx/pull/6976>`_).
- Test on Python 3.13-dev (`#7096 <https://github.com/networkx/networkx/pull/7096>`_).
- Changed arguments list of GraphMLWriterLxml.dump() (`#6261 <https://github.com/networkx/networkx/pull/6261>`_).
- ``write_graphml``: Small fix for object type description on ``TypeError`` exception (`#7109 <https://github.com/networkx/networkx/pull/7109>`_).
- updated functions in ``core.py`` (`#7027 <https://github.com/networkx/networkx/pull/7027>`_).
- label check on push and change check name (`#7111 <https://github.com/networkx/networkx/pull/7111>`_).
- DEP : adding ``not_implemented_for("multigraph”)`` to ``k_core``, ``k_shell``, ``k_crust`` and ``k_corona`` (`#7121 <https://github.com/networkx/networkx/pull/7121>`_).
- Add label check when pull request is edited instead of push (`#7134 <https://github.com/networkx/networkx/pull/7134>`_).
- Add label workflow pull_request type synchronize and echo message (`#7135 <https://github.com/networkx/networkx/pull/7135>`_).
- adding test coverage for isomorphism when using digraphs (`#6417 <https://github.com/networkx/networkx/pull/6417>`_).
- Remove usage of ``__networkx_plugin__`` (use ``__networkx_backend__`` instead) (`#7157 <https://github.com/networkx/networkx/pull/7157>`_).
- DOC: consistent spelling of neighbor and rename vars (`#7162 <https://github.com/networkx/networkx/pull/7162>`_).
- MAINT: use ruff format instead of black (`#7160 <https://github.com/networkx/networkx/pull/7160>`_).
- Ensure warnings related to changes in shortest_path returns are visible to users (`#7161 <https://github.com/networkx/networkx/pull/7161>`_).
- Sync up behavior of is_{type} for empty graphs (`#5849 <https://github.com/networkx/networkx/pull/5849>`_).
- Added ``NodeNotFound`` exceptions to ``_apply_prediction`` and ``simrank``, and ignored isolated nodes in ``panther_similarity`` (`#7110 <https://github.com/networkx/networkx/pull/7110>`_).
- Fix not_implemented_for decorator for is_regular and related functions (`#7182 <https://github.com/networkx/networkx/pull/7182>`_).
- Fix all_node_cuts output for complete graphs (`#6558 <https://github.com/networkx/networkx/pull/6558>`_).
- Remove ``"networkx.plugins"`` and ``"networkx.plugin_info"`` entry-points (`#7192 <https://github.com/networkx/networkx/pull/7192>`_).
- Bump actions/setup-python from 4 to 5 (`#7201 <https://github.com/networkx/networkx/pull/7201>`_).
- Update test suite for Pytest v8 (`#7203 <https://github.com/networkx/networkx/pull/7203>`_).
- Undeprecate ````nx_pydot```` now that pydot is actively maintained again (`#7204 <https://github.com/networkx/networkx/pull/7204>`_).
- Future-proofing and improve tests (`#7209 <https://github.com/networkx/networkx/pull/7209>`_).
- Drop old dependencies per SPEC 0 (`#7217 <https://github.com/networkx/networkx/pull/7217>`_).
- Update pygraphviz (`#7216 <https://github.com/networkx/networkx/pull/7216>`_).
- Refactor geometric_soft_configuration_model tests for performance (`#7210 <https://github.com/networkx/networkx/pull/7210>`_).
- Rename ``_dispatch`` to ``_dispatchable`` (`#7193 <https://github.com/networkx/networkx/pull/7193>`_).
- Replace tempfile with tmp_path fixture in test suite (`#7221 <https://github.com/networkx/networkx/pull/7221>`_).
- updated test_directed_edge_swap #5814 (`#6426 <https://github.com/networkx/networkx/pull/6426>`_).
- Bump copyright year for 2024 (`#7232 <https://github.com/networkx/networkx/pull/7232>`_).
- Improving test coverage for Small.py (`#7260 <https://github.com/networkx/networkx/pull/7260>`_).
- Test for symmetric edge flow betweenness partition (`#7251 <https://github.com/networkx/networkx/pull/7251>`_).
- MAINT : added ``seed`` to ``gnm_random_graph`` in ``community/tests/test_label_propagation.py`` (`#7264 <https://github.com/networkx/networkx/pull/7264>`_).
- Bump scientific-python/upload-nightly-action from 0.2.0 to 0.3.0 (`#7266 <https://github.com/networkx/networkx/pull/7266>`_).
- adding self loops related docs and tests for functions in ``cluster.py`` (`#7261 <https://github.com/networkx/networkx/pull/7261>`_).
- Improving test coverage for Mycielsky.py (`#7271 <https://github.com/networkx/networkx/pull/7271>`_).
- Use ruff's docstring formatting (`#7276 <https://github.com/networkx/networkx/pull/7276>`_).
- Add docstring formatting change to blame-ignore-revs (`#7281 <https://github.com/networkx/networkx/pull/7281>`_).
- Improve test coverage for random_clustered and update function names (`#7273 <https://github.com/networkx/networkx/pull/7273>`_).
- Doc infrastructure: replace ``nb2plot`` with ``myst-nb`` (`#7237 <https://github.com/networkx/networkx/pull/7237>`_).
- Temporarily rm geospatial examples to fix CI (`#7299 <https://github.com/networkx/networkx/pull/7299>`_).
- Improve test coverage for bipartite extendability (`#7306 <https://github.com/networkx/networkx/pull/7306>`_).
- CI: Update scientific-python/upload-nightly-action from 0.3.0 to 0.4.0 (`#7309 <https://github.com/networkx/networkx/pull/7309>`_).
- CI: Group dependabot updates (`#7308 <https://github.com/networkx/networkx/pull/7308>`_).
- CI: update upload-nightly-action to 0.5.0 (`#7311 <https://github.com/networkx/networkx/pull/7311>`_).
- renaming backend ``func_info`` dictionary's keys (`#7219 <https://github.com/networkx/networkx/pull/7219>`_).
- Add ``mutates_input=`` and ``returns_graph=`` to ``_dispatchable`` (`#7191 <https://github.com/networkx/networkx/pull/7191>`_).
- Avoid creating results with numpy scalars (re: NEP 51) (`#7282 <https://github.com/networkx/networkx/pull/7282>`_).
- Bump changelist from 0.4 to 0.5 (`#7325 <https://github.com/networkx/networkx/pull/7325>`_).
- Improve test coverage for bipartite matrix.py (`#7312 <https://github.com/networkx/networkx/pull/7312>`_).
- Un-dispatch coloring strategies (`#7329 <https://github.com/networkx/networkx/pull/7329>`_).
- Undo change in return type of ``single_target_shortest_path_length`` (`#7327 <https://github.com/networkx/networkx/pull/7327>`_).
- Remove animation from spectral clustering example to improve performance (`#7328 <https://github.com/networkx/networkx/pull/7328>`_).
- Expire steinertree mehlhorn futurewarning (`#7337 <https://github.com/networkx/networkx/pull/7337>`_).
- Update louvain test modularity comparison to leq (`#7336 <https://github.com/networkx/networkx/pull/7336>`_).
- Add aaronzo as contributor (`#7342 <https://github.com/networkx/networkx/pull/7342>`_).
- Fix #7339. ``shortest_path`` inconsisitent with warning (`#7341 <https://github.com/networkx/networkx/pull/7341>`_).
- Add ``nx.config`` dict for configuring dispatching and backends (`#7225 <https://github.com/networkx/networkx/pull/7225>`_).
- Improve test coverage for Steiner Tree & Docs (`#7348 <https://github.com/networkx/networkx/pull/7348>`_).
- added ``seed`` to ``test_richclub_normalized`` (`#7355 <https://github.com/networkx/networkx/pull/7355>`_).
- Add tests to link_prediction.py (`#7357 <https://github.com/networkx/networkx/pull/7357>`_).
- Fix pydot tests when testing backends (`#7356 <https://github.com/networkx/networkx/pull/7356>`_).
- Future proof xml parsing in graphml (`#7360 <https://github.com/networkx/networkx/pull/7360>`_).
- make doc_string examples order-independent by removing np.set_printoptions (`#7361 <https://github.com/networkx/networkx/pull/7361>`_).
- Close figures on test cleanup (`#7373 <https://github.com/networkx/networkx/pull/7373>`_).
- More numpy scalars cleanup for numpy 2.0 (`#7374 <https://github.com/networkx/networkx/pull/7374>`_).
- Update numpydoc (`#7364 <https://github.com/networkx/networkx/pull/7364>`_).
- Fix pygraphviz tests causing segmentation faults in backend test (`#7380 <https://github.com/networkx/networkx/pull/7380>`_).
- Add dispatching to broadcasting.py (`#7386 <https://github.com/networkx/networkx/pull/7386>`_).
- Update test suite to handle when scipy is not installed (`#7388 <https://github.com/networkx/networkx/pull/7388>`_).
- Rm deprecated np.row_stack in favor of vstack (`#7390 <https://github.com/networkx/networkx/pull/7390>`_).
- Fix exception for ``del config[key]`` (`#7391 <https://github.com/networkx/networkx/pull/7391>`_).
- Bump the GH actions with 3 updates (`#7310 <https://github.com/networkx/networkx/pull/7310>`_).
Contributors
------------
54 authors added to this release (alphabetically):
- `@BucketHeadP65 <https://github.com/BucketHeadP65>`_
- `@dependabot[bot] <https://github.com/apps/dependabot>`_
- `@nelsonaloysio <https://github.com/nelsonaloysio>`_
- `@YVWX <https://github.com/YVWX>`_
- Aaron Z. (`@aaronzo <https://github.com/aaronzo>`_)
- Aditi Juneja (`@Schefflera-Arboricola <https://github.com/Schefflera-Arboricola>`_)
- AKSHAYA MADHURI (`@akshayamadhuri <https://github.com/akshayamadhuri>`_)
- Alex Markham (`@Alex-Markham <https://github.com/Alex-Markham>`_)
- Anders Rydbirk (`@anders-rydbirk <https://github.com/anders-rydbirk>`_)
- Andrew Knyazev (`@lobpcg <https://github.com/lobpcg>`_)
- Ayooluwa (`@Ay-slim <https://github.com/Ay-slim>`_)
- Baldo (`@BrunoBaldissera <https://github.com/BrunoBaldissera>`_)
- Benjamin Edwards (`@bjedwards <ht