human
I wrote the below code

    if (source not in G):
        raise nx.NodeNotFound(('Node    %s    is    not    found    in    the    graph' % source))
    weight = _weight_function(G, weight)
    if any(((weight(u, v, d) < 0) for (u, v, d) in G.selfloop_edges(data=True))):
        raise nx.NetworkXUnbounded('Negative    cost    cycle    detected.')
    if (len(G) == 1):
        return ({source: None}, {source: 0})
    if G.is_directed():
        G_succ = G.succ
    else:
        G_succ = G.adj
    inf = float('inf')
    d = dict(((u, inf) for u in G))
    d[source] = 0
    pred = {source: None}
    def topo_sort(relabeled):
        'Topologically    sort    nodes    relabeled    in    the    previous    round    and    detect\n                                negative    cycles.\n                                '
        to_scan = []
        neg_count = {}
        for u in relabeled:
            if (u in neg_count):
                continue
            d_u = d[u]
            if all((((d_u + weight(u, v, e)) >= d[v]) for (v, e) in G_succ[u].items())):
                continue
            stack = [(u, iter(G_succ[u].items()))]
            in_stack = set([u])
            neg_count[u] = 0
            while stack:
                (u, it) = stack[(-1)]
                try:
                    (v, e) = next(it)
                except StopIteration:
                    to_scan.append(u)
                    stack.pop()
                    in_stack.remove(u)
                    continue
                t = (d[u] + weight(u, v, e))
                d_v = d[v]
                if (t <= d_v):
                    is_neg = (t < d_v)
                    d[v] = t
                    pred[v] = u
                    if (v not in neg_count):
                        neg_count[v] = (neg_count[u] + int(is_neg))
                        stack.append((v, iter(G_succ[v].items())))
                        in_stack.add(v)
                    elif ((v in in_stack) and ((neg_count[u] + int(is_neg)) > neg_count[v])):
                        raise...

What's a good function header?

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

def goldberg_radzik(G, source, weight='weight'):