@not_implemented_for('undirected')
def transitive_closure(G):
    TC = nx.DiGraph()
    TC.add_nodes_from(G.nodes())
    TC.add_edges_from(G.edges())
    for v in G:
        TC.add_edges_from((v, u) for u in nx.dfs_preorder_nodes(G, source=v)
                          if v != u)
    return TC
Parse the given docstring, which is formatted using
dataset/ETHPy150Open networkx/networkx/networkx/algorithms/dag.py/transitive_closure--crossover with--dataset/ETHPy150Open CollabQ/CollabQ/vendor/epydoc/markup/restructuredtext.py/parse_docstring