def generate_bond_subgraphs_from_break(bond_graph, atom1, atom2):
"""Splits the bond graph between two atoms to producing subgraphs.
Notes
-----
This will not work if there are cycles in the bond graph.
Parameters
----------
bond_graph: networkx.Graph
Graph of covalent bond network
atom1: isambard.ampal.Atom
First atom in the bond.
atom2: isambard.ampal.Atom
Second atom in the bond.
Returns
-------
subgraphs: [networkx.Graph]
A list of subgraphs generated when a bond is broken in the covalent
bond network.
"""
bond_graph.remove_edge(atom1, atom2)
try:
subgraphs=list(networkx.connected_component_subgraphs(
bond_graph, copy=False))
finally:
# Add edge
bond_graph.add_edge(atom1, atom2)
return subgraphs
评论列表
文章目录