returns a molecule pattern representing the largest common substructure for the input molecules.


uses params to determine equivalence between atoms and bonds.


  • MoleculeMaximumCommonSubstructure attempts to find the maximum common substructure (MCS) present in all the molecules.
  • MoleculeMaximumCommonSubstructure returns a MoleculePattern object, which can be used in functions such as MoleculePlot, MoleculePlot3D, MoleculeContainsQ and FindMoleculeSubstructure.
  • When comparing substructures, equivalence between atoms or bonds is determined by params, which can be Automatic, None or a list {param1,param2,} of matching parameters. Possible values for the parami include:
  • "AtomicNumber"match atoms with the same atomic number
    "Valence"match atomic valence
    "FormalCharge"match the atomic formal charge
    "AtomChirality"match the atom chirality (R) or (S)
    "RingAtomQ"only match ring atoms with other ring atoms
    "BondType"match the bond type
    "BondStereo"match the double bond stereo (E) or (Z)
    "RingBondQ"only match ring bond with other ring bonds
    "CompleteRings"only match complete rings
  • The default value of Automatic is equivalent to {"AtomicNumber","BondType"}.


open allclose all

Basic Examples  (3)

Find the maximum common substructure for three molecules:

Highlight the structure in place:

Find the maximum common structure between two short linear molecules:

By relaxing the match parameters to not look at atomic number, the size of the structure is increased:

Find the maximum common substructure between a group of medium-sized molecules:

Display the common substructure highlighted in place:

Scope  (7)

By default, atoms must have the same atomic number to match; oxygen does not match carbon:

Remove this restriction to get a larger substructure:

Formal charges are not considered by default when comparing atoms, so the zwitterionic and normal forms of glycine match:

Include "FormalCharge" as well as atom and bond types to make the pattern more restrictive:

Include "Valence" to control whether trivalent and pentavalent phosphorous match:

By default, atoms in rings will match atoms in straight chains:

Use "RingAtomQ" to only match ring atoms with ring atoms:

Both of these molecules contain two cyclopentane rings connected by a single bond:

When "RingBondQ" is used, the connecting bond no longer matches because it is part of a larger ring in the second molecule:

Include atom chirality to restrict the matching between two enantiomers:

By default, partial rings can be included in the common substructure:

Use the "CompleteRings" parameter to ensure only full rings are matched:

Wolfram Research (2021), MoleculeMaximumCommonSubstructure, Wolfram Language function,


Wolfram Research (2021), MoleculeMaximumCommonSubstructure, Wolfram Language function,


@misc{reference.wolfram_2021_moleculemaximumcommonsubstructure, author="Wolfram Research", title="{MoleculeMaximumCommonSubstructure}", year="2021", howpublished="\url{}", note=[Accessed: 22-June-2021 ]}


@online{reference.wolfram_2021_moleculemaximumcommonsubstructure, organization={Wolfram Research}, title={MoleculeMaximumCommonSubstructure}, year={2021}, url={}, note=[Accessed: 22-June-2021 ]}


Wolfram Language. 2021. "MoleculeMaximumCommonSubstructure." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2021). MoleculeMaximumCommonSubstructure. Wolfram Language & System Documentation Center. Retrieved from