Professional Documents
Culture Documents
Computing The Szeged Index: Croatica Chemica Acta November 1996
Computing The Szeged Index: Croatica Chemica Acta November 1996
Computing The Szeged Index: Croatica Chemica Acta November 1996
net/publication/273105158
CITATIONS READS
21 189
1 author:
Janez Zerovnik
University of Ljubljana
251 PUBLICATIONS 1,770 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
Extending first and second order algorithms for nested classes of optimization problems to solve computationally challenging industrial questions View project
All content following this page was uploaded by Janez Zerovnik on 04 March 2015.
Introduction
Chemists employ structural formulae in communicating information about molecules
and their structure. The structural or molecular graphs are mathematical objects
representing structural formulae. These objects encode important properties of
the chemical structures.
A topological index is a numerical quantity derived in an unambiguous man-
ner from the structural graph of a molecule. These indices are graph invariants,
which usually reflect molecular size and shape1 (for further examples of topo-
logical indexes see, for example Refs. 2, 3).
The Szeged index Sz is a recently proposed structural descriptor, based
on the distances of vertices in a molecular graph.4 As one can expect,5 it is
not unlike the Wiener index, the first6 and still the most studied topological
index.7–13 For reasons to introduce the Szeged index and for basic properties
of Sz see Ref. 4, 5. Ref. 14 compares Szeged index with Wiener index. Since
the two indices coincide on trees, there is a linear algorithm for computing the
Szeged index of trees.15 Recently an algorithm for computing the Szeged index
for benzenoid hydrocarbons was given.16
In this note we give an explicit algorithm for computing the Szeged index
of arbitrary graph. The algorithm has running time O(mn), where n is the
number of vertices and m is the number of edges of a graph. Space complexity
of the algorithm is O(mn). This is the same complexity as the complexity of
the best known algorithm for computing the Wiener index of arbitrary graphs15
and hence we believe it is likely the best possible.
Graphs
We use usual graph theoretical terminology (as for instance in Ref. 17). A graph
G = (V, E) is a combinatorial object consisting of an arbitrary set V = V (G)
1
of vertices and a set E = E(G) of unordered pairs {x, y} = xy of distinct
vertices of G, called edges. A simple path from x to y is a sequence of distinct
vertices P = x0 , x1 , . . . , xl such that each pair xi , xi+1 is connected by an edge
and x0 = x and xl = y. The length of the path is the number of edges,
l(P ) = l. For any pair of vertices x, y we define the distance d(x, y) to be the
length of a shortest path between x and y. If there is no (finite) path, we
define d(x, y) = ∞. We will also write d(u, v) = du (v) = dv (u). A graph G
is connected, if d(x, y) < ∞ for any pair of vertices x, y. Here we will consider
only connected graphs.
We get the distances from the starting vertex v, if we put d(v) = 0 initially
and for every new vertex y (adjacent to x) we put d(y) = d(x) + 1 when adding
y to the tail of the queue.
2
where the sum runs over all edges of G and the numbers n1 (e | G) and n2 (e | G)
are cardinalities of the sets N1 (e | G) and N2 (e | G). N1 (e | G) is the set of
vertices of G which are closer to u than to v, where u and v are the endpoints
of e. More formally, i ∈ N1 (e | G) if d(i, u) < d(i, v), i.e. if du (i) − dv (i) < 0.
Similarly, i ∈ N2 (e | G) if du (i) − dv (i) > 0. The contribution of edge e to
the Szeged index is thus a product of the number of positive entries times the
number of negative entries of the vector du (i) − dv (i).
3
even more easy to parallelize, since computation for each edge is independent.
Furthermore, the inner loop can be seen as first computing a difference of two
vectors, which is independent task for each vector entry, and then counting
the number of positive and negative signs in the resulting vector, which can
be completed in O(log n) time. Summing up the contributions due to different
edges gives another factor of O(log m) = O(log n). The overall time complexity
of step 2 is therefore O(log2 n) on O(mn) processors.
While the above considerations are rather theoretical, it should be noted
that the algorithm uses operations on vectors and hence admits high speedups
also on vector parallel processors, which may be of more practical importance
on at present available parallel computer equipment.
Examples
The implementation of the algorithm given below was tested on graphs for which
formulas are known. The test examples included some polyacenes, Lh , h =
1, 2, . . . , 24 and coronere/circumcoronere graphs Hn . In both cases, the results
were consistent with formulas of Gutman and Klavžar.16
We conclude with a listing of a Pascal program in which only procedure
get graph, which should provide an input graph as adjacency list, is omitted.
program SZEGED(input,output);
(∗
This program calculates the Szeged index of a graph.
Graph is given by adjacency lists of its vertices.
∗)
const size= 100; max degree = 10;
type vector = array[1..max degree] of integer;
vector of vectors = array[1..size] of vector;
4
procedure append queue(x: integer);
begin queue[Last +1] := x; Last := Last + 1; end;
procedure get queue(var x: integer);
begin x:= queue[First]; First := First + 1; end;
function empty queue:boolean;
begin if First>Last then empty queue:= true else empty queue:= false end;
(∗ Main ∗)
begin
get graph; (*procedure which reads or generates a graph*)
for v:=1 to n do BFS(v);
Sz := 0;
for v:=1 to n do for j:=1 to Degree[v] do begin
u:= Adj list[v][j];
if u>v then begin
n1:=0; n2:=0;
for i:=1 to n do begin
diff := Distance[v][i] − Distance[u][i];
if diff<0 then n1:= n1+1;
if diff>0 then n2:= n2+1
end;
Sz := Sz + n1∗n2;
end;
5
end;
writeln( ’Szeged index =’, Sz:0);
end.
References
[1] D.H.Rouvray, Predicting Chemistry from Topology, Scientific American
(Sept.1986) 40-47.
[4] I. Gutman, Formula for the Wiener Number of trees and Its Extension to Graphs
containing cycles, Graph Theory Notes New York 27 (1994) 9-15.
[8] A.Graovac and T.Pisanski, On the Wiener index of a graph, J. Math. Chem. 8
(1991) 53-62.
[9] I. Lukovits, Correlation Between Components of the Wiener Index and Partition
Coefficients of Hydrocarbons, Int. J. Quantum Chem.: Quantum Biol. Symp. 19
(1992) 217-223.
[12] M.Juvan, B.Mohar, Bond Contributions of the Wiener Index, J. Chem. Inf. Com-
put. Sci. 35 (1995) 217-219.
[13] S.Nikolić, N.Trinajstić and Z.Mihalić, The Wiener Index: Development and Ap-
plications, Croatica Chemica Acta 68 (1995) 105-129.
6
[14] S.Klavžar, A.Rajapaxi, I.Gutman, On the Szeged and the Wiener index of graphs,
Applied Mathematics Letters, to appear.
[16] I. Gutman, S. Klavžar, An Algorithm for the Calculation of the Szeged Index of
Benzenoid Hydrocarbons, J. Chem. Inf. Comput. Sci. 35 (1995) 1011-1014.
[17] N.Trinajstić, Chemical Graph Theory, CRC Press, Boca Raton, FL. 1992.
SAŽETAK
Računanje Szeged indeksa
Janez Žerovnik
Dan je algoritam za računanje Szeged indeksa proizvoljnog grafa kompleksnosti
O(mn) gdje n označava broj čvorova a m broj grana grafa.