5
通过指定节点列表,我们可以很容易地从NetworkX图形中提取子图形,但我无法找到有效的方法来通过边缘执行子图提取。例如,提取子图由边的权重超过用户定义的阈值组成。根据NetworkX中的某些边缘属性有效提取子图形
目前我正在做下列方式:
## extracts all edges satisfy the weight threshold (my_network is directed):
eligible_edges = [(from_node,to_node,edge_attributes) for from_node,to_node,edge_attributes in my_network.edges(data=True) if edge_attributes['weight'] > threshold]
new_network = NetworkX.DiGraph()
new_network.add_edges_from(eligible_edges)
有没有更好的方式来做到这一点?
感谢您的答复。
太好了,谢谢你的记忆保存提示! –