How to create a graph data structure in PyTorch?

I have a txt file has feature and coordinates for multiple rectangles (F, Xcenter , Ycenter , width, height). I would like to create an undirected graph network where the nodes of which stand for the rectangle and the edges of which represent distance between the rectangle centers. I used KNN but I couldn’t represent a node and assign a feature for each node.

txt file:


F(np array)     Xcenter       Ycenter    width     height
[23.4....]     0.568396      0.394130   0.176887  0.345912
[20.4....]     0.391509      0.393082   0.172170  0.327044
[18.1....]     0.717571      0.377358   0.119104  0.320755
[0.33....]     0.254717      0.373166   0.103774  0.299790

the code:

dataset = CustomDataset(transform= transforms.ToTensor())
for data in dataset:
  centroid, feature_vector, class_list = data
  data = Data(pos= centroid, x=feature_vector, num_classes=class_list) 
  transform =T.Compose([T.KNNGraph(k=3), T.Distance(norm=False)])
  data = transform(data)
  print(data)

the output:

Data(x=[], y=[17], pos=[17, 2], edge_index=[2, 51], edge_attr=[51, 1])