import sys
import matplotlib.pyplot as plt
import networkx as nx
生成网格
G = nx.grid_2d_graph(5, 5) # 5x5 grid
print the adjacency list
打印网络
for line in nx.generate_adjlist(G):
print(line)
write edgelist to grid.edgelist
写数据
#nx.write_edgelist(G, path=“grid.edgelist”, delimiter="😊
read edgelist from grid.edgelist
读数据
#H = nx.read_edgelist(path=“grid.edgelist”, delimiter="😊
nx.draw(G)
plt.show()