picassooo
\'\'\'
摘自https://docs.dgl.ai/en/0.6.x/guide_cn/graph-graphs-nodes-edges.html
\'\'\'

import dgl
import torch as th
import networkx as nx
import matplotlib.pyplot as plt

# 边 0->1, 0->2, 0->3, 1->3
u, v = th.tensor([0, 0, 0, 1]), th.tensor([1, 2, 3, 3])
graph = dgl.graph((u, v))
fig, ax = plt.subplots()
nx.draw(graph.to_networkx(), ax=ax)   # 将图转为networkx形式
ax.set_title(\'Graph\')
plt.savefig(\'fig_graph.png\')

  

结果:

 

分类:

技术点:

相关文章:

  • 2021-12-26
  • 2021-12-26
  • 2021-12-27
  • 2021-10-24
  • 2021-05-12
  • 2021-06-16
  • 2021-12-26
  • 2021-12-26
猜你喜欢
  • 2021-12-26
  • 2021-12-26
  • 2021-09-10
  • 2021-07-08
  • 2022-01-23
  • 2021-05-17
  • 2021-12-26
相关资源
相似解决方案