有没有办法检测使用 NetworkX 创建的图形中的变化?

问题描述

我是 Python 初学者,非常感谢您对以下问题的帮助。

我有一个创建图形并将其保存为 Pickle 文件的第一个脚本:

import networkx as nx

G = nx.Graph()
#Some code lines to add nodes and edges...

nx.write_gpickle(G,"graph_file.gpickle")

然后,我有第二个脚本,我想在其中读取 Pickle 文件并检测图形节点属性中的任何更改,以防第一个脚本使用不同的节点属性值重新运行:

import networkx as nx

G = nx.read_gpickle("graph_file.gpickle")

#I need to implement something like this:
for node in G.nodes():
    if node["attribute"] changed from prevIoUs value:
        print(f"The attribute of the node {node} changed from {prevIoUs value of node["attribute"]} to {new value of node["attribute"]}")

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)