networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesReturns
to_undirected(self, as_view=False)

Notes

This returns a "deepcopy" of the edge, node, and graph attributes which attempts to completely copy all of the data and references.

This is in contrast to the similar :None:None:`G = nx.MultiGraph(D)` which returns a shallow copy of the data.

See the Python copy module for more information on shallow and deep copies, https://docs.python.org/3/library/copy.html.

Warning: If you have subclassed MultiGraph to use dict-like objects in the data structure, those changes do not transfer to the MultiGraph created by this method.

Returns

G : Graph/MultiGraph

A deepcopy of the graph.

Returns an undirected copy of the graph.

See Also

add_edge
add_edges_from
copy

Examples

>>> G = nx.MultiGraph([(0, 1), (0, 1), (1, 2)])
... H = G.to_directed()
... list(H.edges) [(0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 2, 0), (2, 1, 0)]
>>> G2 = H.to_undirected()
... list(G2.edges) [(0, 1, 0), (0, 1, 1), (1, 2, 0)]
See :

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/classes/multigraph.py#1108
type: <class 'function'>
Commit: