networkx.MultiDiGraph.edges方法是否保留顺序? [英] Is the networkx.MultiDiGraph.edges method order-preserving?

查看:270
本文介绍了networkx.MultiDiGraph.edges方法是否保留顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MyNetwork是networkx.MultiDiGraph的实例.我想知道是否可以确保多次运行以下代码才能在MyNetwork中得到完全相同的列表,其中包含所有边缘(以及边缘属性):

MyNetwork is an instance of networkx.MultiDiGraph. I'm wondering if multiple runs of the following code is guaranteed to result exactly the same list containing all edges (along with edge attributes) in MyNetwork:

AllEdges = [(from_node,to_node,edge_key,edge_attributes) for (from_node,to_node,edge_key,edge_attributes) in MyNetwork.edges(keys=True,data=True)] 

感谢您的友好回答.

推荐答案

从MultiDiGraph.edges()方法返回的边列表在重复调用时不保证顺序相同.如果需要特定的排序,则必须进行更多处理(例如排序)或维护单独的边列表或符号表.

The list of edges returned from the MultiDiGraph.edges() method is not guaranteed to be in any order or the same when called repeatedly. You'll have to do more processing (e.g. a sort) or maintain a separate list or symbol table of edges if you need a particular ordering.

这篇关于networkx.MultiDiGraph.edges方法是否保留顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