retworkx 0.6.0
This release includes a number of new features and bug fixes. The main focus of this release was to expand the retworkx API functionality to include some commonly needed functions that were missing.
This release is also the first release to provide full support for running with Python 3.9. On previous releases Python 3.9 would likely work, but it would require building retworkx from source. Also this will likely be the final release that supports Python 3.5.
Added
- Two new functions,
digraph_k_shortest_path()
andgraph_k_shortest_path()
, for finding the k shortest path lengths from a node in aPyDiGraph
andPyGraph
. - A new method,
is_symmetric()
, to thePyDiGraph
class. This method will check whether the graph is symmetric or not - A new kwarg,
as_undirected
, was added to thedigraph_floyd_warshall_numpy()
function. This can be used to treat the inputPyDiGraph
object as if it was undirected for the generated output matrix. - A new function,
digraph_find_cycle()
, which will return the first cycle during a depth first search of aPyDiGraph
object. - Two new functions,
directed_gnm_random_graph()
andundirected_gnm_random_graph()
, for generating random G(n, m) graphs. - A new method,
remove_edges_from()
, was added toPyDiGraph
andPyGraph
. This can be used to remove multiple edges from a graph object in a single call. - A new method,
subgraph()
, was added toPyDiGraph
andPyGraph
which takes in a list of node indices and will return a new object of the same type representing a subgraph containing the node indices in that list. - Added support for running with Python 3.9
- A new method,
to_undirected(), was added to
PyDiGraph. This method will generate an undirected
PyGraphobject from the
PyDiGraph` object. - A new kwarg,
bidirectional
, was added to the directed generator functionsdirected_cycle_graph()
,directed_path_graph()
, anddirected_star_graph()
. When set toTrue
the directed graphs generated by these functions will add edges in both directions. - Added two new functions,
is_weakly_connected()
andweakly_connected_components()
, which will either check if aPyDiGraph
object is weakly connected or return the list of the weakly connected components of an inputPyDiGraph
. - The
weight_fn
kwarg forgraph_adjacency_matrix()
,digraph_adjacency_matrix()
,graph_floyd_warshall_numpy()
, anddigraph_floyd_warshall_numpy()
is now optional. Previously it always had to be specified when calling these function. But instead you can now rely on a default weight float (which defaults to 1.0) to be used for all the edges in the graph. - Add a
neighbors()
method toPyGraph
andPyDiGraph
. This function will return the node indices of the neighbor nodes for a given input node. - Two new methods,
successor_indices()
andpredecessor_indices()
, were added toPyDiGraph
. These methods will return the node indices for the successor and predecessor nodes of a given input node. - Two new functions,
graph_distance_matrix()
anddigraph_distance_matrix()
, were added for generating a distance matrix from an inputPyGraph
andPyDiGraph
. - Two new functions,
digraph_dijkstra_shortest_paths()
andgraph_dijkstra_shortest_path()
, were added for returning the shortest
paths from a node in aPyDiGraph
and aPyGraph
object. - Two new methods,
insert_node_on_in_edges()
andinsert_node_on_out_edges()
, were added toPyDiGraph
. These functions
are used to insert an existing node in between an reference node and all it's predecessors or successors. - Two new functions,
graph_dfs_edges()
anddigraph_dfs_edges()
, were added to get an edge list in depth first order from aPyGraph
and
PyDiGraph
.
Upgrade
- The numpy arrays returned by
graph_floyd_warshall_numpy()
,digraph_floyd_warshall_numpy()
,digraph_adjacency_matrix()
, andgraph_adjacency_matrix()
will now be in a contiguous C array memory layout. Previously they would return arrays in a column-major fortran layout. This was change was made to make it easier to interface the arrays returned by these functions with other C Python extensions. There should be no change when interacting with the numpy arrays via numpy's API. - The
bfs_successors()
method now returns an object of a custom typeBFSSuccessors
instead of a list. TheBFSSuccessors
type implements the Python sequence protocol so it can be used in place like a list (except for where explicit type checking is used). This was done to defer the type conversion between Rust and Python since doing it all at once can be a performance bottleneck especially for large graphs. TheBFSSuccessors
class will only do the type conversion when an element is accessed.
Fixes
- When pickling
PyDiGraph
objects the original node indices will be preserved across the pickle. - The random gnp functions,
directed_gnp_random_graph()
andundirected_gnp_random_graph()
, will now also handle exact 0 or 1
probabilities. Previously it would fail in these cases. Fixes #172