rllm.transforms.graph_transforms.KNNGraph¶
- class rllm.transforms.graph_transforms.KNNGraph(num_neighbors: int | None = 6, mode: str | None = 'connectivity', metric: str | None = 'minkowski', p: int | None = 2, metric_params: dict | None = None, include_self: bool | None = False, n_jobs: int = 1)[source]¶
Bases:
EdgeTransformBuilds a k-NN adjacency matrix from node features.
- Parameters:
num_neighbors (int, optional) – The number of neighbors. (default: 6)
mode (str[connectivity, distance], optional) – Type of returned matrix: connectivity will return the connectivity matrix with ones and zeros, while distance will return the distances between neighbors according to the given metric. (default: connectivity)
metric (str[minkowski, cosine, l1, l2, …], optional) – Metric to use for distance computation. Default is minkowski, which results in the standard Euclidean distance when p = 2. (default: minkowski)
p (float) – Power parameter for the Minkowski metric (default: 2).
metric_params (dict, optional) – Additional keyword arguments for the metric function. (default:
None)include_self (bool, optional) – If set to
True, the graph will contain self-loops. (default:False)n_jobs (int) – Number of workers to use for computation. (default: 1)