networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
disjoint_union(G, H)

This algorithm forces distinct integer node labels.

Notes

A new graph is created, of the same class as G. It is recommended that G and H be either both directed or both undirected.

The nodes of G are relabeled 0 to len(G)-1, and the nodes of H are relabeled len(G) to len(G)+len(H)-1.

Graph, edge, and node attributes are propagated from G and H to the union graph. If a graph attribute is present in both G and H the value from H is used.

Parameters

G,H : graph

A NetworkX graph

Returns

U : A union graph with the same type as G.

Return the disjoint union of graphs G and H.

Examples

>>> G = nx.Graph([(0, 1), (0, 2), (1, 2)])
... H = nx.Graph([(0, 3), (1, 2), (2, 3)])
... G.nodes[0]["key1"] = 5
... H.nodes[0]["key2"] = 10
... U = nx.disjoint_union(G, H)
... U.nodes(data=True) NodeDataView({0: {'key1': 5}, 1: {}, 2: {}, 3: {'key2': 10}, 4: {}, 5: {}, 6: {}})
>>> U.edges
EdgeView([(0, 1), (0, 2), (1, 2), (3, 4), (4, 6), (5, 6)])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.algorithms.operators.binary.union networkx.algorithms.operators.binary.full_join networkx.algorithms.operators.binary.disjoint_union

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/algorithms/operators/binary.py#78
type: <class 'function'>
Commit: