scipy.sparse.csgraph.depth_first_order¶

scipy.sparse.csgraph.
depth_first_order
(csgraph, i_start, directed=True, return_predecessors=True)¶ Return a depthfirst ordering starting with specified node.
Note that a depthfirst order is not unique. Furthermore, for graphs with cycles, the tree generated by a depthfirst search is not unique either.
New in version 0.11.0.
Parameters:  csgraph : array_like or sparse matrix
The N x N compressed sparse graph. The input csgraph will be converted to csr format for the calculation.
 i_start : int
The index of starting node.
 directed : bool, optional
If True (default), then operate on a directed graph: only move from point i to point j along paths csgraph[i, j]. If False, then find the shortest path on an undirected graph: the algorithm can progress from point i to j along csgraph[i, j] or csgraph[j, i].
 return_predecessors : bool, optional
If True (default), then return the predecesor array (see below).
Returns:  node_array : ndarray, one dimension
The depthfirst list of nodes, starting with specified node. The length of node_array is the number of nodes reachable from the specified node.
 predecessors : ndarray, one dimension
Returned only if return_predecessors is True. The lengthN list of predecessors of each node in a depthfirst tree. If node i is in the tree, then its parent is given by predecessors[i]. If node i is not in the tree (and for the parent node) then predecessors[i] = 9999.