public void ConnectAtoms(uint atomId1, uint atomId2, BondMultiplicity bondMultiplicity = BondMultiplicity.Single) { var atom1 = GetAtom(atomId1); var atom2 = GetAtom(atomId2); var bonds = AtomConnector.CreateBonds(atom1, atom2, bondMultiplicity); foreach (var bond in bonds) { var edge = (Edge <SimpleBond>)MoleculeStructure.ConnectVertices(atomId1, atomId2); edge.Object = bond; } }
public MoleculeReference AddMolecule(MoleculeReference moleculeToBeAdded, uint firstAtomId, uint connectionAtomId, out MoleculeReference convertedInputMoleculeReference, BondMultiplicity bondMultiplicity = BondMultiplicity.Single) { var mergeInfo = MoleculeStructure.AddGraph(moleculeToBeAdded.Molecule.MoleculeStructure); var vertex1 = connectionAtomId; var vertex2 = mergeInfo.VertexIdMap[moleculeToBeAdded.FirstAtomId]; var atom1 = MoleculeStructure.GetVertexFromId(vertex1).Object; var atom2 = MoleculeStructure.GetVertexFromId(vertex2).Object; var bonds = AtomConnector.CreateBonds(atom1, atom2, bondMultiplicity); foreach (var bond in bonds) { var edge = (Edge <SimpleBond>)MoleculeStructure.ConnectVertices(vertex1, vertex2); edge.Object = bond; } convertedInputMoleculeReference = new MoleculeReference(this, moleculeToBeAdded.VertexIds.Select(oldVertexId => mergeInfo.VertexIdMap[oldVertexId]), mergeInfo.VertexIdMap[moleculeToBeAdded.FirstAtomId], mergeInfo.VertexIdMap[moleculeToBeAdded.LastAtomId]); return(new MoleculeReference(this, firstAtomId, mergeInfo.VertexIdMap[moleculeToBeAdded.LastAtomId])); }