Skip to content

Commit 6bc4f35

Browse files
committed
fg level edge fix
If two atoms of a FG points to atom(s) belonging to another FG. In this case, only one edge is counted.
1 parent 66ea248 commit 6bc4f35

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

chebai_graph/preprocessing/reader/augmented_reader.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,12 @@ def _construct_fg_level_structure(
440440

441441
internal_edge_index[0].append(source_fg)
442442
internal_edge_index[1].append(target_fg)
443-
internal_fg_edges[f"{source_fg}_{target_fg}"] = {EDGE_LEVEL: WITHIN_FG_EDGE}
444-
self._num_of_edges += 1
443+
edge_str = f"{source_fg}_{target_fg}"
444+
if edge_str not in internal_fg_edges:
445+
# If two atoms of a FG points to atom(s) belonging to another FG. In this case, only one edge is counted.
446+
# Eg. In CHEBI:52723, atom idx 13 and 16 of a FG points to atom idx 18 of another FG
447+
internal_fg_edges[edge_str] = {EDGE_LEVEL: WITHIN_FG_EDGE}
448+
self._num_of_edges += 1
445449

446450
return internal_edge_index, internal_fg_edges
447451

0 commit comments

Comments
 (0)