human
I wrote the below code

    if ((weight is None) or (G.number_of_edges() == 0)):
        max_weight = 1
    else:
        max_weight = max((d.get(weight, 1) for (u, v, d) in G.edges(data=True)))
    if (nodes is None):
        nodes_nbrs = G.adj.items()
    else:
        nodes_nbrs = ((n, G[n]) for n in G.nbunch_iter(nodes))
    def wt(u, v):
        return (G[u][v].get(weight, 1) / max_weight)
    for (i, nbrs) in nodes_nbrs:
        inbrs = (set(nbrs) - {i})
        weighted_triangles = 0
        seen = set()
        for j in inbrs:
            seen.add(j)
            jnbrs = (set(G[j]) - seen)
            wij = wt(i, j)
            weighted_triangles += sum(((((wij * wt(j, k)) * wt(k, i)) ** (1 / 3)) for k in (inbrs & jnbrs)))
        (yield (i, len(inbrs), (2 * weighted_triangles)))

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

@not_implemented_for('multigraph')
def _weighted_triangles_and_degree_iter(G, nodes=None, weight='weight'):