code: def single_source_shortest_path_length(graph, source, *, cutoff=None):
      """Return the length of the shortest path from source to all reachable nodes.
  
      Parameters
      ----------
      graph : {array-like, sparse matrix} of shape (n_nodes, n_nodes)
          Adjacency matrix of the graph. Sparse matrix of format LIL is
          preferred.
  
      source : int
         Start node for path.
  
      cutoff : int, default=None
          Depth to stop the search - only paths of length <= cutoff are returned.
  
      Returns
      -------
      paths : dict
          Reachable end nodes mapped to length of path from source,
          i.e. `{end: path_length}`.
  
      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, 0],
      ...                   [ 0, 0, 0, 0]])
      >>> single_source_shortest_path_length(graph, 0)
      {0: 0, 1: 1, 2: 2}
      >>> graph = np.ones((6, 6))
      >>> sorted(single_source_shortest_path_length(graph, 2).items())
      [(0, 1), (1, 1), (2, 0), (3, 1), (4, 1), (5, 1)]
      """
      if sparse.issparse(graph):
          graph = graph.tolil()
      else:
          graph = sparse.lil_matrix(graph)
      seen = {}  # level (number of hops) when seen in BFS
      level = 0  # the current level
      next_level = [source]  # dict of nodes to check at next level
      while next_level:
          this_level = next_level  # advance to next level
          next_level = set()  # and start a new list (fringe)
          for v in this_level:
              if v not in seen:
                  seen[v] = level  # set the level of vertex v
                  next_level.update(graph.rows[v])
          if cutoff is not None and cutoff <= level:
              break
          level += 1
      return seen
  
imports: import numpy
  from scipy import sparse
  from ..metrics.pairwise import pairwise_distances
  from ._param_validation import Integral, Interval, validate_params
label_desc: Use image node_id 1 for calling a global function with example usage: single_source_shortest_path_length(graph, source) and returns: seen