arXiv:1710.07507v2 [math.CO] 15 May 2018 ne n h tie -ye-inridxo rdgraphs. grid Keywords: fo of closed index the 3-hyper-Wiener obtain Steiner to the and used index is t method of the computation Finally, makes efficient. method more Our much developed. resu is main graphs the As for distances. graph classical 3-hyper-Wiene the Steiner using by the expressed how show we generalize which Next, polynomial, index. Hosoya hyper-Wiener Steiner the to related th is with index this graph classical graph, the a replacing of by index index hyper-Wiener hyper-Wiener Steiner the study we paper, this In ecitr o rdcigpyiohmclpoete forganic of gr properties physicochemical distance-based predicting are for index descriptors hyper-Wiener the and index Wiener The Introduction 1 Class: Subj. AMS cube partial nteSenrhprWee ne fagraph a of index hyper-Wiener Steiner the On aut fNtrlSine n ahmtc,Uiest of University Mathematics, and Sciences Natural of Faculty tie itne inridx ye-inridx ooapolyno Hosoya index; hyper-Wiener index; Wiener distance; Steiner 21;0C2 53;05C90 05C31; 05C12; 92E10; Rcie a 5 2018) 15, May (Received [email protected] ioTratnik Niko Abstract opud otntoesgicn for significant those (often compounds t ehdfrcmuigti index this computing for method a lt, hc sotie rmtestandard the from obtained is which ne famdlrgahcnbe can graph modular a of index r tie itne ti hw how shown is It distance. Steiner e p nains sda structure as used invariants, aph eSenr3hprWee index 3-hyper-Wiener Steiner he iia eutfrtestandard the for result similar s mlsfrteSenr3-Wiener Steiner the for rmulas aio,Slovenia Maribor, il eingraph; median mial; chemistry, pharmacology, agriculture, environment-protection etc.). Their history goes back to 1947, when H. Wiener used the distances in the molecular graphs of alkanes to calculate their boiling points [40].

This research has led to the Wiener index, which is defined as

W (G)= d(u, v) {u,vX}⊆V (G) for any connected graph G. The origins and applications of the Wiener index are discussed in [36], while some recent research related to this index can be found in [3, 23–25].

The hyper-Wiener index was introduced in 1993 by M. Randi´c[35] and has been extensively studied in many papers (see, for example, [6,20,43]). Randi´c’s original definition of the hyper-Wiener index was applicable just to trees and therefore, the hyper-Wiener index was later defined for any connected graph

G [21] as 1 1 W W (G)= d(u, v)+ d(u, v)2. 2 2 {u,vX}⊆V (G) {u,vX}⊆V (G) The hyper-Wiener index is related to the Hosoya polynomial [14], which is defined as

H(G, x)= d(G, m)xm, m X≥0 where d(G, m) is the number of unordered pairs of vertices at distance m. In [4] the following relation was shown: 1 W W (G)= H′(G, 1)+ H′′(G, 1). 2

Distance-based topological indices were extensively investigated and also the edge versions were stud- ied [39]. Many methods for computing these indices more efficiently were proposed and the most famous between them is the cut method [18]. This method is commonly used on benzenoid systems [8,38] or on partial cubes [7], which constitute a large class of graphs with a lot of applications and includes, for example, many families of chemical graphs (benzenoid systems, trees, phenylenes, cyclic phenylenes, polyphenylenes). In particular, methods for computing the hyper-Wiener index and the edge-hyper-

Wiener index were introduced in [17, 37].

The Steiner distance of a graph, introduced by Chartrand et. al. in 1989 [5], is a natural and nice generalization of the concept of classical graph distance. For a set S ⊆ V (G), the Steiner distance d(S) among the vertices of S is the minimum size among all connected subgraphs whose sets contain

S. The Steiner distance in a graph was considered in many papers, for some relevant investigations see [2,11,33,34,41] and a survey paper [28]. On the other hand, the Steiner problem requires a tree

T with minimum number of edges such that S ⊆ V (T ). In general, this problem is known to be NP- complete [15]. The Steiner distance and the have a lot of applications in real-word problems, for example in circuit layout, network design and in modelling of biomolecular structures [32].

If in the definition of the Wiener index the classical graph distance is replaced by the Steiner distance, the Steiner Wiener index is obtained [26]. In particular, if we replace the distances between pairs of vertices by the distances of all subsets with cardinality k, we obtain the Steiner k-Wiener index. It was shown in [13] that for some molecules the combination of the Steiner Wiener index and the Wiener index has even better correlation with the boiling points than the Wiener index. For some recent investigations on the Steiner Wiener index see [27, 29, 31]. However, a closely similar concept was already studied in the past under the name average Steiner distance [9, 10]. Moreover, the Steiner distance [12, 30] and other analogous generalizations of distance-based molecular descriptors (where the classical distance is replaced by the Steiner distance) were introduced [28].

In [26] the relation between the Steiner 3-Wiener index and the Wiener index was shown for trees and later for modular graphs [22] (see the definition in the preliminaries). In this paper, we first prove the relation between the Steiner hyper-Wiener index and the Steiner Hosoya polynomial. Next, we show how the Steiner 3-hyper-Wiener index of a modular graph can be expressed by using the classical graph distances. Furthermore, if G is a , we develop a cut method for computing the Steiner 3- hyper-Wiener index, which enables us to compute the index very efficiently and also to find the closed formulas for some families of graphs. Finally, our method is used to obtain the closed formulas for the

Steiner 3-Wiener index and the Steiner 3-hyper-Wiener index of grid graphs.

2 Preliminaries

Unless stated otherwise, the graphs considered in this paper are simple and finite. For a graph G we say that |V (G)| is the order of G and that |E(G)| is its size. Moreover, we define dG(x, y) (or simply d(x, y)) to be the usual shortest-path distance between vertices x, y ∈ V (G).

For a connected graph G and an non-empty set S ⊆ V (G), the Steiner distance among the vertices of S, denoted by dG(S) or simply by d(S), is the minimum size among all connected subgraphs whose vertex sets contain S. Note that if H is a connected subgraph of G such that S ⊆ V (H) and |E(H)| = d(S), then H is a tree. An S-Steiner tree or a Steiner tree for S is a subgraph T of G such that T is a tree and

S ⊆ V (T ). Moreover, if T is a Steiner tree for S such that |E(T )| = d(S), then T is called a minimum

Steiner tree for S. It is obvious that for a set S = {x, y}, x 6= y, it holds d(S)= d(x, y).

Let G be a connected graph and k a positive integer such that k ≤ |V (G)|. The Steiner k-Wiener index of G, denoted by SWk(G), is defined as

SWk(G)= d(S). S⊆V (G) |SX|=k

The Steiner k-hyper-Wiener index of G, denoted by SW Wk(G), is defined as

1 1 SW W (G)= d(S)+ d(S)2. k 2 2 S⊆V (G) S⊆V (G) |SX|=k |SX|=k

The Steiner k-Hosoya polynomial of G, denoted by SHk(G, x), is defined as

m SHk(G, x)= dk(G, m)x , m X≥0 where dk(G, m) denotes the number of subsets S ⊆ V (G) with |S| = k and d(S)= m.

Two edges e1 = u1v1 and e2 = u2v2 of a connected graph G are in relation Θ, e1Θe2, if

dG(u1,u2)+ dG(v1, v2) 6= dG(u1, v2)+ dG(u1, v2).

Note that this relation is also known as Djokovi´c-Winkler relation. The relation Θ is reflexive and symmetric, but not necessarily transitive. We denote its transitive closure (i.e. the smallest transitive relation containing Θ) by Θ∗.

The hypercube Qn of dimension n is defined in the following way: all vertices of Qn are presented as n-tuples (x1, x2,...,xn) where xi ∈ {0, 1} for each i, 1 ≤ i ≤ n, and two vertices of Qn are adjacent if the corresponding n-tuples differ in precisely one position.

A subgraph H of a graph G is called an isometric subgraph if for each u, v ∈ V (H) it holds dH (u, v) = dG(u, v). Any isometric subgraph of a hypercube is called a partial cube. For an edge ab of a graph G, let

Wab be the set of vertices of G that are closer to a than to b. We write hSi for the subgraph of G induced by S ⊆ V (G). It is known that for any partial cube G the relation Θ is transitive, i.e. Θ = Θ∗. Moreover, for any Θ-class E of a partial cube G, the graph G − E has exactly two connected components, namely hWabi and hWbai, where ab ∈ E. For more information about Θ relation and partial cubes see [16].

Let G be a graph. A median of a triple of vertices u,v,w of G is a vertex z that lies on a shortest u, v-path, on a shortest u, w-path and on a shortest v, w-path (z can be one of the vertices u,v,w). A graph is a median graph if every triple of its vertices has a unique median. These graphs were first introduced in [1] by Avann and arise naturally in the study of ordered sets and distributive lattices. Moreover, a graph is called a modular graph if every triple of vertices has at least one median. Obviously, any median graph is also a modular graph. It is known that trees, hypercubes, and grid graphs (Cartesian products of two paths) are median graphs. Moreover, any median graph is a partial cube [16].

The following relation between the Steiner 3-Wiener index and the Wiener index was first found out for trees [26] and later generalized to modular graphs [22].

Theorem 2.1 [22] Let G be a modular graph with at least three vertices. Then

|V (G)|− 2 SW (G)= W (G). 3 2 3 The Steiner hyper-Wiener index and the Steiner Hosoya poly- nomial

In 2002 G. G. Cash showed the relationship between the Hosoya polynomial and the hyper-Wiener index, see [4]. In the present section we generalize this result and show that it holds also for the Steiner k-hyper-

Wiener index and the Steiner k-Hosoya polynomial where k is a positive integer such that k ≤ |V (G)|.

First, we notice the obvious connection between the Steiner k-Wiener index and the Steiner k-Hosoya polynomial.

Proposition 3.1 Let G be a connected graph and k a positive integer such that k ≤ |V (G)|. Then

′ SWk(G)= SHk(G, 1).

Now we can state the main result of the section.

Theorem 3.2 Let G be a connected graph and k a positive integer such that k ≤ |V (G)|. Then

1 SW W (G)= SH′ (G, 1)+ SH′′(G, 1). k k 2 k

Proof. Since by Proposition 3.1

1 1 1 d(S)= SW (G)= SH′ (G, 1), 2 2 k 2 k S⊆V (G) |SX|=k it follows 1 1 SW W (G)= SH′ (G, 1) + d(S)2 k 2 k 2 S⊆V (G) |SX|=k and it suffices to show 1 1 1 d(S)2 = SH′ (G, 1) + SH′′(G, 1). 2 2 k 2 k S⊆V (G) |SX|=k First we notice that

2 2 d(S) = m dk(G, m). S⊆V (G) m≥1 |SX|=k X Furthermore, ′ ′ ′ m 2 m−1 (xSH (G, x)) = m · dk(G, m)x = m dk(G, m)x k   m m X≥1 X≥1  ′  and therefore, if we denote f(x)= xSHk(G, x),

d(S)2 = f ′(1). S⊆V (G) |SX|=k

However,

′ ′ ′ ′ ′′ f (x) = (xSHk(G, x)) = SHk(G, x)+ xSHk (G, x) and finally it follows that

2 ′ ′′ d(S) = SHk(G, 1)+ SHk (G, 1), S⊆V (G) |SX|=k which completes the proof. 

In the rest of this section the previous result is demonstrated on two basic examples. First, let Kn be a complete graph on n vertices and let k be a positive integer such that k ≤ n. If S ⊆ V (Kn) with

|S| = k, then d(S)= k − 1. Therefore

n SH (K , x)= xk−1. k n k   Using Proposition 3.1 and Theorem 3.2 we obtain

n SW (K ) = (k − 1) , k n k   k(k − 1) n k n SW W (K )= = . k n 2 k 2 k     

Next, let Pn be a path on n vertices and let k ≥ 2 be a positive integer such that k ≤ n. Obviously, for

j−1 any j ∈{k − 1,...,n − 1} we obtain dk(Pn, j) = (n − j) k−2 . Therefore

n  −1 j − 1 SH (P , x)= (n − j) xj . k n k − 2 j k =X−1   Using Proposition 3.1 and Theorem 3.2 we obtain

n −1 j − 1 n +1 SW (P )= j(n − j) = (k − 1) , k n k − 2 k +1 j k =X−1     n−1 j(j + 1)(n − j) j − 1 SW W (P ) = k n 2 k − 2 j k =X−1   n(n + 1)(n + 2)(n − k + 1) n − 1 = 2(k + 1)(k + 2) k − 2   k n +2 = . 2 k +2    4 The Steiner 3-hyper-Wiener index of modular graphs

Finding a minimum Steiner tree for a given set of vertices S is not easy and it is known to be NP-complete in general [15]. Hence, in this section we prove a method for computing the Steiner 3-hyper-Wiener index of modular graphs. Using this method, computing the Steiner 3-hyper-Wiener index can be done in polynomial time.

For a connected graph G, we will denote by W W (G) the sum of squares of distances between all the pairs of vertices, i.e.

W W (G)= d(u, v)2. {u,vX}⊆V (G) Therefore, it is easy to observe that if G is connected,

1 1 W W (G)= W (G)+ W W (G). 2 2

Furthermore, in the rest of the paper the following notations will be used for a graph G:

2 O2(G) = {(u, v) ∈ V (G) | u 6= v},

3 O3(G) = {(u,v,w) ∈ V (G) | u 6= v,u 6= w, v 6= w}.

In order to obtain the final result of this section, we need two lemmas.

Lemma 4.1 Let G be a connected graph with at least three vertices. Then

d(u, v)2 = 2(|V (G)|− 2)W W (G). (u,v,wX)∈O3(G) Proof. First we notice that

d(u, v)2 = d(u, v)2.

(u,v,w)∈O3(G) (u,v)∈O2(G)) w∈V (G) X X w6=Xu,w6=v

