

def to_directed(self):
    'Return a directed representation of the graph.\n\n        Returns\n        -------\n        G : DiGraph\n            A directed graph with the same name, same nodes, and with\n            each edge (u,v,data) replaced by two directed edges\n            (u,v,data) and (v,u,data).\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\n        Examples\n        --------\n        >>> G = nx.Graph()   # or MultiGraph, etc\n        >>> G.add_path([0,1])\n        >>> H = G.to_directed()\n        >>> H.edges()\n        [(0, 1), (1, 0)]\n\n        If already directed, return a (deep) copy\n\n        >>> G = nx.DiGraph()   # or MultiDiGraph, etc\n        >>> G.add_path([0,1])\n        >>> H = G.to_directed()\n        >>> H.edges()\n        [(0, 1)]\n        '
    from networkx import DiGraph
    G = DiGraph()
    G.name = self.name
    G.add_nodes_from(self)
    G.add_edges_from(((u, v, deepcopy(data)) for (u, nbrs) in self.adjacency_iter() for (v, data) in nbrs.items()))
    G.graph = deepcopy(self.graph)
    G.node = deepcopy(self.node)
    return G

dataset/ETHPy150Open networkx/networkx/networkx/classes/tests/timingclasses.py TimingGraph.to_directed/original