xnn.common.models.ops.build_triplets#
- xnn.common.models.ops.build_triplets(edge_index, num_nodes)[source]#
Enumerate neighbour pairs
(j, k)sharing a centrei.For every centre atom, all unordered pairs of its incoming edges are returned. Fully vectorised (no Python loop over atoms): edges are grouped by their destination (centre) node and, within each group of
cedges, thec*(c-1)/2pairs are enumerated with a shared lower-triangular index template – the same schemetorchaniuses. Used by the angular descriptors of thednnfamily (ANI / HDNNP) and by the valence-angle enumeration of theffnnfamily (ReaxFF).- Parameters:
edge_index (Tensor) – Edge index of shape
(2, E); row 0 is the source (neighbour) and row 1 the destination (centre) node of each edge.num_nodes (int) – Number of atoms (nodes) in the graph.
- Returns:
(edge_jk_first, edge_jk_second, center), each of shape(T,)whereTis the number of triplets. The first two index into the edge dimension (the two edges forming a triplet,first < secondin the per-centre ordering) andcenteris the shared centre node. All three are empty long tensors when no triplet exists.- Return type:
tuple[Tensor, Tensor, Tensor]