Issue
How would one construct a edge_attr list for undirected graphs in pytorch geometric Data object. Say we had an undirected graph such as this one. The graph COO matrix required by the pytorch geometric object is:
[['a', 'b', 'a', 'c', 'b', 'c']
['b', 'a', 'c', 'a', 'c', 'b']]
How would one construct the edge_attr list then (which is an array of one-hot encoded vectors for the features of each edge). Since the graph is undirected, would one simply append two of the same one-hot encoded feature vectors at a time. For example, say these are the edge features :
(a, b) = [0,0,0,1]
(a, c) = [1,0,0,0]
(b, c) = [0,1,0,0]
Would the edge_attr list look like:
[[0,0,0,1], [0,0,0,1], [1,0,0,0], [1,0,0,0], [0,1,0,0], [0,1,0,0]
Note how each one-hot encoded feature vector is repeated twice, and the feature vector index in edge_attr corresponds its respective edge in the graph COO matrix. Because the graph is undirected, we just use the same feature matrix. Is the right way to do it, or is there some other way?
Solution
The answer I figured out is yes. In an undirected graph for pytorch_geometric, the edge features would need to be repeated twice, once for each respective connection present in the COO matrix.
Answered By - makeorbreak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.