affinity_to_edge_index#
- affinity_to_edge_index(affinity_matrix, threshold=0.5)[source]#
Convert an affinity matrix (similarity matrix) to an edge index.
Converts an NxN affinity matrix to a 2xM edge index, where M is the number of node pairs with a similarity greater than the threshold value (defaults to 0.5).
- Parameters:
- Returns:
The edge index of shape (2, M).
- Return type:
ArrayLike or torch.Tensor
Example
>>> points = np.random.rand(100, 2) >>> adjacency = delaunay_adjacency(points) >>> edge_index = affinity_to_edge_index(adjacency)