From 7d6912f925ebe084b6c11618d107a8ac3cbd3ab4 Mon Sep 17 00:00:00 2001 From: Lyubov Yamshchikova Date: Tue, 5 Sep 2023 13:33:33 +0300 Subject: [PATCH] Minor fix --- examples/molecule_search/mol_advisor.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/molecule_search/mol_advisor.py b/examples/molecule_search/mol_advisor.py index d50b45c9..34a5ec39 100644 --- a/examples/molecule_search/mol_advisor.py +++ b/examples/molecule_search/mol_advisor.py @@ -49,10 +49,13 @@ def propose_atom_removal(mol_graph: MolGraph) -> Sequence[int]: Proposes atoms that can be removed - any atom, which deletion will not increase the number of connected components of the molecule. """ - nx_graph = mol_graph.get_nx_graph() - art_points_ids = nx.articulation_points(nx_graph) - atom_ids = np.arange(mol_graph.heavy_atoms_number) - return list(set(atom_ids) - set(art_points_ids)) + if mol_graph.heavy_atoms_number > 1: + nx_graph = mol_graph.get_nx_graph() + art_points_ids = nx.articulation_points(nx_graph) + atom_ids = np.arange(mol_graph.heavy_atoms_number) + return list(set(atom_ids) - set(art_points_ids)) + else: + return [] @staticmethod def propose_connection(mol_graph: MolGraph) -> Sequence[Tuple[int, int]]: