Bug fixed in 13.0.0
Consider the following molecule, specified by a SMILES string:
ex = "[Si+4].[Si+4].[Si+4].[O-][P]([O-])([O-])=O.[O-][P]([O-])([O-])=O.[O-][P]([O-])([O-])=O.[O-][P]([O-])([O-])=O";
m = Molecule[ex, IncludeHydrogens -> All];
Dimensions@MoleculeProperty["AdjacencyMatrix"]@m (* {23, 23} *)
AtomCount[m] (* 47 *)
The option to include hydrogens is reflected in the atom count (47), but the adjacency matrix doesn't include these atoms (only connections between 23 of the atoms are included, judging by the dimensionality of the returned matrix).
Interestingly, all of the correct bond information is present in the molecule, which would enable one to manually generate the adjacency matrix:
correct = With[
{nAtoms = AtomCount[m],
bonds = BondList[m][[All, 1]]},
SparseArray[Join[bonds, Reverse /@ bonds] -> 1, {nAtoms, nAtoms}]]
A second interesting observation is that round-tripping the hydrogen-added SMILES string through Molecule
a second time returns the correct (full) adjacency matrix:
export = MoleculeProperty["SMILES"]@m;
roundtrip = MoleculeProperty["AdjacencyMatrix"]@ Molecule[export, IncludeHydrogens -> All];
Dimensions[roundtrip] (* {47, 47} *)
correct == roundTrip (* True *)
Question: What's gone awry in the first example? And why might a round-trip fix it?
$Version (* 12.3.1 for Mac OS X x86 (64-bit) (July 7, 2021) *)
Added 14 Dec 2021. As noted by Jason B, below, this is fixed in Mathematica 13 (confirmed)
m["AdjacencyMatrix", IncludeHydrogens -> #] & /@ {True, False}
. This is fixed in the upcoming release. $\endgroup$