The documentation for retworkx has migrated to:
These docs will no longer be updated.
- floyd_warshall_numpy(graph, weight_fn=None, default_weight=1.0)[source]¶
- floyd_warshall_numpy(graph: retworkx.PyDiGraph, weight_fn=None, default_weight=1.0)
- floyd_warshall_numpy(graph: retworkx.PyGraph, weight_fn=None, default_weight=1.0)
Return the adjacency matrix for a graph object
In the case where there are multiple edges between nodes the value in the output matrix will be the sum of the edges’ weights.
graph – The graph used to generate the adjacency matrix from. Can either be a
weight_fn (callable) –
A callable object (function, lambda, etc) which will be passed the edge object and expected to return a
float. This tells retworkx/rust how to extract a numerical weight as a
floatfor edge object. Some simple examples are:
adjacency_matrix(graph, weight_fn: lambda x: 1)
to return a weight of 1 for all edges. Also:
adjacency_matrix(graph, weight_fn: lambda x: float(x))
to cast the edge object as a float as the weight. If this is not specified a default value (either
default_weightor 1) will be used for all edges.
default_weight (float) –
weight_fnis not used this can be
optionally used to specify a default weight to use for all edges.
The adjacency matrix for the input dag as a numpy array