compose_all#
- compose_all(graphs)[source]#
返回所有图的组合。
组合是节点集和边集的简单并集。 提供的图的节点集不必不相交。
- Parameters:
- graphsiterable
可迭代的NetworkX图
- Returns:
- C与列表中第一个图相同类型的图
- Raises:
- ValueError
如果
graphs
是空列表。- NetworkXError
在混合类型图(如多图和图,或有向图和无向图)的情况下。
Notes
对于操作混合类型图,应将它们转换为相同类型。
图、边和节点属性会传播到并集图。 如果某个图属性在多个图中存在,则使用列表中具有该属性的最后一个图的值。
Examples
>>> G1 = nx.Graph([(1, 2), (2, 3)]) >>> G2 = nx.Graph([(3, 4), (5, 6)]) >>> C = nx.compose_all([G1, G2]) >>> list(C.nodes()) [1, 2, 3, 4, 5, 6] >>> list(C.edges()) [(1, 2), (2, 3), (3, 4), (5, 6)]