我正在尝试使用 NetworkX 构建具有动态节点属性的网络。我尝试了以下方法:
import networkx as nx
G=nx.Graph()
G.add_node('A', attr_dict={'data': 1, 'start' : "1990-01-01", 'end' : "1993-01-01"})
G.add_node('B', attr_dict={'data': 2, 'start' : "1992-01-01", 'end' : "1993-01-01"})
但是,当使用 nx.write_gexf(G, 'test.gexf')
写入时,文件可以正常加载到 Gephi,但没有显示时间线。
将动态节点属性输入到 networkx 节点以写入 gexf 文件的正确格式是什么?
最佳答案
你的代码是正确的,但是你需要在数据实验室的Gephi里面生成时间间隔。查看用您的代码生成的网络:
请注意,从 0.9 版本开始,Gephi 将支持时间戳:
This 0.9 release adds a new way to represent networks over time: timestamps. So far, users could only represent time using intervals and that was cumbersome when the underlying network data was collected at fixed time intervals (e.g. one network per day). Starting with this release, Gephi will support both intervals and timestamps to represent evolving network topology and/or evolving attribute values.
关于python - Networkx 和 nx.write_gexf ... 动态节点属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20344383/