human
I wrote the below code

    n = G.order()
    k = 1
    while ((1 << k) < n):
        k += 1
    def enc(x):
        'Big    endian    k-bit    encoding    of    x'
        return [(1 if (x & (1 << ((k - 1) - i))) else 0) for i in range(k)]
    if (nodes is not None):
        G = G.subgraph(nodes)
    H = nx.convert_node_labels_to_integers(G, ordering='sorted')
    edges = sorted(((max(u, v), min(u, v)) for (u, v) in H.edges()))
    bits = []
    curv = 0
    for (v, u) in edges:
        if (v == curv):
            bits.append(0)
            bits.extend(enc(u))
        elif (v == (curv + 1)):
            curv += 1
            bits.append(1)
            bits.extend(enc(u))
        else:
            curv = v
            bits.append(1)
            bits.extend(enc(v))
            bits.append(0)
            bits.extend(enc(u))
    if ((k < 6) and (n == (1 << k)) and (((- len(bits)) % 6) >= k) and (curv < (n - 1))):
        bits.append(0)
        bits.extend(([1] * ((- len(bits)) % 6)))
    else:
        bits.extend(([1] * ((- len(bits)) % 6)))
    data = [((((((bits[(i + 0)] << 5) + (bits[(i + 1)] << 4)) + (bits[(i + 2)] << 3)) + (bits[(i + 3)] << 2)) + (bits[(i + 4)] << 1)) + (bits[(i + 5)] << 0)) for i in range(0, len(bits), 6)]
    res = ((':' + data_to_graph6(n_to_data(n))) + data_to_graph6(data))
    if header:
        return ('>>sparse6<<' + res)
    else:
        return res

What's a good function header?

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

@not_implemented_for('directed')
def generate_sparse6(G, nodes=None, header=True):