每1秒,可以更改节点状态。这就是为什么我应该在程序运行期间更改节点颜色的原因。我该怎么做?
import matplotlib.pyplot as plt
import networkx as nx
nodes = [0,1,2,3]
edges = [(0,1), (1,2), (3,1), (2,3)]
nodeListA = [0,1]
nodeListB = [2,3]
G = nx.Graph()
G.add_nodes_from(nodes)
G.add_edges_from(edges)
position = nx.circular_layout(G)
nx.draw_networkx_nodes(G,position, nodelist=nodeListA, node_color="b")
nx.draw_networkx_nodes(G,position, nodelist=nodeListB, node_color="r")
nx.draw_networkx_edges(G,position)
nx.draw_networkx_labels(G,position)
plt.show()