-
graphicle.matrix.knn_adj(matrix: ndarray[Any, dtype[float64]], k: int, self_loop: bool =
False, weighted: bool =False, row: bool =True, dtype: dtype[Any] | None | type[Any] | _SupportsDType[dtype[Any]] | str | tuple[Any, int] | tuple[Any, SupportsIndex | collections.abc.Sequence[SupportsIndex]] | list[Any] | _DTypeDict | tuple[Any, Any] =None) ndarray[Any, dtype[float64]][source] Produce a directed adjacency matrix with outward edges towards the
knearest neighbours, determined from the input affinitymatrix.New in version 0.1.0.
- Parameters:¶
- matrix : ndarray[float64]¶
2D matrix of Particle affinities.
- k : int¶
Number of nearest neighbours in result.
- weighted : bool¶
If
Trueedges weighted by affinity, ifFalseedge is binary. Default isFalse.- self_loop : bool¶
If
Falsewill remove self-edges. Default isFalse.- row : bool¶
If
Trueoutward edges given by rows, ifFalsecols. Default isTrue.- dtype : dtype-like, optional¶
Type of output. Must be floating point if weighted is
True.
- Returns:¶
adj – Adjacency matrix representing particle connectivity.
- Return type:¶
ndarray[bool_] or ndarray[float64]
Notes
If weighted is
False, the returned adjacency matrix will be boolean.
Last update:
Jun 27, 2025