python列表add用法_使用add_edge_list()方法创建图形的最佳方法是什么?

如果你有一个10^6-10^7顶点的稠密图(是一些医学数据还是社交图?它可以改变一切),你不应该使用networkx,因为它是用纯Python编写的,所以它比graph-tool或{}慢10-100倍。在您的例子中,我建议您使用graph-tool。它是最快的(~asigraph)Python图形处理库。在

graph-tool行为与networkx不同。当您创建networkx节点时,它的标识符是您在节点构造函数中编写的,这样您就可以通过节点的ID来获取该节点。在graph tool中,每个顶点ID都是从1到graph\u SIZE的整数:Each vertex in a graph has an unique index, which is always between 0 and N−1, where N is the number of vertices. This index can be obtained by using the vertex_index attribute of the graph (which is a property map, see Property maps), or by converting the vertex descriptor to an int.

关于图、顶点或边的所有附加信息都存储在property maps中。当您将.add_edge_list()与hashed=True一起使用时,新的属性映射将作为.add_edge_list()的结果返回。所以在你的例子中,你应该像这样处理你的顶点:# Create graph

g = grt.Graph(directed=False)

# Create edge list

# Why frozensets? You don't really need them. You can use ordinary sets

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值