networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturns
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.DiGraph(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 DiGraph to use dict-like objects in the data structure, those changes do not transfer to the Graph created by this method.

Parameters

as_view : bool (optional, default=False)

If True return a view of the original undirected graph.

Returns

G : Graph/MultiGraph

A deepcopy of the graph.

Returns an undirected copy of the graph.

See Also

Graph
add_edge
add_edges_from
copy

Examples

>>> G = nx.path_graph(2)  # or MultiGraph, etc
... H = G.to_directed()
... list(H.edges) [(0, 1), (1, 0)]
>>> G2 = H.to_undirected()
... list(G2.edges) [(0, 1)]
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/graph.py#1604
type: <class 'function'>
Commit: