Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Compute the Wiener index of a graph
ResourceFunction["WienerIndex"][g] computes the Wiener index of the graph g. |
The Wiener index of a simple graph:
In[1]:= | ![]() |
Out[1]= | ![]() |
More densely connected graphs have lower WienerIndex values:
In[2]:= | ![]() |
Out[2]= | ![]() |
In[3]:= | ![]() |
Out[3]= | ![]() |
By default, the WienerIndex of a molecule is the WienerIndex of the hydrogen-depleted molecule graph. That is, the molecule graph with all hydrogen atoms removed:
In[4]:= | ![]() |
Out[4]= | ![]() |
A different isomer with the same atoms can have a different WienerIndex:
In[5]:= | ![]() |
Out[5]= | ![]() |
WienerIndex can accept "Graph" or "Chemical" entities:
In[6]:= | ![]() |
Out[6]= | ![]() |
In[7]:= | ![]() |
Out[7]= | ![]() |
WienerIndex of a molecule ignores hydrogen atoms:
In[8]:= | ![]() |
Out[8]= | ![]() |
The option IncludeHydrogens→ All will have them taken into account:
In[9]:= | ![]() |
Out[9]= | ![]() |
Create OEIS sequence A292054 - the Wiener index of n×n knight's tour graphs:
In[10]:= | ![]() |
Out[10]= | ![]() |
Create OEIS sequence A034828 - the Wiener index of n-cycle graphs:
In[11]:= | ![]() |
Out[11]= | ![]() |
Generate all alkanes with 7 carbon atoms (heptanes) using the resource function AlkaneIsomers:
In[12]:= | ![]() |
Out[12]= | ![]() |
Sort the heptane isomers by their Wiener index. This effectively sorts them from "most branched" to "least branched":
In[13]:= | ![]() |
Out[13]= | ![]() |
For an acyclic graph the Wiener index is the same as the Szeged index:
In[14]:= | ![]() |
Out[14]= | ![]() |
In[15]:= | ![]() |
Out[15]= | ![]() |
GraphData provides the pre-computed WienerIndex for many special graphs:
In[16]:= | ![]() |
Out[16]= | ![]() |
We can confirm this number by computing it on the graph:
In[17]:= | ![]() |
Out[17]= | ![]() |
Wolfram Language 12.3 (May 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License