pytorch_geometric icon indicating copy to clipboard operation
pytorch_geometric copied to clipboard

`NetworkX` heterogeneous graphs can be converted to `HeteroData` using `from_hetero_networkx`

Open SimonPop opened this issue 1 year ago • 10 comments

In order to answer the following issue: https://github.com/pyg-team/pytorch_geometric/issues/7340 this change proposes the implementation of a from_hetero_networkx method in the convert module.

Most of the unit tests have been copied from the from_networkx version and adapted.

Some implementation questions can be discussed such as:

  • Should the edge_type_attribute parameter accept being set to None? (currently, it does, and in that case, it defines the edge type as 'to')
  • Should edge_type_attribute values be tuples (node_a_type, type, node_b_type)? Should it also/only accept a single value type and infer node_a_type and node_b_type?
  • When specified for a non-directed graph, what should happen with non-symmetrical edge_type_attribute which is bound to be incorrect in at least one of the directions (e.g. if an edge defines its type as ('A', 'to', 'B') and the graph is not directed, the B -> A edge will have an incorrect label). Currently, it raises an error by checking node type coherency with edge type labels.

SimonPop avatar Jul 14 '23 10:07 SimonPop