Skip to content
Discussion options

You must be logged in to vote

to_heterogeneous requires that node_type and edge_type denote index-based vectors, not lists of strings:

import networkx as nx
import numpy as np
import torch

from torch_geometric.utils.convert import from_networkx

graph = nx.DiGraph()
graph.add_node(...)
graph.add_node(...)
graph.add_node(...)

graph.add_edge(1, 2, edge_type="topology")
graph.add_edge(123131243, 1, edge_type="involved")

data = from_networkx(graph)

data.node_type = np.unique(np.array(data.node_type), return_inverse=True)[1]
data.node_type = torch.from_numpy(data.node_type)

data.edge_type = np.unique(np.array(data.edge_type), return_inverse=True)[1]
data.edge_type = torch.from_numpy(data.edge_type)

hetero_data = data.t…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@HamidL
Comment options

Answer selected by HamidL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants