# graphscope.experimental.nx.Graph.to_undirected¶

Graph.to_undirected(as_view=False)[source]

Returns an undirected copy of the graph.

Parameters

as_view (bool (optional, default=False)) – If True return a view of the original undirected graph.

Returns

G – A deepcopy of the graph.

Return type

Graph

Notes

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

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.

Examples

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