human
I wrote the below code

    if (source == target):
        return (0, [source])
    if G.is_directed():
        Gpred = G.predecessors
        Gsucc = G.successors
    else:
        Gpred = G.neighbors
        Gsucc = G.neighbors
    if ignore_nodes:
        def filter_iter(nodes):
            def iterate(v):
                for w in nodes(v):
                    if (w not in ignore_nodes):
                        (yield w)
            return iterate
        Gpred = filter_iter(Gpred)
        Gsucc = filter_iter(Gsucc)
    if ignore_edges:
        if G.is_directed():
            def filter_pred_iter(pred_iter):
                def iterate(v):
                    for w in pred_iter(v):
                        if ((w, v) not in ignore_edges):
                            (yield w)
                return iterate
            def filter_succ_iter(succ_iter):
                def iterate(v):
                    for w in succ_iter(v):
                        if ((v, w) not in ignore_edges):
                            (yield w)
                return iterate
            Gpred = filter_pred_iter(Gpred)
            Gsucc = filter_succ_iter(Gsucc)
        else:
            def filter_iter(nodes):
                def iterate(v):
                    for w in nodes(v):
                        if (((v, w) not in ignore_edges) and ((w, v) not in ignore_edges)):
                            (yield w)
                return iterate
            Gpred = filter_iter(Gpred)
            Gsucc = filter_iter(Gsucc)
    push = heappush
    pop = heappop
    dists = [{}, {}]
    paths = [{source: [source]}, {target: [target]}]
    fringe = [[], []]
    seen = [{source: 0}, {target: 0}]
    c = count()
    push(fringe[0], (0, next(c), source))
    push(fringe[1], (0, next(c), target))
    neighs = [Gsucc, Gpred]
    finalpath = []
    dir = 1
    while (fringe[0] and fringe[1]):
        dir = (1 - dir)
        (dist, _, v) = pop(fringe[dir])
        if (v in dists[dir]):
            continue
        dists[dir][v] = dist
        if (v in dists[(1 - dir)]):
      ...

What's a good function header?
 Here's a good function header?
assistant
#Here's a good function header.

def _bidirectional_dijkstra(G, source, target, weight='weight', ignore_nodes=None, ignore_edges=None):