Therefore, we get d(u, v)2 = d(u, v)2 1 (u,v,w)∈O3(G) (u,v)∈O2(G) w∈V (G) X X  X   w6=u,w6=v    = (|V (G)|− 2)d(u, v)2 (u,v)X∈O2(G) = (|V (G)|− 2) d(u, v)2 (u,v)X∈O2(G) = 2(|V (G)|− 2)W W (G) and the proof is complete. 

Lemma 4.2 Let G be a connected graph with at least three vertices. Three distinct vertices u,v,w have at least one median if and only if for the set S = {u,v,w} it holds

2d(S)= d(u, v)+ d(u, w)+ d(v, w).

Proof. Assume that m is a median for three distinct vertices u,v,w and let S = {u,v,w}. Denote a = d(u,m), b = d(v,m), and c = d(w,m). Since m is a median, it obviously holds d(u, v) = a + b, d(u, w) = a + c, and d(v, w) = b + c. Moreover, let T be a connected subgraph of G containing only a shortest path from u to m, a shortest path from v to m, and a shortest path from w to m, see Figure 1.

Figure 1. A connected subgraph T which is a minimum Steiner tree.

We will first show that T is a minimum Steiner tree for S. Let T ′ be any minimum Steiner tree for

S and let P be the path from u to v in T ′. Also, let m′ be the last vertex on the path from u to w in T ′ that is contained also in P . Since T ′ is a minimum Steiner tree, T ′ contains only P and the path from

