sklearn.neighbors
.sort_graph_by_row_values¶
- sklearn.neighbors.sort_graph_by_row_values(graph, copy=False, warn_when_not_sorted=True)[source]¶
Sort a sparse graph such that each row is stored with increasing values.
New in version 1.2.
- Parameters:
- graphsparse 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.
- copybool, 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_sortedbool, default=True
If True, a
EfficiencyWarning
is raised when the input graph is not sorted by row values.
- Returns:
- graphsparse 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.