

def to_undirected(self, reciprocal=False):
    'Return an undirected representation of the digraph.\n\n        Parameters\n        ----------\n        reciprocal : bool (optional)\n          If True only keep edges that appear in both directions \n          in the original digraph. \n\n        Returns\n        -------\n        G : MultiGraph\n            An undirected graph with the same name and nodes and\n            with edge (u,v,data) if either (u,v,data) or (v,u,data)\n            is in the digraph.  If both edges exist in digraph and\n            their edge data is different, only one edge is created\n            with an arbitrary choice of which edge data to use.\n            You must check and correct for this manually if desired.\n\n        Notes\n        -----\n        This returns a "deepcopy" of the edge, node, and\n        graph attributes which attempts to completely copy\n        all of the data and references.\n\n        This is in contrast to the similar D=DiGraph(G) which returns a\n        shallow copy of the data.\n\n        See the Python copy module for more information on shallow\n        and deep copies, http://docs.python.org/library/copy.html.\n        '
    H = MultiGraph()
    H.name = self.name
    H.add_nodes_from(self)
    if (reciprocal is True):
        H.add_edges_from(((u, v, key, deepcopy(data)) for (u, nbrs) in self.adjacency_iter() for (v, keydict) in nbrs.items() for (key, data) in keydict.items() if self.has_edge(v, u, key)))
    else:
        H.add_edges_from(((u, v, key, deepcopy(data)) for (u, nbrs) in self.adjacency_iter() for (v, keydict) in nbrs.items() for (key, data) in keydict.items()))
    H.graph = deepcopy(self.graph)
    H.node = deepcopy(self.node)
    return H

dataset/ETHPy150Open networkx/networkx/networkx/classes/tests/timingclasses.py TimingMultiDiGraph.to_undirected/original