处理图的开源库

1、networkx可视化pyg的Data

from torch_geometric.utils import to_networkx
import pylab

# one_data是Data类型
G = to_networkx(one_data)
nx.draw(G)
pylab.show()

2、RDKit 用于化学信息学的开源工具包
基于对化合物2D和3D分子操作,利用机器学习方法进行化合物描述符生成,fingerprint生成,化合物结构相似性计算,2D和3D分子展示等
https://rdkit.org/

            # 使用rdkit解析分析分子的信息,生成图信息,构建Data
            mol = Chem.MolFromSmiles(smiles)  # Read the molecule info
            adj = Chem.GetAdjacencyMatrix(mol)  # Get molecule structure
            # You should extract other features here!
            data = Data(num_nodes=adj.shape[0], edge_index=torch.Tensor(adj).nonzero().T, y=label)