this is impler:

  

      stackoverflow.com
  

  
      
    
  


  How to visualize a torch_geometric graph in Python? 20



  graph, pytorch, draw



  asked by
  
  
    White
  
  on 03:09PM - 17 Apr 20 UTC


  

  
    
    
  

  


import networkx as nx

edge_index = torch.tensor([[0, 1, 1, 2],
                           [1, 0, 2, 1]], dtype=torch.long)
x = torch.tensor([[-1], [0], [1]], dtype=torch.float)

data = torch_geometric.data.Data(x=x, edge_index=edge_index)
g = torch_geometric.utils.to_networkx(data, to_undirected=True)
nx.draw(g)

you need matplot lib installed too do conda install -y matplotlib.