cugraph.shortest_path_length#
- cugraph.shortest_path_length(G, source, target=None)[source]#
Compute the distance from a source vertex to one or all vertexes in graph. Uses Single Source Shortest Path (SSSP).
- Parameters:
- graphcuGraph.Graph, NetworkX.Graph, or CuPy sparse COO matrix
cuGraph graph descriptor with connectivity information. Edge weights, if present, should be single or double precision floating point values.
- sourceDependant on graph type. Index of the source vertex.
- If graph is an instance of cuGraph.Graph or CuPy sparse COO matrix:
int
- If graph is an instance of a NetworkX.Graph:
str
- target: Dependant on graph type. Vertex to find distance to.
- If graph is an instance of cuGraph.Graph or CuPy sparse COO matrix:
int
- If graph is an instance of a NetworkX.Graph:
str
- Returns:
- Return value type is based on the input type.
- If target is None, returns:
- cudf.DataFrame
- df[‘vertex’]
vertex id
- df[‘distance’]
gives the path distance from the starting vertex
- If target is not None, returns:
Distance from source to target vertex.