import networkx as nx
#新建一张图
G = nx.path_graph(3)
#为图的所有边添加属性 attribute, 属性的值 为 False
nx.set_edge_attributes(G, False, "attribute")
print(G[1][2]['attribute'])
输出为False
参考自networkx官方文档
import networkx as nx
#新建一张图
G = nx.path_graph(3)
#为图的所有边添加属性 attribute, 属性的值 为 False
nx.set_edge_attributes(G, False, "attribute")
print(G[1][2]['attribute'])
输出为False
参考自networkx官方文档