@@ -50,6 +50,16 @@ def union_all(graphs, rename=()):
50
50
If a graph attribute is present in multiple graphs, then the value
51
51
from the last graph in the list with that attribute is used.
52
52
53
+ Examples
54
+ --------
55
+ >>> G1 = nx.Graph([(1, 2), (2, 3)])
56
+ >>> G2 = nx.Graph([(4, 5), (5, 6)])
57
+ >>> result_graph = nx.union_all([G1, G2])
58
+ >>> result_graph.nodes()
59
+ NodeView((1, 2, 3, 4, 5, 6))
60
+ >>> result_graph.edges()
61
+ EdgeView([(1, 2), (2, 3), (4, 5), (5, 6)])
62
+
53
63
See Also
54
64
--------
55
65
union
@@ -125,6 +135,16 @@ def disjoint_union_all(graphs):
125
135
NetworkXError
126
136
In case of mixed type graphs, like MultiGraph and Graph, or directed and undirected graphs.
127
137
138
+ Example
139
+ -------
140
+ >>> G1 = nx.Graph([(1, 2), (2, 3)])
141
+ >>> G2 = nx.Graph([(4, 5), (5, 6)])
142
+ >>> U = nx.disjoint_union_all([G1, G2])
143
+ >>> list(U.nodes())
144
+ [0, 1, 2, 3, 4, 5]
145
+ >>> list(U.edges())
146
+ [(0, 1), (1, 2), (3, 4), (4, 5)]
147
+
128
148
Notes
129
149
-----
130
150
For operating on mixed type graphs, they should be converted to the same type.
@@ -169,6 +189,16 @@ def compose_all(graphs):
169
189
NetworkXError
170
190
In case of mixed type graphs, like MultiGraph and Graph, or directed and undirected graphs.
171
191
192
+ Example
193
+ -------
194
+ >>> G1 = nx.Graph([(1, 2), (2, 3)])
195
+ >>> G2 = nx.Graph([(3, 4), (5, 6)])
196
+ >>> C = nx.compose_all([G1, G2])
197
+ >>> list(C.nodes())
198
+ [1, 2, 3, 4, 5, 6]
199
+ >>> list(C.edges())
200
+ [(1, 2), (2, 3), (3, 4), (5, 6)]
201
+
172
202
Notes
173
203
-----
174
204
For operating on mixed type graphs, they should be converted to the same type.
@@ -246,6 +276,16 @@ def intersection_all(graphs):
246
276
>>> gh.nodes(data=True)
247
277
NodeDataView({0: {'new_capacity': 2}, 1: {'new_capacity': 3}})
248
278
279
+ Example
280
+ -------
281
+ >>> G1 = nx.Graph([(1, 2), (2, 3)])
282
+ >>> G2 = nx.Graph([(2, 3), (3, 4)])
283
+ >>> R = nx.intersection_all([G1, G2])
284
+ >>> list(R.nodes())
285
+ [2, 3]
286
+ >>> list(R.edges())
287
+ [(2, 3)]
288
+
249
289
"""
250
290
R = None
251
291
0 commit comments