Adjacency matrix of a block is not symmetric

As the subject suggests, I was wondering if it’s possible to make the adjacency matrix of a block come out as symmetric (of dimension |dstnode| x |dstnode|). Currently, when I use it, the shape will be |srcsnodes| x |srcnodes|.

To reproduce this issue :

import numpy as np
import networkx as nx 
import matplotlib.pyplot as plt
import torch
import dgl 

src_ids = [2,5,2,2,6,9,1,9,2,2,1,2,2, 3,5,]
dst_ids = [3,9,0,8,8,8,10,1,4,7,7,6,10, 8, 8]

g = dgl.to_bidirected(dgl.graph((src, dst))) 
sampler = dgl.dataloading.NeighborSampler([2,2])
sampler = dgl.dataloading.as_edge_prediction_sampler(
train_dataloader = dgl.dataloading.DataLoader(
        g, torch.arange(g.num_edges()), sampler,
        device='cpu', batch_size=2, shuffle=True,
        drop_last=False, num_workers=0, use_uva=False)
_, _, _ , blocks = next(iter(train_dataloader))
>> torch.Size([12, 9])

You can simply resize it if you want a square matrix.

num_src = adj.size(0)
adj.sparse_resize_((num_src, num_src), adj.sparse_dim(), adj.dense_dim())
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.