python - Networkx 和 nx.write_gexf ... 动态节点属性

标签 python networkx gephi

我正在尝试使用 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里面生成时间间隔。查看用您的代码生成的网络:

Merging the columns

Formatting the time

请注意,从 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/

相关文章:

python - 使用 python 替换文件中的行的方法是什么

python - 将 Networkx 图转换为具有其属性的数据框

python - 从 networkx 中的图形中删除所有边

plugins - Gephi 0.9.1 版本中缺少 Neo4j 插件

python - 如何从 Python 创建 Gephi 网络图?

python - 线程未与 ThreadPoolExecutor 并行执行 python

python - 清除 Django 中的所有数据?

python - 如何从元组列表中提取模式元组?

python - 获取 NetworkX 图中的连接节点

export - Gephi preview export pdf 在左右边距处截断标签