chrsmrrs / k-gnn

Source code for our AAAI paper "Weisfeiler and Leman Go Neural: Higher-order Graph Neural Networks".
183 stars 45 forks source link

A question regarding k-gnn functions outputs #15

Closed Ana-hita closed 3 years ago

Ana-hita commented 3 years ago

Hi,

There are three outputs to the functions such as two_local and connected_two_local which are edge_index, assignment_index, and iso_type from the according higher order graph. Could you please explain what each are and what they indicate? I have already read your paper but I could not figure the implementation out regarding these features.

Thank you in advance.

rusty1s commented 3 years ago

edge_index returns the graph-structure where nodes correspond to tuples in the original graph. As a result, assignment_index maps each node in the original graph to the tuples which contain this node. iso_type defines the isomorphism type of each tuple in the processed graph (just a label), in order to distinguish any given tuple.

Ana-hita commented 3 years ago

Thank you very much for the reply. I'm not sure if I could understand properly. More specifically the rows and columns in each of these attributes. Here I have used an example of a simple graph with 3 nodes and 2 connections:

v = torch.tensor([1,5,1]).unsqueeze(1) e = torch.tensor([[0,1,0],[1,0,1],[0,1,0]]) o = graph_cpu.two_local(e,v,3)

then o outputs:

Out[1]: [tensor([[0, 0, 1, 1, 2, 2], [1, 2, 0, 2, 0, 1]]), tensor([[0, 1, 0, 2, 1, 2], [0, 0, 1, 1, 2, 2]]), tensor([1, 0, 0])]

I understand that each are edge_index_2, assignment_index_2, and iso_type_2 respectively. I could guess that assignment_index_2 gives that e.g. node_0 in the high order graph (listed in the second row) is from the (node_0, node_1) in the original graph (shown in the first row) and so on. But I'm still confused about the dge_index_2 rows and columns.

rusty1s commented 3 years ago

A graph with 3 nodes will result in in three tuples of size 2 each. Therefore, edge_index_2 will contain values between 0 and 2. Here, edge_index_2 denotes a fully-connected graph, since for each tuple, there exist a node inside this tuple that is connected to another node outside this tuple. You can find a formal definition in the paper.

You are absolutely right with your understanding regarding assignment_index_2.

Ana-hita commented 3 years ago

Thank you again. It was as I was expecting it to be, and now I'm certain. 🙂