mindscience.e3nn.utils.radius_graph
- mindscience.e3nn.utils.radius_graph(x, r, batch=None, loop=False, max_num_neighbors=32, flow='source_to_target')[source]
Computes graph edges to all points within a given distance.
- Parameters
x (ndarray) – node feature matrix.
r (Union[ndarray, float]) – the radius.
batch (ndarray, optional) – batch vector. If it is none, then calculate and return. Default:
None.loop (bool, optional) – whether contain self-loops in the graph. Default:
False.max_num_neighbors (int, optional) – The maximum number of neighbors to return for each element in y. Default:
32.flow (str, optional) – {'source_to_target', 'target_to_source'}, the flow direction when using in combination with message passing. Default:
'source_to_target'.
- Returns
edge_index (numpy.ndarray) - including edges of source and destination.
batch (numpy.ndarray) - batch vector.
- Raises
ValueError – If flow is not in {'source_to_target', 'target_to_source'}.
Examples
>>> from mindscience.e3nn.utils import radius_graph >>> import numpy as np >>> np.random.seed(1) >>> x = np.random.random((5, 12, 3)) >>> r = 0.5 >>> edge_index, batch = radius_graph(x, r) >>> print(edge_index.shape) (2, 162) >>> print(batch.shape) (60,)