Concatenate edge feature and edge feature

Hi, I’m wondering if there is a way to concatenate features of edge E and edges of E neighbor.

Suppose a directed graph with edges [(0,3), (3,0), (1,3), (3,1), (3,2), (2,3)], and then the edge embedding are concatenated as follows [ ((1,3),(3,0)); ((1,3),(3,2)); ((2,3),(3,0)); ((2,3),(3,1)); ((0,3),(3,1)); ((0,3),(3,2)) ]

You can convert your graph to its line graph using dgl.line_graph where the edges of the original graph become the nodes in the new graph (so are their features). Since the adjacent nodes in the line graph are the edges with common incident nodes in the original graph, you then just need to concatenate their features using a simple lookup. Below is a piece of pseudocode:

g = ...  # your original graph
X = ...  # edge features
lg = dgl.line_graph(g)  # convert to line graph
lg_u, lg_v = lg.edges()
torch.cat([X[lg_u], X[lg_v]])

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