Toggle Menu
Prev Up Next

scikit-learn 1.3.2
Other versions

Please cite us if you use the software.

# `sklearn.neighbors`.sort_graph_by_row_values

sklearn.neighbors.sort_graph_by_row_values(graph, copy=False, warn_when_not_sorted=True)

  Sort a sparse graph such that each row is stored with increasing values.

  New in version 1.2.

  Parameters:
    graph sparse matrix of shape (n_samples, n_samples)

      Distance matrix to other samples, where only non-zero elements are considered neighbors. Matrix is converted to CSR format if not already.

    copy bool, default=False

      If True, the graph is copied before sorting. If False, the sorting is performed inplace. If the graph is not of CSR format, `copy` must be True to allow the conversion to CSR format, otherwise an error is raised.

    warn_when_not_sorted bool, default=True

      If True, a `EfficiencyWarning` is raised when the input graph is not sorted by row values.

  Returns:
    graph sparse matrix of shape (n_samples, n_samples)

      Distance matrix to other samples, where only non-zero elements are considered neighbors. Matrix is in CSR format.