xnn.common.data.neighborlist.nearest_edges#

xnn.common.data.neighborlist.nearest_edges(dist, dst, num_nodes, k)[source]#

The edges to the k nearest neighbors of every receiving atom.

Parameters:
  • dist (Tensor or callable) – Edge lengths (E,), or a function without arguments that returns them, called only when edges have to be dropped.

  • dst (Tensor) – Receiving atom of every edge (E,).

  • num_nodes (int) – Number of atoms.

  • k (int) – Neighbors kept per atom; an atom with fewer keeps all of them.

Returns:

  • keep (Tensor or None) – Indices of the kept edges, grouped by receiving atom and, where an atom had more than k, by length (edges of equal length keep their order in the neighbor list); None keeps every edge where it is (with per_atom, the edges are already grouped by receiving atom).

  • per_atom (int or None) – The number of kept edges of every atom when it is the same for all: the kept edges are then a table of per_atom rows per atom.

Return type:

Tuple[Tensor | None, int | None]