Question about g.apply_edges()

Hi, Thank you very much for your time to read my question . I’ve been browsing through many posts, people are amazing here and community is truly one of a kind ! I am quite new to graphs sorry if my question is non sense, off topic or stupidly easy . May you please see as follow :
if I have a directed graph, nodes are (x, y) coordinates and edges are distance between coordinates.

def f_edge(edges): 
    return {'cc': edges.src['h']}
g.apply_edges(f_edge)

if I want to use apply_edges, is it possible for me to at each edge, get previous 3 edges and use them to update next edge. ie at node 3; get [ A, B and C's ] mean to update D and possibly pass through a Linear Layer to update D, and so on for every other subsequent edges.

I was thinking to hard code previous coordinates into g.edata[‘previous nodes’] , and calculate within message_func, dont quite know if that is at all possible and how to update .

Edit : Just in case some new users are in same situation, I've found out that coverting g to g.line_graph() and updating nodes repeatedly could do, but in a graph that has more than one edge type does it not work then ?

Thank you very much for your time

as the other thread mentioned, could you try with dgl.line_graph first and utilize dgl.DGLGraph.prop_nodes — DGL 0.8.0post1 documentation then?

1 Like

Thank you very much for your reply !

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