symmetric_difference#
- symmetric_difference(G, H)[源代码]#
返回新的图,其中的边存在于g或h中,但不同时存在。
H和G的节点集必须相同。
- 参数
- G,H图表
网络X图。G和H必须具有相同的节点集。
- 返回
- D给出了与G.
笔记
来自图形、节点和边的属性不会复制到新图形。
实例
>>> G = nx.Graph([(0, 1), (0, 2), (1, 2), (1, 3)]) >>> H = nx.Graph([(0, 1), (1, 2), (0, 3)]) >>> R = nx.symmetric_difference(G, H) >>> R.nodes NodeView((0, 1, 2, 3)) >>> R.edges EdgeView([(0, 2), (0, 3), (1, 3)])