′ ′ ′ ′ ′ m to w in T . Denote x = dT ′ (u,m ), y = dT ′ (v,m ), and z = dT ′ (w,m ). Obviously, x + y ≥ a + b, x + z ≥ a + c, and y + z ≥ b + c. Therefore, we get d(S)= |E(T ′)| = x + y + z ≥ a + b + c ≥ |E(T )| and thus d(S) = |E(T )|, which shows that T is a minimum Steiner tree with |E(T )| = a + b + c. It follows

1 d(S)= 2 (d(u, v)+ d(u, w)+ d(v, w)). For the other direction, suppose that 2d(S) = d(u, v)+ d(u, w)+ d(v, w) and let T ′ be a minimum

Steiner tree, i.e. |E(T ′)| = d(S). Let m′, x, y, and z be defined the same as before. It follows x+y ≥ d(u, v), x+z ≥ d(u, w), and y +z ≥ d(v, w). Therefore, 2d(S)=2(x+y +z) ≥ d(u, v)+d(u, w)+ d(v, w)=2d(S) and we obtain x + y = d(u, v), x + z = d(u, w), and y + z = d(v, w), which implies that m′ is a median for u,v,w. 

In order to state the main result of the section, the following notation will be used for a connected graph

G with at least three vertices:

W[ W (G)= d(u, v)d(u, w). (1) (u,v,wX)∈O3(G) Finally, we are able to prove how the Steiner 3-hyper-Wiener index of a modular graph G can be obtained from W (G), W W (G), and W[ W (G).

Theorem 4.3 Let G be a modular graph with at least three vertices. Then

|V (G)|− 2 |V (G)|− 2 1 SW W (G)= W (G)+ W W (G)+ W[ W (G). 3 4 8 8

Proof. Since any three vertices in G have a median, by using Lemma 4.2 we calculate

1 d(S)2 = (d(u, v)+ d(u, w)+ d(v, w))2 4 S⊆V (G) {u,v,w}⊆V (G) |SX|=3 X 1 = (d(u, v)2 + d(u, w)2 + d(v, w)2) 4 {u,v,wX}⊆V (G) 1 + (d(u, v)d(u, w)+ d(u, v)d(v, w)+ d(u, w)d(v, w)). 2 {u,v,wX}⊆V (G) Therefore, since any unordered triple occurs six times as an ordered triple, it follows

1 d(S)2 = (d(u, v)2 + d(u, w)2 + d(v, w)2) 24 S⊆V (G) (u,v,w)∈O3(G) |SX|=3 X 1 + (d(u, v)d(u, w)+ d(u, v)d(v, w)+ d(u, w)d(v, w)) 12 (u,v,wX)∈O3(G) 1 1 = d(u, v)2 + d(u, v)d(u, w) 8 4 (u,v,wX)∈O3(G) (u,v,wX)∈O3(G) |V (G)|− 2 1 = W W (G)+ W[ W (G), 4 4 where the last equality follows by Lemma 4.1 and Equation (1). Finally, using the definition of the Steiner

3-hyper-Wiener index and Theorem 2.1 the proof is complete. 

5 A cut method for partial cubes

Theorem 4.3 implies that the Steiner 3-hyper-Wiener index of a modular graph can be computed by using

W (G), W W (G), and W[ W (G). However, the terms W W (G) and W[ W (G) are not easy to calculate, especially if one is interested in finding closed formulas for a given family of graphs. Therefore, in this section we describe methods for computing W W (G) and W[ W (G) of a partial cube G, which are much more efficient than the calculation by the definition.

To prove the results in this section, we need to introduce some additional notation. If G is a partial

′ cube with Θ-classes E1,...,Ed, we denote by Ui and Ui the connected components of the graph G − Ei, where i ∈{1,...,d}. For any i, j ∈{1,...,d}, i 6= j, set

00 Nij = V (Ui) ∩ V (Uj ),

01 ′ Nij = V (Ui) ∩ V (Uj ),

10 ′ Nij = V (Ui ) ∩ V (Uj ),

11 ′ ′ Nij = V (Ui ) ∩ V (Uj ).

Then, for i, j ∈{1,...,d}, i 6= j, and k,l ∈{0, 1} we define

kl kl nij = |Nij |.

Also, for i ∈{1,...,d}, let

0 1 ′ ni = |V (Ui)|, ni = |V (Ui )|.

In [17] it was shown that if G is a partial cube and d is the number of its Θ-classes, then

d−1 d 2 00 11 01 10 d(u, v) =2W (G)+4 nij nij + nij nij . u∈V (G) v∈V (G) i=1 j=i+1 X X X X  Moreover, it is known [18] that if G is a partial cube with d Θ-classes, then

d 0 1 W (G)= ni ni . (2) i=1 X 2 2 Taking into account that u∈V (G) v∈V (G) d(u, v) =2 {u,v}⊆V (G) d(u, v) and combining the previous two results, we obtain theP followingP result, which representsP a method for computing W W (G) for a partial cube G. Proposition 5.1 Let G be a partial cube and let d be the number of its Θ-classes. Then

d d−1 d 0 1 00 11 01 10 W W (G)= ni ni +2 nij nij + nij nij . i=1 i=1 j=i+1 X X X  On the other hand, a method for computing the term W[ W (G) is not yet known and therefore, we

′ develop it in the next theorem. If G is a partial cube with d Θ-classes and Ui,Ui , i ∈ {1,...,d}, are defined as before, then for two vertices u, v ∈ V (G) we set

1; u ∈ V (U )& v ∈ V (U ′) or u ∈ V (U ′)& v ∈ V (U ), δ (u, v)= i i i i i 0; otherwise.  It is not difficult to check that for any two vertices of G the following equation holds (see, for example, [17]):

d d(u, v)= δi(u, v). (3) i=1 X Theorem 5.2 Let G be a partial cube with at least three vertices and let d be the number of its Θ-classes.

Then

d [ 0 1 1 1 0 0 W W (G) = ni ni (ni − 1)+ ni ni (ni − 1) i=1 X d−1 d  00 01 10 00 01 11 00 10 11 01 10 11 + 2 3nij nij nij +3nij nij nij +3nij nij nij +3nij nij nij i=1 j=i+1 X X 00 11 11 01 10 10 10 01 01 11 00 00 + nij nij (nij − 1)+ nij nij (nij − 1)+ nij nij (nij − 1)+ nij nij (nij − 1) . !

Proof. By Equation (3) we get

d d (d(u, v)d(u, w)) = δi(u, v) δj(u, w)   i=1 ! j=1 ! (u,v,wX)∈O3(G) (u,v,wX)∈O3(G) X X  d d  = (δi(u, v)δj (u, w))   i=1 j=1 (u,v,wX)∈O3(G) X X d d   = δi(u, v)δj (u, w)   i=1 j=1 3 X X (u,v,wX)∈O (G) d   = δi(u, v)δi(u, w)   i=1 3 X (u,v,wX)∈O (G) d  d  + δi(u, v)δj (u, w) .   i=1 j ,j i 3 X =1X6= (u,v,wX)∈O (G)   Therefore, it follows d [ W W (G) = δi(u, v)δi(u, w)   i=1 X (u,v,wX)∈O3(G) d−1 d  + 2 δi(u, v)δj (u, w) .   i=1 j=i+1 3 X X (u,v,wX)∈O (G)   Since δi(u, v)δi(u, w) = 1 if and only if δi(u, v) = 1 and δi(u, w) = 1 (see Figure 2), we obtain

0 1 1 1 0 0 δi(u, v)δi(u, w)= ni ni (ni − 1)+ ni ni (ni − 1). (u,v,wX)∈O3(G)

Figure 2. Possible position for u, v, and w.

Similarly, δi(u, v)δj (u, w) = 1 if and only if δi(u, v) = 1 and δj (u, w) = 1. First assume that u,v,w

00 01 10 11 00 belong to two of the sets Nij ,Nij ,Nij ,Nij . If, for example, u ∈ Nij , the number of triples (u,v,w)

00 11 11 satisfying δi(u, v)δj (u, w) = 1 is exactly nij nij (nij − 1).

00 01 10 11 00 Next, assume that u,v,w belong to three of the sets Nij ,Nij ,Nij ,Nij . If u ∈ Nij , we have three possibilities for v and w, see Figure 3.

Figure 3. Three possibilities for u, v, and w.

00 00 01 10 Hence, the number of triples (u,v,w) satisfying δi(u, v)δj (u, w) = 1 and u ∈ Nij is exactly nij nij nij +

00 01 11 00 10 11 01 10 11 nij nij nij + nij nij nij . Similar formulas hold also when u ∈ Nij , u ∈ Nij , or u ∈ Nij . Summing up all the contributions we obtain

00 01 10 00 01 11 00 10 11 01 10 11 δi(u, v)δj (u, w) = 3nij nij nij +3nij nij nij +3nij nij nij +3nij nij nij (u,v,wX)∈O3(G) 00 11 11 01 10 10 10 01 01 11 00 00 + nij nij (nij − 1) + nij nij (nij − 1)+ nij nij (nij − 1) + nij nij (nij − 1) and the proof is complete. 

Finally, we obtain the main result of this paper.

Theorem 5.3 Let G be a modular graph and a partial cube with at least three vertices and let d be the number of Θ-classes of G. Then

d d−1 d 3|V (G)|− 6 |V (G)|− 2 SW W (G) = n0n1 + n00n11 + n01n10 3 8 i i 4 ij ij ij ij i=1 i=1 j=i+1 X X X  d 1 + n0n1(n1 − 1)+ n1n0(n0 − 1) 8 i i i i i i i=1 X d−1 d  1 + 3n00n01n10 +3n00n01n11 +3n00n10n11 +3n01n10n11 4 ij ij ij ij ij ij ij ij ij ij ij ij i=i j=i+1 X X 00 11 11 01 10 10 10 01 01 11 00 00 + nij nij (nij − 1)+ nij nij (nij − 1) + nij nij (nij − 1)+ nij nij (nij − 1) . !

Proof. The result follows by Theorem 4.3, Equation (2), Proposition 5.1, and Theorem 5.2. 

Note that the number of Θ-classes of G is much smaller than the number of its edges, therefore, this result enables us to compute the Steiner 3-hyper-Wiener index much more efficiently. In particular, since any median graph is a partial cube and a modular graph, Theorem 5.3 holds for all median graphs. An example showing how this theorem can be used is presented in the next section.

6 The Steiner 3-hyper-Wiener index of grid graphs

Let m and n be positive integers. In this paper, the grid graph Gm,n is defined as the Cartesian product of two paths Pm and Pn, i.e. Gm,n = Pm✷Pn, see Figure 4. Grid graphs are a subfamily of graphs (a polyomino graph consists of a cycle C in the infinite square together with all squares inside C), which are known chemical graphs and often arise also in other real-word problems, for an example see [42].

Let G be a grid graph (or a polyomino graph) drawn in the plane such that every edge is a line segment of length 1. An elementary cut of G is a line segment that starts at the center of a peripheral edge of G, goes orthogonal to it and ends at the first next peripheral edge of G. Note that elementary cuts can be defined also for benzenoid systems, where they have been described and illustrated by numerous examples in several earlier articles. The elementary cuts of a grid graph Gm,n will be denoted by C1,...,Cn−1 and

D1,...,Dm−1, as shown in Figure 4. Figure 4. Grid graph G9,4 with all the elementary cuts.

The main insight for our consideration is that every Θ-class of a grid graph (or a polyomino graph) coincides with exactly one of its elementary cuts. Therefore, it is not difficult to check that all grid graphs

(or polyomino graphs) are partial cubes.

Moreover, in [19] it was studied which subgraphs of grid graphs are median graphs. In particular, every grid graph is known to be a median graph. Hence, in this section we find a closed formula for the

Steiner 3-hyper-Wiener index of Gm,n by using Theorem 5.3.

In order to simplify the computation, we introduce the following notation for a partial cube G. For any Θ-class Ei of G, let

0 1 f1(Ei) = ni ni ,

0 1 1 1 0 0 f2(Ei) = ni ni (ni − 1)+ ni ni (ni − 1)

and for any two distinct Θ-classes Ei,Ej let

00 11 01 10 g1(Ei, Ej ) = nij nij + nij nij ,

00 01 10 00 01 11 00 10 11 01 10 11 g2(Ei, Ej ) = 3nij nij nij +3nij nij nij +3nij nij nij +3nij nij nij

00 11 11 01 10 10 10 01 01 11 00 00 + nij nij (nij − 1)+ nij nij (nij − 1) + nij nij (nij − 1)+ nij nij (nij − 1).

Moreover, if E1,...,Ed are all the Θ-classes of G, we define

d

S1(G) = f1(Ei), i=1 X d

S2(G) = f2(Ei), i=1 X d−1 d S3(G) = g1(Ei, Ej ), i=1 j=i+1 X X d−1 d S4(G) = g2(Ei, Ej ). i=1 j=i+1 X X 0 1 First, we compute numbers ni and ni for any elementary cut. The results are presented in Table 1.

0 1 Elementary cut ni ni Ci (i =1,...,n − 1) im (n − i)m Di (i =1,...,m − 1) ni n(m − i)

Table 1. Number of vertices in the connected components with respect to an elementary cut.

Therefore, we can compute the following contributions from Table 2.

Sum Result n−1 1 2 3 2 i=1 f1(Ci), n ≥ 2 6 (m n − m n) m−1 f (D ), m ≥ 2 1 (n2m3 − n2m) Pi=1 1 i 6 n−1 f C n 1 m3n4 m3n2 m2n3 m2n P i=1 2( i), ≥ 2 6 ( − − 2 +2 ) m−1 f (D ), m ≥ 2 1 (n3m4 − n3m2 − 2n2m3 +2n2m) Pi=1 2 i 6

TableP 2. Partial results for computing S1(Gm,n) and S2(Gm,n).

Finally, for m,n ≥ 2 one can obtain

n−1 m−1 S1(Gm,n) = f1(Ci)+ f1(Di) i=1 i=1 X X 1 = m3n2 + m2n3 − m2n − mn2 , 6 

n−1 m−1 S2(Gm,n) = f2(Ci)+ f2(Di) i=1 i=1 X X 1 = m4n3 + m3n4 − 3m3n2 − 3m2n3 +2m2n +2mn2 . 6  Using S1(Gm,n), Theorem 2.1, and Equation (2), we can compute the Steiner 3-Wiener index of Gm,n.

Proposition 6.1 Let Gm,n be a grid graph such that m,n ≥ 2. Then

1 SW (G )= m4n3 + m3n4 − 3m3n2 − 3m2n3 +2m2n +2mn2 . 3 m,n 12  00 01 10 11 Next, we compute numbers nij , nij , nij , and nij for any pair of elementary cuts. The results are gathered in Table 3.

00 01 10 11 Pair of elementary cuts nij nij nij nij Ci, Cj (i < j) im 0 (j − i)m (n − j)m Di,Dj (i < j) ni 0 n(j − i) n(m − j) Ci,Dj ij i(m − j) (n − i)j (n − i)(m − j)

Table 3. Number of vertices in the connected components with respect to all the pairs of elemen- tary cuts.

Hence, we can calculate the following contributions from Table 4. Sum Result n−2 n−1 1 2 4 2 3 2 2 2 i=1 j=i+1 g1(Ci, Cj ), n ≥ 3 24 (m n − 2m n − m n +2m n) m−2 m−1 g (D ,D ), m ≥ 3 1 (m4n2 − 2m3n2 − m2n2 +2mn2) Pi=1 Pj=i+1 1 i j 24 n−1 m−1 g (C ,D ), m,n ≥ 2 1 (m3n3 − m3n − mn3 + mn) Pi=1 Pj=1 1 i j 18 n−2 n−1 1 3 5 3 4 3 3 2 4 P i=1P j=i+1 g2(Ci, Cj ), n ≥ 3 120 (7m n − 10m n − 15m n − 10m n +10m3n2 + 20m2n3 +8m3n + 10m2n2 − 20m2n) Pm−2 Pm−1 1 5 3 4 3 3 3 4 2 i=1 j=i+1 g2(Di,Dj), m ≥ 3 120 (7m n − 10m n − 15m n − 10m n +10m2n3 + 20m3n2 +8mn3 + 10m2n2 − 20mn2) Pn−1 Pm−1 1 4 4 4 2 3 3 2 4 3 2 2 3 i=1 j=1 g2(Ci,Dj), m,n ≥ 2 9 (m n − m n − m n − m n + m n + m n + mn − mn)

P P Table 4. Partial results for computing S3(Gm,n) and S4(Gm,n).

Finally, for m,n ≥ 3 one can compute

n−2 n−1 m−2 m−1 n−1 m−1 S3(Gm,n) = g1(Ci, Cj )+ g1(Di,Dj )+ g1(Ci,Dj ) i=1 j=i+1 i=1 j=i+1 i=1 j=1 X X X X X X 1 = m4n2 + m2n4 − 2m3n2 − 2m2n3 − 2m2n2 +2m2n +2mn2 24 1  + m3n3 − m3n − mn3 + mn , 18 

n−2 n−1 m−2 m−1 n−1 m−1 S4(Gm,n) = g2(Ci, Cj )+ g2(Di,Dj )+ g2(Ci,Dj ) i=1 j=i+1 i=1 j=i+1 i=1 j=1 X X X X X X 1 = 7m5n3 +7m3n5 − 10m4n3 − 10m3n4 − 10m4n2 − 30m3n3 − 10m2n4 120 + 30m3n2 + 30m2n3 +8m3n + 20m2n2 +8mn3 − 20m2n − 20mn2 1  + m4n4 − m4n2 − m3n3 − m2n4 + m3n + m2n2 + mn3 − mn . 9  Combining all the obtained results and Theorem 5.3, we obtain the main result of this section.

Theorem 6.2 Let Gm,n be a grid graph such that m,n ≥ 3. Then

1 SW W (G ) = 9m5n3 + 15m4n4 +9m3n5 + 15m4n3 + 15m3n4 − 30m4n2 − 50m3n3 − 30m2n4 3 m,n 360 + 26m3n − 45m3n2 − 45m2n3 + 45m2n2 + 26mn3 + 30m2n + 30mn2 − 20mn .  Moreover, for any n ≥ 3 it holds

1 SW W (G ) = 3n5 + 10n4 − 25n2 + 12n . 3 2,n 15  Acknowledgement

The author was financially supported from the Slovenian Research Agency (research core funding No.

P1-0297).

References

[1] S. P. Avann, Metric ternary distributive semi-lattices, Proc. Amer. Math. Soc. 12 (1961) 407–414.

[2] L. W. Beineke, O. R. Oellermann, R. E. Pippert, On the Steiner median of a tree, Discrete Appl. Math. 68 (1996) 249–258.

[3] Q. Cai, F. Cao, T. Li, H. Wang, On distances in vertex-weighted trees, Appl. Math. Comput. 333 (2018) 435–442.

[4] G. G. Cash, Relationship between the Hosoya polynomial and the hyper-Wiener index, Appl. Math. Lett. 15 (2002) 893–895.

[5] G. Chartrand, O. R. Oellermann, S. Tian, H. B. Zou, Steiner distance in graphs, Casopis´ pro pˇestov´an´ımatematiky 114 (1989) 399–410.

[6] Y.-H. Chen, H. Wang, X.-D. Zhang, Properties of the hyper-Wiener index as a local function, MATCH Commun. Math. Comput. Chem. 76 (2016) 745–760.

[7] M. Crepnjak,ˇ N. Tratnik, The Szeged index and the Wiener index of partial cubes with applications to chemical graphs, Appl. Math. Comput. 309 (2017) 324–333.

[8] M. Crepnjak,ˇ N. Tratnik, The edge-Wiener index, the Szeged indices and the PI index of benzenoid systems in sub-linear time, MATCH Commun. Math. Comput. Chem. 78 (2017) 675–688.

[9] P. Dankelmann, O. R. Oellermann, H. C. Swart, The average Steiner distance of a graph, J. 22 (1996) 15–22.

[10] P. Dankelmann, H. C. Swart, O. R. Oellermann, On the average Steiner distance of graphs with prescribed properties, Discrete Appl. Math. 79 (1997) 91–103.

[11] L. Eroh, O. R. Oellermann, Geodetic and Steiner geodetic sets in 3-Steiner distance hereditary graphs, Discrete Math. 308 (2008) 4212–4220.

[12] I. Gutman, On Steiner degree distance of trees, Appl. Math. Comput. 283 (2016) 163–167.

[13] I. Gutman, B. Furtula, X. Li, Multicenter Wiener indices and their applications, J. Serb. Chem. Soc. 80 (2015) 1009–1017.

[14] H. Hosoya, On some counting polynomials in chemistry, Discrete Appl. Math. 19 (1988) 239–257.

[15] F. K. Hwang, D. S. Richards, P. Winter, The Steiner Tree Problem, Annals of Discrete Mathematics 53, North-Holland: Elsevier, Amsterdam, 1992.

[16] R. Hammack, W. Imrich, S. Klavˇzar, Handbook of Product Graphs, Second Edition, RC Press, Taylor & Francis Group, Boca Raton, 2011. [17] S. Klavˇzar, Applications of isometric embeddings to chemical graphs, DIMACS Ser. Discrete Math. Theoret. Comput. Sci. 51 (2000) 249–259.

[18] S. Klavˇzar, M. J. Nadjafi-Arani, Cut method: update on recent developments and equivalence of independent approaches, Curr. Org. Chem. 19 (2015) 348–358.

[19] S. Klavˇzar, R. Skrekovski,ˇ On median graphs and median grid graphs, Discrete Math. 219 (2000) 287–293.

[20] S. Klavˇzar, P. Zigert,ˇ I. Gutman, An algorithm for the calculation of the hyper-Wiener index of benzenoid hydrocarbons, Comput. Chem. 24 (2000) 229–233.

[21] D. J. Klein, I. Lukovits, I. Gutman, On the definition of hyper-Wiener index for cycle-containing structures, J. Chem. Inf. Comput. Sci. 35 (1995) 50–52.

[22] M. Kovˇse, Vertex decomposition of Steiner Wiener index and Steiner betweenness centrality, arXiv:1605.00260.

[23] M. Krnc, R. Skrekovski,ˇ On Wiener inverse interval problem, MATCH Commun. Math. Comput. Chem. 75 (2016) 71–80.

[24] Y. Lan, T. Li, Y. Ma, Y. Shi, H. Wang, Vertex-based and edge-based centroids of graphs, Appl. Math. Comput. 331 (2018) 445–456.

[25] H. Lei, T. Li, Y. Ma, H. Wang, Analyzing lattice networks through substructures, Appl. Math. Comput. 329 (2018) 297–314.

[26] X. Li, Y. Mao, I. Gutman, The Steiner Wiener index of a graph, Discuss. Math. Graph Theory 36 (2016) 455–465.

[27] X. Li, Y. Mao, I. Gutman, Inverse problem on the Steiner Wiener index, Discuss. Math. Graph Theory 38 (2018) 83–95.

[28] Y. Mao, Steiner distance in graphs - a survey, arXiv:1708.05779.

[29] Y. Mao, Z. Wang, I. Gutman, Steiner Wiener index of graph products, Trans. Comb. 5 (2016) 39–50.

[30] Y. Mao, Z. Wang, I. Gutman, A. Klobuˇcar, Steiner degree distance, MATCH Commun. Math. Comput. Chem. 78 (2017) 221–230.

[31] Y. Mao, Z. Wang, I. Gutman, H. Li, Nordhaus-Gaddum-type results for the Steiner Wiener index of graphs, Discrete Appl. Math. 219 (2017) 167–175.

[32] R. P. Mondaini, The Steiner tree Problem and its application to the modelling of biomolecular structures, in: R. P. Mondaini, P. M. Pardalos (Eds.), Mathematical Modelling of Biosystems, Applied Optimization 102, Springer, Berlin, 2008, pp. 199–219.

[33] O. R. Oellermann, On Steiner centers and Steiner of graphs, Networks 34 (1999) 258–263.

[34] O. R. Oellermann, S. Tian, Steiner centers in graphs, J. Graph Theory 14 (1990) 585–597. [35] M. Randi´c, Novel molecular descriptor for structure-property studies, Chem. Phys. Lett. 211 (1993) 478–483.

[36] D. H. Rouvray, The rich legacy of half century of the Wiener index, in: D. H. Rouvray, R. B. King (Eds.), Topology in Chemistry – Discrete Mathematics of Molecules, Horwood, Chichester, 2002, pp. 16–37.

[37] N. Tratnik, A method for computing the edge-hyper-Wiener index of partial cubes and an algorithm for benzenoid systems, Appl. Anal. Discr. Math. 12 (2018) 126–142.

[38] N. Tratnik, The edge-Szeged index and the PI index of benzenoid systems in linear time, MATCH Commun. Math. Comput. Chem. 77 (2017) 393–406.

[39] N. Tratnik, P. Zigertˇ Pleterˇsek, Relationship between the Hosoya polynomial and the edge-Hosoya polynomial of trees, MATCH Commun. Math. Comput. Chem. 78 (2017) 181–187.

[40] H. Wiener, Structural determination of paraffin boiling points, J. Amer. Chem. Soc. 69 (1947) 17–20.

[41] H.-G. Yeh, C.-Y. Chiang, S.-H. Peng, Steiner centers and Steiner medians of graphs, Discrete Math. 308 (2008) 5298–5307.

[42] X. Zhou, H. Zhang, A minimax result for perfect matchings of a polyomino graph, Discrete Appl. Math. 206 (2016) 165–171.

[43] P. Zigert,ˇ S. Klavˇzar, I. Gutman, Calculating the hyper-Wiener index of benzenoid hydrocarbons, ACH - Models Chem. 137 (2000) 83–94.