While reviewing the GraphPropertyReader class, I noticed that the edge_index in the _read_data method is built like this:
edge_index = torch.tensor(
[
[bond.GetBeginAtomIdx() for bond in mol.GetBonds()],
[bond.GetEndAtomIdx() for bond in mol.GetBonds()],
]
)
This seems to construct the molecular graph as directed graph, where each bond is added in one direction only [begin_atom_idx] -> [end_atom_idx].
❓ Clarification
Since molecular graphs typically model bonds as undirected, I wanted to confirm the intended behavior.
💡 Suggestion (if not intentional)
If the goal is an undirected graph, this can be handled cleanly using PyTorch Geometric's to_undirected utility:
from torch_geometric.utils import to_undirected
edge_index = torch.tensor(
[
[bond.GetBeginAtomIdx() for bond in mol.GetBonds()],
[bond.GetEndAtomIdx() for bond in mol.GetBonds()],
]
)
edge_index = to_undirected(edge_index)
OR
by explicitly creating undirected graphs:
src = [bond.GetBeginAtomIdx() for bond in mol.GetBonds()]
tgt = [bond.GetEndAtomIdx() for bond in mol.GetBonds()]
edge_index = torch.tensor([src + tgt, tgt + src])
Let me know if this was an intentional design or if we should update it. Thanks!
While reviewing the
GraphPropertyReaderclass, I noticed that theedge_indexin the_read_datamethod is built like this:This seems to construct the molecular graph as directed graph, where each bond is added in one direction only
[begin_atom_idx] -> [end_atom_idx].❓ Clarification
Since molecular graphs typically model bonds as undirected, I wanted to confirm the intended behavior.
💡 Suggestion (if not intentional)
If the goal is an undirected graph, this can be handled cleanly using PyTorch Geometric's
to_undirectedutility:OR
by explicitly creating undirected graphs:
Let me know if this was an intentional design or if we should update it. Thanks!