One of the main applications of information entropy is the analysis of molecular graphs of chemical species. This is a mandatory step before introducing entropy-based topological descriptors, used both for quantitative classifications of molecules and solid state systems and in a variety of studies dealing with QSAR/QSPR studies (quantitative structure-activity and structure-property relationships). The formula for the structural information content of a molecular graph has been widely established in literature and applied to several kind of molecular species [1]. The basic principle behind its definition is the selection and enumeration of inequivalent structural primitives (atoms and bonds), in particular graph vertices corresponding to atom of different elements and atoms belonging to same element but occupying different symmetry positions in the graph. This process produces a partitioning of the molecular graph vertices into discrete subsets with their own cardinalities. Since atomic positions are uniquely identified, criteria based on partitioning atom vertices are generally considered to be stricter than those based on graph edges as the concept of chemical bond is more prone to intuitive descriptions. Therefore, a vertex partitioning scheme applied to the formula of the molecular information content can be considered a reliable route for the computation of the molecular information entropy.
In this post, the author has chosen as testing base for quantifying information entropy a class of simple organic compounds such as linear alkanes. Since they are built up with just simple carbon-carbon and hydrogen bonds, it has been possible to devise a general computational scheme for the partitioning of the graph vertices based on the degree of carbon atom branching and vertex coloring. Thus, the computation of the information entropy for each alkane isomer can be obtained straightforwardly starting from its molecule graph by taking into account also eventual symmetry features.
In this post, the author has chosen as testing base for quantifying information entropy a class of simple organic compounds such as linear alkanes. Since they are built up with just simple carbon-carbon and hydrogen bonds, it has been possible to devise a general computational scheme for the partitioning of the graph vertices based on the degree of carbon atom branching and vertex coloring. Thus, the computation of the information entropy for each alkane isomer can be obtained straightforwardly starting from its molecule graph by taking into account also eventual symmetry features.
Definition of Information Entropy Content for a given chemical structure
Definition of Information Entropy Content for a given chemical structure
According to Ref. [1], the structural information content of a molecular graph can be expressed by
I(G,α)=-
n
∑
i=1
X
i
X
log
2
X
i
X
where α is the equivalence criterion chosen and applied to the set of the graph elements X. The chosen criterion α produces a partitioning of X into n subsets with corresponding cardinality .
This equation applied to graph vertices (see Refs. [40-25] in Ref.[1]) can be rewritten in terms of the information content
X
i
This equation applied to graph vertices (see Refs. [40-25] in Ref.[1]) can be rewritten in terms of the information content
h=N-
log
2
n
∑
i=1
N
i
N
log
2
N
i
where N is the total number of atoms in the molecule. The unit measure of h is bits/atom whereas the total information content in the molecule is . In this computational essay the results reported for alkanes refer all to h values. As pointed out in Ref. [1], a reliable partitioning should reflect correctly the chemical inequivalence and should be independent of the chosen mathematical protocol. As main guidelines, atoms of different elements are attributed to different atom types, whereas atoms belonging to the same elements but occupying different positions in the graph because of connectivity reasons can be attributed to different subsets as well. In the present essay, which focuses only on molecules containing simple bonds, the author has chosen to take into account connectivity by determining the coordination rank of the C atoms within the molecule branching, i.e. whether the chosen carbon atom is primary, secondary, tertiary or quaternary. This is a departure from the choice stated in Ref. [1], although it will be shown in the example about pentane isomers that the same partitioning and consequently the same h values will be found.
Nh=NN-
log
2
n
∑
i=1
N
i
log
2
N
i
A general procedure to determine atom partitions with Mathematica
A general procedure to determine atom partitions with Mathematica
The starting point of the procedure is to obtain the molecular graphs for the chosen alkane isomer with and without hydrogens alongside the corresponding vertex coloring patterns. Let’s take for instance the linear alkane n-pentane, which has 5 carbon atoms and 12 hydrogen atoms in its structure
In[]:=
specie=FindIsomersMolecule[[1]];alkanename=MoleculeName/@specienC=AtomCount[specie,"C"];nH=AtomCount[specie,"H"];nTot=nC+nH;
Out[]=
Molecule
In[]:=
galkane=MoleculeGraph[specie,IncludeHydrogensNone,VertexLabels->"Name"];vcnoH=FindVertexColoring[galkane];galkanewH=MoleculeGraph[specie,IncludeHydrogensAll,VertexLabels->"Name"];vc=FindVertexColoring[galkanewH];
The following function determines the ranking list of the connectivity for each carbon atom in the alkane skeleton (i.e. whether it is primary, secondary, tertiary or quaternary)
In[]:=
carbonroot[nv_,agraph_]:=Total@Table[Count[EdgeList[agraph][[All,i]],nv(*vertexatom*)],{i,1,2,1}]
In[]:=
Crank=Map[carbonroot[#,galkane]&,Range[nC]]
Out[]=
{1,2,2,2,1}
From the above list, one can see that there are two primary C atoms at the chain ends while the remaining ones are secondary carbons since they are each bonded with two neighbors C atoms. The following picture comprehends both the vertex coloring pattern and the carbon connectivity indices
Annotategalkane,
Out[]=
Finally, to obtain a partitioning scheme for the carbon skeleton of the chosen alkane isomer, the ranks of C atoms are paired in a list with the numeric pattern of the vertex coloring scheme for the alkane isomer without hydrogen atoms included. When exactly the same pairings are found, these are gathered and enumerated as in the following lines
In[]:=
dataCprops=Transpose[{Map[carbonroot[#,galkane]&,Range[nC]],vcnoH}];Cpart=Map[Length,Gather[dataCprops]]
Out[]=
{2,2,1}
From the picture above, one can actually check that there are effectively one group made up by two secondary C atoms with black vertices, one group made up by two primary C atoms with orange vertices, and a group of only one secondary C atom with orange vertex. The partitioning of C atoms for the n-pentane matches with the scheme reported in Fig. 1 c (left side) of Ref. [1] .
The partitioning scheme of H atoms is a bit more involved, since it requires to find the pairings between H atoms bonded with C atoms of the same ranking and the vertex coloring of the full graph with H atoms, before gathering them. Again, this step takes both into account vertex coloring for the graph symmetry and branching of the carbon skeleton.
In[]:=
assCH=EdgeList[galkanewH];dataHprops=Table[If[assCH[[i,2]]>nC,{carbonroot[assCH[[i,1]],galkane],vc[[assCH[[i,2]]]]}],{i,1,Length[assCH]}];DeleteCases[dataHprops,Null];Hpart=Map[Length,Gather[DeleteCases[dataHprops,Null]]];
In[]:=
Hpart
Out[]=
{6,4,2}
From the color pattern of the complete molecule graph below, one can effectively check that the partition for H atoms is consistent, since there are six equivalent H atoms (all with orange color) bonded to two equivalent primary C atoms (those black at the chain ends), four H atoms with same black color bonded to two secondary C atoms of the same color and one pair of H atoms (orange color) bonded to the central secondary C atom (black color).
AnnotategalkanewH,
Out[]=
Again, the partitioning of H atoms for the n-pentane matches with the scheme reported in Fig. 1 c (left side) of Ref. [1]
Example: h computation from partitioning scheme of C and H atoms
Example: h computation from partitioning scheme of C and H atoms
The information content entropy h for the obtained partitioning schemes for C and H atoms can be computed with the following expression, matching exactly the numerical result reported for n-pentane in Fig. 1 d (left side) of Ref. [1]
In[]:=
N@(Log[2,nTot]-Apply[Plus,Map[#/(nC+nH)*Log[2,#]&,Cpart]]-Apply[Plus,Map[#/(nC+nH)*Log[2,#]&,Hpart]])
Out[]=
2.35159
Managing C2 symmetry: example of h computation for hexane isomers
Managing symmetry: example of h computation for hexane isomers
C
2
When symmetry is present in the complete molecular graph, as in occurs for alkanes with even number of C atoms, one can observe that the partitioning lists are palindrome sequences of integer numbers. For instance, for n-hexane the obtained partitions are
C
2
In[]:=
Cpart={1,2,2,1};Hpart={3,4,4,3};nC=6;nH=14;nTot=nC+nH;
The correct value for h is then obtained by taking just half of the sequence for both C and H atoms
In[]:=
N@(Log[2,nTot/2]-Apply[Plus,Map[#/(nC/2+nH/2)*Log[2,#]&,Cpart[[1;;Length[Cpart]/2]]]]-Apply[Plus,Map[#/(nC/2+nH/2)*Log[2,#]&,Hpart[[1;;Length[Hpart]/2]]]])
Out[]=
1.84644
Final module and relationship with partial ordering plots of alkane isomers
Final module and relationship with partial ordering plots of alkane isomers
For commodity, the above outlined procedure for the computation of h has been encapsulated into a module of general applicability to linear alkanes.
(*findfrommoleculeedgeifacarbonatomisprimary,secondary,tertiaryorquaternary*)
In[]:=
carbonroot[nv_,agraph_]:=Total@Table[Count[EdgeList[agraph][[All,i]],nv(*vertexatom*)],{i,1,2,1}]
In[]:=
hcheminform[alkanemol_]:=Module[{specie=Molecule[alkanemol],nC,nH,nTot,galkane,galkanewH,vcnoH,vc,dataCprops,Cpart,assCH,dataHprops,Hpart,hci},nC=AtomCount[specie,"C"];nH=AtomCount[specie,"H"];nTot=nC+nH;(*Fullmoleculegraphswithoutandwithhydrogensandrelatedvertexcoloring*)galkane=MoleculeGraph[specie,IncludeHydrogensNone,VertexLabels->"Name"];vcnoH=FindVertexColoring[galkane];galkanewH=MoleculeGraph[specie,IncludeHydrogensAll,VertexLabels->"Name"];vc=FindVertexColoring[galkanewH];(*partitioningcarbonatomonthebasisoframificationandvertexcoloring:associatetypeofcarbon(primary,secondary,...)withvertexcolouringandgathersameelements*)dataCprops=Transpose[{Map[carbonroot[#,galkane]&,Range[nC]],vcnoH}];Cpart=Map[Length,Gather[dataCprops]];(*PartitioninghydrogensandclassifythemaccordingtovertexcoloringandbondswithCatomsandtheirramification*)assCH=EdgeList[galkanewH];dataHprops=Table[If[assCH[[i,2]]>nC,{carbonroot[assCH[[i,1]],galkane],vc[[assCH[[i,2]]]]}],{i,1,Length[assCH]}];DeleteCases[dataHprops,Null];Hpart=Map[Length,Gather[DeleteCases[dataHprops,Null]]];(*CheckifC2symmetryispresenttocomputecorrectvalueofhinformationentropy*)hci=If[(*checkconditionforeventualC2symmetry*)(EvenQ[Length[Cpart]]==True)&&(EvenQ[Length[Hpart]]==True)&&(TrueQ[Cpart[[1;;Length[Cpart]/2]]==Reverse[Cpart[[Length[Cpart]/2+1;;-1]]]]==True)&&(TrueQ[Hpart[[1;;Length[Hpart]/2]]==Reverse[Hpart[[Length[Hpart]/2+1;;-1]]]]==True),(*chemicalinformationentropywithC2symmetry*)N@(Log[2,nTot/2]-Apply[Plus,Map[#/(nTot/2)*Log[2,#]&,Cpart[[1;;Length[Cpart]/2]]]]-Apply[Plus,Map[#/(nC/2+nH/2)*Log[2,#]&,Hpart[[1;;Length[Hpart]/2]]]]),(*chemicalinformationentropygeneric*)N@(Log[2,nTot]-Apply[Plus,Map[#/(nC+nH)*Log[2,#]&,Cpart]]-Apply[Plus,Map[#/(nC+nH)*Log[2,#]&,Hpart]])];Return[{MoleculeName[specie],Cpart,Hpart,hci}]]
In[]:=
alkaneisomers=FindIsomers[Molecule[Entity["Chemical","Pentane"]]];
In[]:=
TableForm[Map[hcheminform[#]&,alkaneisomers],TableHeadings{{},{"Isomer","C partition","H partition","h"}},TableSpacing{2,2},TableAlignments->Center]
Out[]//TableForm=
Isomer | C partition | H partition | h | |||||||||
pentane |
|
| 2.35159 | |||||||||
isopentane |
|
| 2.66013 | |||||||||
2,2-dimethylpropane |
|
| 1.08631 |
Following the outline sketched in a recent example published by the author, the general trend for h can be inspected over the whole range of the isomers available for each linear alkane. By applying the partial ordering scheme introduced in the 1980s by Prof. Milan Randic, one can assign to each alkane isomer a pair of indices accounting for the connectivity within each molecule graph. This allows to order a specific physical property of alkane isomers (e.g. boiling point) according to their own structural parameters. The table below can be considered a sort of periodic table of alkane boiling points for the octane isomers.
(,)
p
2
p
3
Summary
Summary
A general computational scheme for the prediction of the information entropy content of linear alkane has been outlined and tested against some simple test examples reported in recent literature. This is the first step towards a general computation-based classification of organic chemical species on the basis of a quantitative descriptor such as information entropy.
References
References
[1] Denis Sh. Sabirov and Igor S. Shepelevich, “Information Entropy in Chemistry”, Entropy, 2021, no. 23, 1240, 2023. https://doi.org/10.3390/e23101240
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
A Graph-based method for computing information entropy content of linear Alkanes
By Jessica Alfonsi
Wolfram Community, STAFF PICKS, April 8, 2026
https://community.wolfram.com/groups/-/m/t/3678484
By Jessica Alfonsi
Wolfram Community, STAFF PICKS, April 8, 2026
https://community.wolfram.com/groups/-/m/t/3678484