Return a directed representation of the graph.
Returns: | G : MultiDiGraph
|
---|
Notes
This is similar to MultiDiGraph(self) which returns a shallow copy. self.to_undirected() returns a deepcopy of edge, node and graph attributes.
Examples
>>> G = nx.Graph() # or MultiGraph, etc
>>> G.add_path([0,1])
>>> H = G.to_directed()
>>> H.edges()
[(0, 1), (1, 0)]
If already directed, return a (deep) copy
>>> G = nx.DiGraph() # or MultiDiGraph, etc
>>> G.add_path([0,1])
>>> H = G.to_directed()
>>> H.edges()
[(0, 1)]