def twoPaths(G, i, j):
    """
    Return a list of nodes identifying the two-paths that would be formed
    (whether open or already closed) by the addition of arc i -> j

    Parameters:
         G - digraph
         i - source of arc to test
         j - destination of arc to test

    Return value:
        Tuple of two lists ([u], [v]) where [u] is list of nodes where i -> j
        forms a new two-path u -> i -> j and [v] is list of node where i -> j
        forms a new two-path i -> j -> v.
    """
    ulist = []
    vlist = []
    for u in G.inIterator(i):
        assert(G.isArc(u, i))
        if u == i or u == j:
            continue
        ulist.append(u)
    for v in G.outIterator(j):
        assert(G.isArc(j, v))
        if v == i or v == j:
            continue
        vlist.append(v)        
    return (ulist, vlist)