KNNGraph#
- class KNNGraph(pos, neighbours, **kwargs)[source]#
Bases:
GraphBuilderExtends the
GraphBuilderclass to computeedge_indexbased on a K-nearest neighbors algorithm.Instantiate the
Graphclass by computing theedge_indexbased on the K-nearest neighbors algorithm.- Parameters:
pos (torch.Tensor | LabelTensor) – A tensor of shape
(N, D)representing the positions ofNpoints inD-dimensional space.neighbours (int) – The number of nearest neighbors to consider when building the graph.
kwargs (dict) – The additional keyword arguments to be passed to
GraphBuilderandGraphclasses.
- Returns:
A
Graphinstance with the computededge_index.- Return type:
- static compute_knn_graph(points, neighbours)[source]#
Computes the
edge_indexbased on the K-nearest neighbors algorithm.- Parameters:
points (torch.Tensor | LabelTensor) – A tensor of shape
(N, D)representing the positions ofNpoints inD-dimensional space.neighbours (int) – The number of nearest neighbors to consider when building the graph.
- Returns:
A tensor of shape
(2, E), withEnumber of edges, representing the edge indices of the graph.- Return type: