vermouth/molecule.py
def subgraph(self, nodes):
        """
        Creates a subgraph from the molecule.


        Returns
        -------
        Molecule
        """
        subgraph = self.__class__()
        subgraph.meta = copy.copy(self.meta)
        subgraph._force_field = self._force_field
        subgraph.nrexcl = self.nrexcl

        node_copies = [(node, copy.copy(self.nodes[node])) for node in nodes]
        subgraph.add_nodes_from(node_copies)

        nodes = set(nodes)

        #edges_to_add = [
        #    (node, node2)
        #    for node in nodes
        #    for node2 in set(self[node]) & nodes
        #]
        subgraph.add_edges_from(self.edges_between(nodes, nodes, data=True))

        for interaction_type, interactions in self.interactions.items():
            for interaction in interactions:
                if all(atom in nodes for atom in interaction.atoms):
                    subgraph.interactions[interaction_type].append(interaction)

        return subgraph

        Creates a subgraph from the molecule.


        Returns
        -------
        Molecule
        
Creates a subgraph from the molecule.
Returns

Molecule
Creates a subgraph from the molecule . Returns Molecule
def subgraph(self, nodes):
        subgraph = self.__class__()
        subgraph.meta = copy.copy(self.meta)
        subgraph._force_field = self._force_field
        subgraph.nrexcl = self.nrexcl
        node_copies = [(node, copy.copy(self.nodes[node])) for node in nodes]
        subgraph.add_nodes_from(node_copies)
        nodes = set(nodes)
        subgraph.add_edges_from(self.edges_between(nodes, nodes, data=True))
        for interaction_type, interactions in self.interactions.items():
            for interaction in interactions:
                if all(atom in nodes for atom in interaction.atoms):
                    subgraph.interactions[interaction_type].append(interaction)
        return subgraph
def subgraph ( self , nodes ) : subgraph = self . __class__ ( ) subgraph . meta = copy . copy ( self . meta ) subgraph . _force_field = self . _force_field subgraph . nrexcl = self . nrexcl node_copies = [ ( node , copy . copy ( self . nodes [ node ] ) ) for node in nodes ] subgraph . add_nodes_from ( node_copies ) nodes = set ( nodes ) subgraph . add_edges_from ( self . edges_between ( nodes , nodes , data = True ) ) for interaction_type , interactions in self . interactions . items ( ) : for interaction in interactions : if all ( atom in nodes for atom in interaction . atoms ) : subgraph . interactions [ interaction_type ] . append ( interaction ) return subgraph
Creates a subgraph from the molecule.
Creates a subgraph from the molecule .
"""
        Creates a subgraph from the molecule.


        Returns
        -------
        Molecule
        """ #edges_to_add = [ #    (node, node2) #    for node in nodes #    for node2 in set(self[node]) & nodes #]
self
nodes