package sklearn

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
val get_py : string -> Py.Object.t

Get an attribute of this module as a Py.Object.t. This is useful to pass a Python function to another function.

val single_source_shortest_path_length : ?cutoff:int -> graph:[> `ArrayLike ] Np.Obj.t -> source:int -> unit -> Py.Object.t

Return the shortest path length from source to all reachable nodes.

Returns a dictionary of shortest path lengths keyed by target.

Parameters ---------- graph : sparse matrix or 2D array (preferably LIL matrix) Adjacency matrix of the graph source : integer Starting node for path cutoff : integer, optional Depth to stop the search - only paths of length <= cutoff are returned.

Examples -------- >>> from sklearn.utils.graph import single_source_shortest_path_length >>> import numpy as np >>> graph = np.array([ 0, 1, 0, 0], ... [ 1, 0, 1, 0], ... [ 0, 1, 0, 1], ... [ 0, 0, 1, 0]) >>> list(sorted(single_source_shortest_path_length(graph, 0).items())) (0, 0), (1, 1), (2, 2), (3, 3) >>> graph = np.ones((6, 6)) >>> list(sorted(single_source_shortest_path_length(graph, 2).items())) (0, 1), (1, 1), (2, 0), (3, 1), (4, 1), (5, 1)

OCaml

Innovation. Community. Security.