How to define a edge_udf with parameters?

For example, I want to define a edge_udf like

def edge_udf(edges, k):
  return {'m': some complicated operation on (edges.src['h'] &  edges.dst['h']) parameterized by k}

However,

DGLGraph.apply_edges(func, edges='__ALL__', etype=None, inplace=False)

seems infeasible to pass k in to edge_udf, hope anyone can tell me how to fix it, thank a lot!

The udf interface is fixed and you cannot modify it.
You can try wrapping k in a closure:

def udf_k(k):
    def edge_udf(edges):
        ...
    return edge_udf

g.apply_edges(udf_k(k), ...)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.