-
Hi team, I knew there is a function named In the document, it is described Adds a self-loop to every node in the graph given by edge_index , but in test case occurs to me confusing. Much appreciate if you could help me to understand |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
So the Now coming to the test case. On another note you can check add_remaining_self_loops which only adds self loops that are not already present. |
Beta Was this translation helpful? Give feedback.
So the
add_self_loops
function adds edges from each node to itself. Such a thing might be useful if you want to say pass a message from a node to itself , like lets say you have a graph with no self loops then a layer likeGATConv
will pay attention to only a nodes neighbors, but with add_self_loops it can pay some "attention" to itself too.Now coming to the test case.
add_self_loops
doesn't check for existing self loops it simply appends all possible self loops to theedge_index
so the expected outputexpected = [[0, 1, 0, 0, 1], [1, 0, 0, 0, 1]]
, the first three edges(0,1), (1,0), (0,0)
are already present and the self loops(0,0), (1,1)
are added the self loop(0,0)
gets repeated.On…