pytorch_geometric
pytorch_geometric copied to clipboard
`NetworkX` heterogeneous graphs can be converted to `HeteroData` using `from_hetero_networkx`
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 valuetype
and infernode_a_type
andnode_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.