Network.shortest_path

Network.shortest_path(weight=None, s=None, backward_edges: bool = False, backward_positive: bool = False, multiprocessing: bool = False, return_source_indices: bool = False)[source]

Compute shortest path wrt. weight.

Parameters
weightarray_like, optional

Edge weights, default: unit weight (1) for all edges.

sint or array_like, optional

If specified, only compute the paths originating at the given indices. Default: all nodes in edges.

backward_edgesbool, default=False

Whether to use separate entries in adjacency matrix H for undirected edges, i.e., H[s, t] = w and H[t, s] = w.

backward_positivebool, default=False

Whether to negate weight for undirected edges, i.e., H[s, t] = w and H[t, s] = -w.

multiprocessingbool, default=False

Whether to calculate D and Pr using multiple processes.

return_source_indicesbool, default=False

Whether to return dict that maps node_id in s to indices in return matrices D and Pr.

Returns
Dndarray

Distance matrix.

Pr: ndarray

Predecessor matrix.

dict, optional

Mapping of node_id in s to indices in D and Pr if return_source_indices is True.

See also

paminco.net.shared.Shared.csgraph

Setup of adjacency matrix used to find shortest path.

scipy.sparse.csgraph.dijkstra

Shortest path computation.