def _draw_graph_diffing(graph1, graph2, differences):
plt.subplot(121)
pos = nx.pygraphviz_layout(graph1, prog='dot')
nx.draw_networkx_nodes(graph1, pos,
graph1.nodes(), node_color='b', node_size=200)
nx.draw_networkx_nodes(graph1, pos, differences[0],
node_color='r', node_size=600)
nx.draw_networkx_nodes(graph1, pos, differences[2],
node_color='y', node_size=600)
nx.draw_networkx_edges(graph1, pos, graph1.edges())
nx.draw_networkx_labels(graph1, pos, font_size=8)
plt.title('Graph 1')
plt.axis('off')
plt.subplot(122)
pos = nx.pygraphviz_layout(graph2, prog='dot')
nx.draw_networkx_nodes(graph2, pos, graph2.nodes(), node_color='b',
node_size=200)
nx.draw_networkx_nodes(graph2, pos, differences[1], node_color='r',
node_size=600)
nx.draw_networkx_nodes(graph2, pos, differences[3], node_color='g',
node_size=600)
nx.draw_networkx_edges(graph2, pos, graph2.edges())
nx.draw_networkx_labels(graph2, pos, font_size=8)
plt.title('Graph 2')
plt.axis('off')
lr = plt.Circle((0, 0), 5, fc='r')
lb = plt.Circle((0, 0), 5, fc='b')
lg = plt.Circle((0, 0), 5, fc='g')
ly = plt.Circle((0, 0), 5, fc='y')
plt.legend([lb, lr, lg, ly], ['No changed', 'Changed', 'Added',
'Removed'], loc=4)
# plt.savefig(graph1.name + '-' + graph2.name + '.png')
plt.show()
评论列表
文章目录