我试图用add_edge_list通过一个使用,而不是插入的边缘之一的add_edge为了使图创建速度更快.
但是我找不到如何一次创建这些边缘并将权重属性与它们相关联,而不会在创建后循环边缘.
添加示例用法,因为文档中的语法有些不清楚.
# the edges of the graph with corresponding properties
edges = [[x_0, y_0, p_0],
[x_1, y_1, p_1],
...
[x_n, y_n, p_n]]
# creating an external property
any_property_name = g.new_edge_property("int")
# adding list of all properties
eprops = [any_property_name]
# add edges and properties to the graph
g.add_edge_list(edges, eprops=eprops)
Run Code Online (Sandbox Code Playgroud)