Dear DGL-Forum,
i am new to DGL and currently working on a way to compute alle paths of a fixed length leading to all nodes. As a first step i would like each node to store a tensor containing the edge_id that leads to the node, as well as the source node of the path. So the result should look like this:
[
[predecessor_node_id, edge_id connecting predecessor and this node, predecessor_node_id],
[predecessor_node_id, edge_id connecting predecessor and this node, predecessor_node_id],
...
]
I have tried the following approach which leads to an error message (see below), so i am thinking i miss something fundamental about the API. Please enlighten me about my wrong doings
import dgl
import torch
import numpy as np
def initial_send(edges):
helper = torch.stack((edges._eid, g.find_edges(edges._eid)[0], edges._eid))
return {"send_message": helper.T}
def initial_reduce(nodes):
return {"recieved message": nodes.mailbox["send_message"]}
if __name__ == '__main__':
src = np.array([0, 1, 2, 2, 3, 3, 4, 3])
dst = np.array([1, 2, 3, 1, 1, 2, 2, 2])
g = dgl.graph((src, dst))
g.update_all(initial_send,initial_reduce)
RuntimeError: Sizes of tensors must match except in dimension 0. Got 1 and 3 in dimension 1 (The offending index is 1)