繁体   English   中英

如何从 Networkx 或 DyNetx 上的图形列表生成动态图形

[英]How can I generate a dynamic graph from a list of graphs on Networkx or DyNetx

好吧,我拥有的是一堆边缘文件,我设法将它们放入图表列表中,但问题是我想将它们作为单个动态网络进行处理,但我不知道如何去做,我一直在寻找 networkx 和 dynetx 的文档,但没有任何反应; 所以这是我到目前为止所做的:

import networkx as nx
import matplotlib.pyplot as plt
from operator import itemgetter
import dynetx as dnx
#from glob import glob
import os

#path to the files
path = '../Ants'
#Create a list of graph from the files
G = [nx.read_weighted_edgelist(path+'/'+f, create_using=nx.Graph(), nodetype=int) for f in os.listdir(path) ]

DyNetx包在其DynGraph文档中说明了一些方法。 以下应该可以解决您的问题:

import networkx as nx
import matplotlib.pyplot as plt
from operator import itemgetter
import dynetx as dnx
#from glob import glob
import os

#path to the files
path = '../Ants'
#Create a list of graph from the files
list_of_snapshots = [nx.read_weighted_edgelist(path+'/'+f, create_using=nx.Graph(), nodetype=int) for f in os.listdir(path) ]

dynamic_graph = dnx.DynGraph()
for t, graph in enumerate(list_of_snapshots):
    dynamic_graph.add_interactions_from(graph.edges(data=True), t=t)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM