test_saint.py 432 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
4
5
6
7
import pytest
import torch
from torch_sparse.tensor import SparseTensor

from .utils import devices


rusty1s's avatar
rusty1s committed
8
@pytest.mark.parametrize('device', devices)
rusty1s's avatar
rusty1s committed
9
def test_saint_subgraph(device):
rusty1s's avatar
rusty1s committed
10
11
12
13
14
    row = torch.tensor([0, 0, 1, 1, 2, 2, 2, 3, 3, 4])
    col = torch.tensor([1, 2, 0, 2, 0, 1, 3, 2, 4, 3])
    adj = SparseTensor(row=row, col=col).to(device)
    node_idx = torch.tensor([0, 1, 2])

rusty1s's avatar
rusty1s committed
15
    adj, edge_index = adj.saint_subgraph(node_idx)