topobench.transforms.data_manipulations.infere_radius_connectivity module#
InfereRadiusConnectivity class definition.
- class InfereRadiusConnectivity(**kwargs)#
Bases:
BaseTransformClass to infer point cloud connectivity.
The transform generates the radius connectivity of the input point cloud.
- Parameters:
- **kwargsoptional
Parameters for the base transform.
- __init__(**kwargs)#
- forward(data)#
Apply the transform to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data.
- Returns:
- torch_geometric.data.Data
The transformed data.
- radius_graph(x, r, batch=None, loop=False, max_num_neighbors=32, flow='source_to_target', num_workers=1, batch_size=None)#
Computes graph edges to all points within a given distance.
- Parameters:
x (Tensor) – Node feature matrix \(\mathbf{X} \in \mathbb{R}^{N \times F}\).
r (float) – The radius.
batch (LongTensor, optional) – Batch vector \(\mathbf{b} \in {\{ 0, \ldots, B-1\}}^N\), which assigns each node to a specific example.
batchneeds to be sorted. (default:None)loop (bool, optional) – If
True, the graph will contain self-loops. (default:False)max_num_neighbors (int, optional) – The maximum number of neighbors to return for each element. If the number of actual neighbors is greater than
max_num_neighbors, returned neighbors are picked randomly. (default:32)flow (string, optional) – The flow direction when used in combination with message passing (
"source_to_target"or"target_to_source"). (default:"source_to_target")num_workers (int) – Number of workers to use for computation. Has no effect in case
batchis notNone, or the input lies on the GPU. (default:1)batch_size (int, optional) – The number of examples \(B\). Automatically calculated if not given. (default:
None)
- Return type:
LongTensor
import torch from torch_cluster import radius_graph x = torch.Tensor([[-1, -1], [-1, 1], [1, -1], [1, 1]]) batch = torch.tensor([0, 0, 0, 0]) edge_index = radius_graph(x, r=1.5, batch=batch, loop=False)