Technical Support Forum
Access ChemAxon scientists and developers here. For registration and login issues contact website support.

## Support Ticket System is replacing forum

This forum was converted into a searchable archive. You cannot add posts here any more. For support please use our new Ticket System.

 First Zagreb index with JChem or Excel Plugin To watch this topic for replies  Register (enables digests) or give email address:
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
Author Message
 Posted: Fri Aug 22, 2014 8:55 amPost subject: First Zagreb index with JChem or Excel Plugin Dear all, A newbie question: How do I calculate the First Zagreb index (the sum of vertex degrees' squares over all vertices of a molecular graph) for a collection of molecules in JChem or in Excel plugin? In fact, a simple function would be enough, which returns the degree of the i-th atom in a given molecule. Is there a standard API function (calculation) for this?  Regards, Mike
 Posted: Wed Aug 27, 2014 2:50 pmPost subject: Dear Mike, Yes, there is: Molecule.getLigandCount(MolAtom)Could you share with us why you would like to calculate the Zagreb index? BR,Laszlo
 Posted: Tue Sep 02, 2014 2:33 pmPost subject: Dear Laszlo, Thanks a lot for the advice, I'll try. I used a simple custom code in Excel Addin as a workaround to calculate the second Zagreb Index and the ABC index. I post the code below, if someone's interested. It works rather solwly, but it solved my problem. I use degree-based indices as a branchieness metric in my regressions for boiling points and chromatography retention indices.   Public Function JCDegree(Mol As Range, Atom As Integer) n = JCHeavyAtomCount(Mol) If Atom < n Then d = 0 For i = 0 To n - 1 l = JCShortestPath(Mol, Atom, i) If l = 1 Then d = d + 1 End If Next JCDegree = d Else JCDegree = 0 End If End Function   Public Function JCSecondZagreb(Mol As Range) n = JCHeavyAtomCount(Mol) JCSecondZagreb = 0 Dim i As Integer Dim j As Integer   For i = 0 To n - 1 For j = 0 To n - 1 l = JCShortestPath(Mol, i, j) If l = 1 Then JCSecondZagreb = JCSecondZagreb + JCDegree(Mol, i) * JCDegree(Mol, j) End If Next Next End Function   Public Function JCABCIndex(Mol As Range)   n = JCHeavyAtomCount(Mol) JCABCIndex = 0 Dim i As Integer Dim j As Integer   For i = 0 To n - 1 For j = 0 To n - 1 l = JCShortestPath(Mol, i, j) If l = 1 Then d1 = JCDegree(Mol, i) d2 = JCDegree(Mol, j) JCABCIndex = JCABCIndex + Sqr((d1 + d2 - 2) / (d1 * d2)) End If Next Next End Function