1 Introduction

Given a graph \(G = (V(G), E(G))\), a set \(S\subseteq V(G)\) of vertices of G is a general position set if no triple of vertices from S lie on a common shortest path in G. The cardinality of a largest general position set of G is called the general position number of G and is denoted by \({{\,\textrm{gp}\,}}(G)\). These sets were independently introduced in [7, 20] and have already been studied from many perspectives, cf. [4, 15, 16, 18, 22, 23, 26]. In this paper, we explore general position sets from the point of view of the counting polynomial defined in the following standard way.

Definition 1.1

The general position polynomial of a graph G is the polynomial

$$\begin{aligned} \psi (G) = \sum _{i \ge 0}a_ix^i, \end{aligned}$$

where \(a_i\) is the number of distinct general position sets of G with cardinality i.

A polynomial is said to be unimodal if its coefficients are non-decreasing and then non-increasing. Unimodality is one of the most important and most studied properties of counting polynomials in graph theory. In the next paragraph, we give a very brief justification for our claim.

Since the matching polynomial of a graph has only real zeros [11], it is unimodal. The unimodality of the chromatic polynomial has been established in [13]. In [3] it has been conjectured that the domination polynomial of an arbitrary graph G is also unimodal. The conjecture has been approached from different perspectives, see [2, 5, 6, 19], but it remains open. On the other hand, it is known that the independence polynomial is not unimodal in general, but it has been conjectured by Alavi, Malde, Schwenk, and Erdős that the independence polynomial of a tree is unimodal [1], a conjecture which is also still open. It was very recently demonstrated that the conjecture cannot be strengthened up to its log-concave version [14]. On the other hand, the independence polynomial of a claw-free graph is unimodal [8].

The rest of the paper is organised as follows. In the next section we determine the general position polynomial of several families of graphs and give an inclusion–exclusion-like formula for the polynomial. We also construct an infinite number of pairs of non-isomorphic trees with the same general position polynomial. In Sect. 3 we consider the general position polynomials of disjoint unions of graphs, joins of graphs, and Cartesian products of graphs. In particular, we express the general position polynomial of the join of two graphs with the clique polynomial and the independent union of cliques polynomial (to be defined in Sect. 3) of the factors, and determine \(\psi (P_r{{\,\mathrm{\,\square \,}\,}}P_s)\). Then, in Sect. 4, we consider unimodality of the polynomial. We first demonstrate that it is not unimodal in general and not even unimodal on the class of trees. On the other hand, we prove that it is unimodal on combs, Kneser graphs K(n, 2), and a family of graphs containing complete bipartite graphs minus a matching. The paper is concluded with some open problems and suggestions for future research.

2 Basic Results and Examples

Let G be a graph. Then, clearly, the degree of \(\psi (G)\) is \({{\,\textrm{gp}\,}}(G)\). It was shown in [7, Theorem 2.10] that \(C_4\) and \(P_n\), \(n\ge 2\), are the only connected graphs G with \({{\,\textrm{gp}\,}}(G) = 2\), hence among connected graphs the degree of a general position polynomial is equal to 2 precisely for \(C_4\) and for \(P_n\), \(n\ge 2\). In addition, if G is of order n, then since every set of at most two vertices is a general position set, its general position polynomial starts as

$$\begin{aligned} \psi (G) = 1 + nx + {n \atopwithdelims ()2}x^2 + \cdots \end{aligned}$$
(1)

We now derive general position polynomials for some standard families of graphs.

Proposition 2.1

  1. (i)

    If \(n\ge 1\), then \(\psi (K_n) = (1+x)^n\).

  2. (ii)

    If \(n\ge 1\), then \(\psi (P_n) = 1+nx+{n \atopwithdelims ()2}x^2\).

  3. (iii)

    If \(n\ge 3\) is odd, then \(\psi (C_{n}) = 1+nx+{n \atopwithdelims ()2}x^2 + \left( {n \atopwithdelims ()3}-n{\lfloor \frac{n}{2} \rfloor \atopwithdelims ()2}\right) x^3\).

  4. (iv)

    If \(n\ge 4\) is even, then \(\psi (C_{n}) = 1+nx+{n \atopwithdelims ()2}x^2 + \left( {n \atopwithdelims ()3}-n{{\frac{n}{2} -1 }\atopwithdelims ()2}-\frac{n(n-2)}{2}\right) x^3\).

  5. (v)

    If \(m\ge n\ge 1\), then \(\psi (K_{m,n}) = 1+ (m+n)x+{m+n \atopwithdelims ()2}x^2 + \sum _{i=3}^m \left( {m \atopwithdelims ()i} + {n \atopwithdelims ()i}\right) x^i\).

Proof

(i) Any subset of i vertices in \(K_n\) for \(0 \le i \le n\) is in general position, so the coefficient at \(x^i\) in \(\psi (G)\) is \({n \atopwithdelims ()i}\). Thus \(\psi (G) = \sum _{i=0}^{n}{n \atopwithdelims ()i}x^i = (1+x)^n\).

(ii) Follows from (1) and the previously mentioned fact that \({{\,\textrm{gp}\,}}(P_n) = 2\) for \(n\ge 2\).

(iii) Consider \(C_{2d+1}\), \(d\ge 1\). We count the number of triples of vertices that are on a common geodesic. For \(2 \le r\le d\) there are exactly n pairs of vertices at distance r on the cycle and each such pair corresponds to exactly \(r-1\) sets from \(\left( {\begin{array}{c}V(C_n)\\ 3\end{array}}\right) \) that are on a common geodesic. Thus there are \(n\sum _{r=1}^{d} (r-1) = n{d \atopwithdelims ()2}\) triples that are on a common geodesic and hence there are exactly \({n \atopwithdelims ()3}-n{d \atopwithdelims ()2}\) triples that are in general position.

(iv) Consider \(C_{2d}\), \(d\ge 2\). The reasoning for odd cycles applies to pairs of vertices at distance at most \(d-1\) from each other; however, each pair of vertices at distance d now corresponds to \(n-2\) sets from \(\left( {\begin{array}{c}V(C_n)\\ 3\end{array}}\right) \) on a common geodesic. Therefore there are

$$\begin{aligned} \frac{n}{2}(n-2)+n \sum _{r=1}^{d-1} (r-1) = n{d-1 \atopwithdelims ()2}+\frac{n}{2}(n-2)\end{aligned}$$

triples of vertices that are on a common geodesic.

(v) The formula follows since \({{\,\textrm{gp}\,}}(K_{m,n}) = \max \{m, n\} = m\) and since a general position set S of \(K_{m,n}\) of cardinality at least 3 is an independent set, so that S is a subset of one of the bipartition sets of \(K_{m,n}\). \(\square \)

The general position polynomial can also be expressed via the inclusion–exclusion principle as follows. For a positive integer n, let \([n] = \{1,\ldots ,n\}\).

Proposition 2.2

Let G be a graph and let \(X_1,\ldots ,X_n\) be the maximal general position sets of G. Then

$$\begin{aligned} \psi (G) = \sum _{k = 1}^n (-1)^{k-1} \sum _{\{i_1,\ldots ,i_k\}\subseteq [n]} \psi (X_{i_1} \cap \cdots \cap X_{i_k}). \end{aligned}$$

Proof

Any subset of a general position set X is also a general position set and the number of subsets of size i is \({|X| \atopwithdelims ()i}\). It follows that for every general position set X we have \(\psi (X) = (1+x)^{|X|}\). The formula then follows by the inclusion–exclusion principle. \(\square \)

As an example, consider the Petersen graph \(P = K(5,2)\). In the standard drawing of it denote the consecutive vertices of the outer 5-cycle by \(u_0, u_1, u_2, u_3, u_4\), and their respective neighbors on the inner 5-cycle by \(u_0, u_1, u_2, u_3, u_4\). It is known from the seminal paper [20] that \({{\,\textrm{gp}\,}}(P) = 6\). By inspection it can be checked that there are precisely five general position sets of cardinality 6:

$$\begin{aligned}&\{u_0,u_1,u_3,v_2,v_3,v_4\}, \{u_0,u_2,u_3,v_0,v_1,v_4\}, \{u_0,u_2,u_4,v_1,v_2,v_3\}, \\&\{u_1,u_2,u_4,v_0,v_3,v_4\}, \{u_1,u_3,u_4,v_0,v_1,v_2\}\,. \end{aligned}$$

Moreover, the remaining maximal general position sets are the five independent sets of cardinality 4:

$$\begin{aligned}&\{u_0,u_2,v_3,v_4\}, \{u_0,u_3,v_1,v_2\}, \{u_1,u_3,v_0,v_4\}, \{u_1,u_4,v_2,v_3\}, \{u_2,u_4,v_0,v_1\}\,. \end{aligned}$$

Since every vertex of P lies in five different maximal general position sets, the intersection of six or more such sets is empty. In Table 1 it is shown how many different occurrences of the same number of sets in an intersection have the same size of intersection.

Table 1 Number of different occurrences of the same number of maximal general position sets in an intersection having the same size of intersection

Combining Proposition 2.2 with Table 1 yields:

$$\begin{aligned} \psi (P) =\ {}&\left[ 5(x+1)^6+5(x+1)^4)\right] - \left[ 5(x+1)^0 + 10(x+1)^1 + 30(x+1)^3)\right] \\&+\left[ 50(x+1)^0+40(x+1)^1+30(x+1)^2\right] \\ {}&\quad - \left[ 160(x+1)^0+50(x+1)^1\right] \\&+ \left[ 242(x+1)^0+10(x+1)^1\right] -210+120-45+10-1 \\ =\ {}&1 + 10x + 45x^2 + 90x^3 + 80x^4 + 30x^5+5x^6. \end{aligned}$$

To conclude the section we point out that the general position polynomial does not determine a graph uniquely. For example, \(1 + 4 x + 6 x^2\) is a general position polynomial of both \(P_4\) and \(C_4\). Furthermore, the general position polynomial does not even determine a tree uniquely. For example, let \(k \in {\mathbb {N}}\) and take \(T_1^{(k)}\) to be the tree obtained from identifying one leaf of \(P_{13k}\), \(P_{5k}\) and \(P_{4k}\), and \(T_2^{(k)}\) to be the tree obtained from identifying one leaf of \(P_{10k}\), \(P_{9k}\) and \(P_{3k}\). The case \(k=1\) is shown in Fig. 1.

Fig. 1
figure 1

Trees \(T_1^{(1)}\) and \(T_2^{(1)}\)

Both trees \(T_1^{(k)}\) and \(T_2^{(k)}\) have 20k vertices and three leaves, thus \({{\,\textrm{gp}\,}}(T_1^{(k)}) = {{\,\textrm{gp}\,}}(T_2^{(k)}) = 3\) by [20, Corollary 3.7]. Observe that

$$\begin{aligned} \psi (T_1^{(k)})&= 1 + 20 k x + \left( {\begin{array}{c}20 k\\ 2\end{array}}\right) x^2 + 144 k^3 x^3,\\ \psi (T_2^{(k)})&= 1 + 20 k x + \left( {\begin{array}{c}20 k\\ 2\end{array}}\right) x^2 + 144 k^3 x^3, \end{aligned}$$

where the coefficient at \(x^3\) is obtained by taking one vertex from each pendent path. The key property that achieves the equality of polynomials is that \(12 + 4 + 3 = 9 + 8 + 2\) and \(12 \cdot 4 \cdot 3 = 9 \cdot 8 \cdot 2\). Note that this is not the only pair of triples with this property.

3 The General Position Polynomial of Some Graph Operations

In this section we consider the general position polynomials of disjoint unions of graphs, joins of graphs, and Cartesian products of graphs.

Let denote the disjoint union of graphs G and H. Then is a general position set of if and only if \(S\cap V(G)\) is a general position set of G and \(S\cap V(H)\) is a general position set of H. Using this fact, the following result readily follows.

Proposition 3.1

If \(G_1, \ldots , G_r\), \(r\ge 2\), are graphs, then

Proposition 3.1 extends as follows.

Proposition 3.2

Let G be a graph, \(V_1,V_2\) a partition of V(G), and \(G_1 = G[V_1]\), \(G_2 = G[V_2]\). Then \(\psi (G) = \psi (G_1)\psi (G_2)\) if and only if or G is complete.

Proof

Sufficiency follows by Proposition 3.1 and Proposition 2.1(i).

Conversely, we need to prove that \(\psi (G) = \psi (G_1)\psi (G_2)\) implies either that G is a clique or that G is the disjoint union of \(G_1\) and \(G_2\). Examine the subsets of order three of V(G); in order to have equality in the \(x^3\) term, we must have that every set of three vertices with two vertices in one of \(G_1,G_2\) and one vertex in the other must be in general position. Suppose that there is an edge between \(G_1\) and \(G_2\) in G; we show that G must be complete. Let e be an edge from \(G_1\) to \(G_2\) with endpoints \(u \in V(G_1)\) and \(v \in V(G_2)\). Let \(u^{\prime }\) be any neighbour of u in \(G_1\); as \(\{ u,u^{\prime },v\} \) must be in general position, it follows that \(v \sim u^{\prime }\). Inductively, we conclude that u is adjacent to every vertex of \(G_1\); furthermore, it follows that if \(u_1\) and \(u_2\) are non-adjacent vertices in \(G_1\), then \(u_1,v,u_2\) would not be in general position, so \(G_1\) is a clique. Similarly \(G_2\) must be a clique and we must have every edge between \(G_1\) and \(G_2\). \(\square \)

If G and H are disjoint graphs, then the join \(G\vee H\) of G and H is the graph with the vertex set \(V(G\vee H) = V(G)\cup V(H)\), and the edge set \(E(G \vee H) = E(G)\cup E(H)\cup \{xy:\ x\in V(G), y\in V(H)\}\). Setting \(\rho (G)\) to denote the maximum number of vertices in a union of pairwise independent cliques of G, it was proved in [10, Proposition 4.2] that \({{\,\textrm{gp}\,}}(G \vee H ) = \max \{\omega (G) + \omega (H), \rho (G), \rho (H)\}\).

The clique polynomial C(G) of a graph G is the counting polynomial of cliques, that is,

$$\begin{aligned} C(G) = c_0+c_1x+c_2x^2+\cdots , \end{aligned}$$

where \(c_i\) is the number of cliques of order i in G, cf. [12]. Similarly, the independent union of cliques polynomial \(C_i(G)\) has coefficients equal to the number of independent union of cliques in G. Since a set \(S \subseteq V(G_1 \vee G_2)\) is in general position if and only if either it induces a clique in both \(G_1\) and \(G_2\), or S is an induced union of cliques in \(G_1\) or \(G_2\), the above discussion yields the following relation between the general position polynomial and the two clique polynomials.

Proposition 3.3

If \(G_1\) and \(G_2\) are graphs, then

$$\begin{aligned}\psi (G_1 \vee G_2) = (C(G_1)-1)(C(G_2)-1)+C_i(G_1)+C_i(G_2))-1.\end{aligned}$$

We now turn our attention to the Cartesian product of graphs. Recall that the Cartesian product \(G{{\,\mathrm{\,\square \,}\,}}H\) of graphs G and H has the vertex set \(V(G{{\,\mathrm{\,\square \,}\,}}H) = V(G)\times V(H)\) and the edge set \(E(G{{\,\mathrm{\,\square \,}\,}}H) = \{(g,h)(g',h'):\ gg'\in E(G) \text{ and } h=h', \text{ or, } g=g' \text{ and } hh'\in E(H)\}\).

For the general position number of the Cartesian product of two paths we have (cf. [21]):

$$\begin{aligned} {{\,\textrm{gp}\,}}(P_r {{\,\mathrm{\,\square \,}\,}}P_s) = {\left\{ \begin{array}{ll} 2; &{} r = s = 2,\\ 3; &{} r = 2, s \ge 3,\\ 4; &{} r, s \ge 3. \end{array}\right. }\end{aligned}$$
(2)

Moreover, in [17, Theorem 2.1] it was proved that the number of general position sets in \(P_r{{\,\mathrm{\,\square \,}\,}}P_s\) of cardinality \({{\,\textrm{gp}\,}}(P_r{{\,\mathrm{\,\square \,}\,}}P_s)\) is equal to

$$\begin{aligned} \left\{ \begin{array}{ll} 6; &{} r = s = 2, \\ \displaystyle {\frac{s(s-1)(s-2)}{3}}; &{} r = 2, s\ge 3, \\ \displaystyle {\frac{rs(r - 1)(r - 2)(s - 1)(s - 2)(r(s - 3) - s + 7)}{144}}; &{} r, s\ge 3. \end{array} \right. \end{aligned}$$
(3)

From (3) we immediately obtain the general position polynomial of thin grids:

Corollary 3.4

If \(r, s \ge 2\), then

$$\begin{aligned} \psi (P_r{{\,\mathrm{\,\square \,}\,}}P_s) = {\left\{ \begin{array}{ll} 6x^2+4x+1; &{} r = s = 2,\\ \frac{s(s-1)(s-2)}{3}x^3 + {2s \atopwithdelims ()2}x^2+2sx+1; &{} r = 2, s \ge 3.\\ \end{array}\right. } \end{aligned}$$

For larger grids we have:

Theorem 3.5

If \(r, s \ge 3\), then

$$\begin{aligned} \psi (P_r{{\,\mathrm{\,\square \,}\,}}P_s)&= \frac{rs(r - 1)(r - 2)(s - 1)(s - 2)(r(s - 3) - s + 7)}{144} \; x^4 \\ {}&\quad + \frac{1}{18}(r-1)r(s-1)s(r(2s-1)-s-4) \; x^3 \\ {}&\quad + {rs \atopwithdelims ()2} x^2 + rs x + 1. \end{aligned}$$

Proof

Let \(r,s\ge 3.\) It follows from (2) that \(\psi (P_r{{\,\mathrm{\,\square \,}\,}}P_s)\) is of degree 4. From (3) we get the leading coefficient, while coefficients of \(x^2, x^1\) and \(x^0\) are obviously \({rs \atopwithdelims ()2}, rs\) and 1, respectively. Consider the number of general position sets with three vertices. There are \({rs \atopwithdelims ()3}\) 3-subsets of \(V(P_r{{\,\mathrm{\,\square \,}\,}}P_s)\), but some of them are not in general position. In the following, we count the number of 3-subsets of \(V(P_r{{\,\mathrm{\,\square \,}\,}}P_s)\) that are not in general position.

  1. 1.

    There are \(r {s \atopwithdelims ()3}\) and \(s {r \atopwithdelims ()3}\) sets where all vertices are in the same horizontal or vertical layer.

  2. 2.

    Consider the case where exactly two are in the same horizontal layer (the case where they are in the same vertical layer is similar). Suppose that the second coordinate is k. The one with smaller first coordinate has \(r-1\) possibilities; suppose it is i, while the one with greater coordinate can be in \(\{i+1,\ldots ,r\}\), say j. Since the triplet is not in general position, the third vertex can have any other second coordinate (any of \(\{1,\ldots , k-1,k+1,\ldots ,s\}\)), and for its first coordinate x either \(x\le i\) or \(x\ge j\). Using the same reasoning for the case where two coordinates are in the same vertical layer and subtract the cases where both of them are the same, we obtain that in this case the number of sets that are not in general position is equal to

    $$\begin{aligned}&r\sum _{i=1}^{s-1}\sum _{j=i+1}^s(s-(j-i-1))(r-1) \\ {}&\quad + s\sum _{i=1}^{r-1}\sum _{j=i+1}^r(r-(j-i-1))(s-1) - 4 {r \atopwithdelims ()2} {s \atopwithdelims ()2}. \end{aligned}$$
  3. 3.

    The last case is vertices \((x_1,y_1)\), \((x_2,y_2)\) and \((x_3,y_3)\), where \(x_1<x_2<x_3\) and either \(y_1<y_2<y_3\) or \(y_1>y_2>y_3\). There are:

    $$\begin{aligned} 2\sum _{i=1}^{r-2}\sum _{j=1}^{s-2}\sum _{k=i+2}^{r}\sum _{l=j+2}^{s}(k-i-1)(l-j-1) \end{aligned}$$

    such sets.

By subtracting from the number of all sets the number of sets that are not in general position, we get this simplified expression:

$$\begin{aligned} \frac{1}{18}(r-1)r(s-1)s(r(2s-1)-s-4), \end{aligned}$$

representing the coefficient of the \(x^3\) term in the general position polynomial. \(\square \)

4 Unimodality

In this section we consider the unimodality of the general position polynomial. First, it is not unimodal in general as shown by the following example, which follows from Proposition 2.1(v):

$$\begin{aligned} \psi (K_{8,4}) = 1+12x^1+66x^2+60x^3+71x^4+56x^5+28x^6+8x^7+x^8. \end{aligned}$$

Another complete bipartite graph for which the general position polynomial is not unimodal is \(K_{9,7}\).

In view of the above example and the situation with the independence polynomial, we can ask ourselves whether the general position polynomial is unimodal on trees. The answer is negative as we now demonstrate.

A broom \(B_{s,r}\), \(s \ge 0\), \(r \ge 0\), is a graph with vertices \(u_0, \ldots , u_s, v_1, \ldots , v_r\), and edges \(u_i u_{i+1}\) for \(i \in \{0,\ldots , s-1\}\) and \(u_0 v_j\) for \(j \in [r]\). See Fig. 2 for an example.

Fig. 2
figure 2

The broom \(B_{4,6}\)

It is straightforward to check that

$$\begin{aligned} \psi (B_{s,r})&= \sum _{k \ge 0} b_k x^k \\&= 1 + (s+r+1) x + \left( {\begin{array}{c}s+r+1\\ 2\end{array}}\right) x^2 + \sum _{k \ge 3} \left( s \left( {\begin{array}{c}r\\ k - 1\end{array}}\right) + \left( {\begin{array}{c}r\\ k\end{array}}\right) \right) x^k\,. \end{aligned}$$

The smallest broom whose general position polynomial is not unimodal is \(B_{17,6}\); its general position polynomial is

$$\begin{aligned} \psi (B_{17,6}) = 1 + 24 x + 276 x^2 + 275 x^3 + 355 x^4 + 261 x^5 + 103 x^6 + 17 x^7. \end{aligned}$$

Moreover, one can calculate that if

then \(b_1< b_2 > b_3 < b_4\) holds, and hence there are infinitely many brooms for which the general position polynomial is not unimodal.

On the positive side, we first prove that the general position polynomial of comb graphs are unimodal. Recall that the comb \(G_n\), \(n\ge 1\), is obtained from the path \(P_n\) by respectively attaching a pendent vertex to each of its vertices.

Theorem 4.1

If \(n\ge 1\), then \(\psi (G_n)\) is unimodal.

Proof

Let \(\psi (G_n) = \sum _{k \ge 0} a_k x^k\). Clearly, \(a_0 = 1\), \(a_1 = 2n\), and \(a_2 = \left( {\begin{array}{c}2n\\ 2\end{array}}\right) \). For \(k \ge 3\), we can determine \(a_k\) by distinguishing between zero, one or two vertices from the general position set belonging to the path \(P_n\) in G:

$$\begin{aligned} a_k&= \left( {\begin{array}{c}n\\ k\end{array}}\right) + \sum _{i=1}^n \left( \left( {\begin{array}{c}i-1\\ k-1\end{array}}\right) + \left( {\begin{array}{c}n-i\\ k-1\end{array}}\right) \right) + \sum _{i = 1}^{n-1} \sum _{j=i+1}^n \left( {\begin{array}{c}j-i-1\\ k-2\end{array}}\right) \\&= \frac{1}{k} \left( \frac{(n-1) n}{k-1} \left( {\begin{array}{c}n-2\\ k-2\end{array}}\right) +n \left( {\begin{array}{c}n-1\\ k-1\end{array}}\right) +(n-k+1) \left( {\begin{array}{c}n\\ k-1\end{array}}\right) +k \left( {\begin{array}{c}n\\ k\end{array}}\right) \right) . \end{aligned}$$

In particular, \(a_3 = \frac{2}{3} (n-2) (n-1) n\), and \(a_3 \ge a_2\) if and only if \(n \ge 6\).

If \(n = 1\), then \(G_1 = K_2\), while if \(n = 2\), then \(G_2 = P_4\), and their polynomials are unimodal. For \(n \in \{3,4,5\}\), we calculate the polynomials explicitly to check that they are also unimodal:

$$\begin{aligned} \psi (G_3)&= 4 x^3+ 15 x^2+6 x+1\\ \psi (G_4)&= 4 x^4+16 x^3+ 28 x^2+8 x+1\\ \psi (G_5)&= 4 x^5+20 x^4+40 x^3+ 45 x^2+10 x+1 \end{aligned}$$

For \(n \ge 6\), we already know that \(a_0 \le a_1 \le a_2 \le a_3\), thus it only remains to show that the sequence \((a_k)_{k \ge 3}\) is unimodal. The difference between two terms in \(\psi (G)\) for \(3 \le k \le n-1\) can be simplified as follows:

$$\begin{aligned} a_k - a_{k+1} = \frac{4 n! (2 k-n+1)}{(k+1)! (n-k)!}, \end{aligned}$$

which implies that for \(3 \le k \le \frac{n-1}{2}\), \(a_k \le a_{k+1}\), and that for \(\frac{n-1}{2} \le k \le n-1\), \(a_k \ge a_{k+1}\), so \((a_k)_{k \ge 3}\) is indeed unimodal. \(\square \)

Another family of graphs for which the general position polynomial is unimodal is the class of Kneser graphs K(n, 2). Recall that the vertex set of K(n, 2) contains all 2-subsets of an n-set, two vertices being adjacent if the corresponding sets are disjoint. At the end of Sect. 2 we have considered the special case \(P = K(5,2)\).

Theorem 4.2

If \(n\ge 2\), then \(\psi (K(n,2))\) is unimodal.

Proof

We first determine the general position polynomial of K(n, 2). Recall from [20] that

$$\begin{aligned} {{\,\textrm{gp}\,}}(K(n,2)) = {\left\{ \begin{array}{ll} 6; &{} n \le 6,\\ n-1; &{} n \ge 7. \end{array}\right. } \end{aligned}$$

General position sets of size \(j \in \{2, \ldots , n-1\}\) can be cliques or independent sets, and for \(j \ge 7\) this is the only possibility. To form a clique on j vertices in K(n, 2), select 2j elements of the n-set (this can be done in \(\left( {\begin{array}{c}n\\ 2j\end{array}}\right) \) ways) and put them into unordered pairs (\(\left( {\begin{array}{c}2j\\ 2,\ldots ,2\end{array}}\right) \frac{1}{j!} = \frac{(2j)!}{2^j j!}\) options). An independent set on j vertices can be of the form \(\{ax_1, \ldots , ax_j\}\), where \(a, x_1, \ldots , x_j\) are distinct elements of the n-set. There are \(n \left( {\begin{array}{c}n-1\\ j\end{array}}\right) \) such sets. For \(j \ge 4\), all independent sets are of this form. However, for \(j = 3\), independent sets can also take the form \(\{ab, bc, ac\}\), where abc are distinct elements of the n-set. For \(j \in \{ 3, \ldots , 6\}\), several additional types of general position sets are possible. On six vertices, \(3K_2\) forms a general position set, and there are \(\left( {\begin{array}{c}n\\ 4\end{array}}\right) \) such sets (they are of the form \(\{ab, cd, ac, bd, ad, bc\}\)). On five vertices, is also a general position set, and it can be obtained by removing one vertex from the general position set on six vertices, thus there are \(6 \left( {\begin{array}{c}n\\ 4\end{array}}\right) \) of them. Similarly, on four vertices, \(2K_2\) or are also independent sets. They are obtained by removing two vertices from the general position set on six vertices, so there are \(\left( {\begin{array}{c}6\\ 2\end{array}}\right) \left( {\begin{array}{c}n\\ 4\end{array}}\right) = 12 \left( {\begin{array}{c}n\\ 4\end{array}}\right) \) of them. On three vertices, we need to consider the additional type of independent sets as well, and there are \(\left( {\begin{array}{c}n\\ 3\end{array}}\right) \) of them. By removing three vertices from a general position set on six vertices we can also obtain a set of three vertices in general position that induces a copy of , but these vertices must not belong to three copies of different \(K_2\). Thus there are \(\left( \left( {\begin{array}{c}6\\ 3\end{array}}\right) - 2^3 \right) \left( {\begin{array}{c}n\\ 4\end{array}}\right) = 12 \left( {\begin{array}{c}n\\ 4\end{array}}\right) \). Therefore:

$$\begin{aligned} \psi (K(n,2))&= \sum _{k = 0}^{n-1} a_k x^k = 1 + \left( {\begin{array}{c}n\\ 2\end{array}}\right) x \\&+ \left( \left( {\begin{array}{c}n\\ 3\end{array}}\right) + 12 \left( {\begin{array}{c}n\\ 4\end{array}}\right) \right) x^3 + 15 \left( {\begin{array}{c}n\\ 4\end{array}}\right) x^4 + 6 \left( {\begin{array}{c}n\\ 4\end{array}}\right) x^5 + \left( {\begin{array}{c}n\\ 4\end{array}}\right) x^6 \\&\quad + \sum _{j=2}^{n-1} \left( \left( {\begin{array}{c}n\\ 2 j\end{array}}\right) \frac{ (2 j)!}{2^{j} j!}+n \left( {\begin{array}{c}n-1\\ j\end{array}}\right) \right) x^j\,. \end{aligned}$$

We can check by computer that \(\psi (K(n,2))\) is unimodal for \(2 \le n \le 16\). For \(n \ge 17\), the following inequalities hold: \(a_0 \le a_1 \le \cdots \le a_6 \le a_7\). Thus it remains to show that \((a_k)_{k \ge 7}\) is unimodal. Since \(k \ge 7\), \(a_k = n \left( {\begin{array}{c}n-1\\ k\end{array}}\right) + \frac{(2k)!}{2^k k!} \left( {\begin{array}{c}n\\ 2k\end{array}}\right) \). To show unimodality, we simplify the difference

$$\begin{aligned} a_k - a_{k+1} =&\frac{\left( {\begin{array}{c}n\\ k+1\end{array}}\right) }{2^{k+1}} \Bigl ( 2^{k+1} (2k+2-n) \\&+ (n+2-(n-2k)^2) (n-2k+1)(n-2k+2) \cdots (n-k-1) \Bigr )\,. \end{aligned}$$

To determine for which k the difference \(a_k - a_{k+1} \ge 0\) and for which k it is \(a_k - a_{k+1} \le 0\), we only need to consider the terms

$$\begin{aligned} A&= 2^{k+1} (2k+2-n), \\ B&= (n+2-(n-2k)^2) (n-2k+1)(n-2k+2) \cdots (n-k-1)\,. \end{aligned}$$

First observe that if \(k > \frac{n}{2}\), then \(\frac{(2k)!}{2^k k!} \left( {\begin{array}{c}n\\ 2k\end{array}}\right) = 0\), thus \(a_k - a_{k+1} = \frac{\left( {\begin{array}{c}n\\ k+1\end{array}}\right) }{2^{k+1}} \cdot A > 0\).

If \(\frac{n}{2} - 1 \le k \le \frac{n}{2}+1\), then \(A \ge 0\), and since \(n+2-(n-2k)^2 \ge 0\) and for all \(j \in [k-1]\), \(n-2k+j \ge 0\), we also have \(B \ge 0\). Thus \(a_k - a_{k+1} \ge 0\).

For \(\frac{n}{2} - \frac{\sqrt{n+1}}{2} \le k \le \frac{n}{2} - 1\), we have \(A \le 0\) and \(B \ge 0\). In the following we will prove that \(B \ge |A|\). Observe that \(n+2-(n-2k)^2 \ge 1\), \(n-2k+1 > |2k+2-n|\) and for all \(j \in \{2,\ldots , k-1\}\), \(n-2k+j \ge 4\). Thus

$$\begin{aligned} B \ge 1 \cdot |2k+2-n| \cdot 4^{k-2} > |2k+2-n| \cdot 2^{k+1} = |A| \end{aligned}$$

since \(k \ge 7\). Hence we have \(a_k - a_{k+1} \ge 0\).

For \(7 \le k \le \frac{n}{2} - \frac{\sqrt{n+2}}{2}\), we have \(A < 0\), \(n+2-(n-2k)^2 \le 0\) and for all \(j \in [k-1]\), \(n-2k+j \ge 0\), thus \(B \le 0\). It follows that \(a_k - a_{k+1} < 0\).

It remains to prove that the above cases indeed cover all integers k, \(7 \le k \le n-1\). To see this we need to prove that no integer lies in the interval \(\left( \frac{n}{2} - \frac{\sqrt{n+2}}{2}, \frac{n}{2} - \frac{\sqrt{n+1}}{2} \right) \). Suppose that there exists \(m \in {\mathbb {N}}\) such that \(\frac{n}{2} - \frac{\sqrt{n+2}}{2}< m < \frac{n}{2} - \frac{\sqrt{n+1}}{2}\). Simplifying and squaring this chain of inequalities yields \(n+1< (n-2m)^2 < n+2\). But since \(n+1\) and \(n+2\) are consecutive integers, we obtain a contradiction. Thus we have proved that \((a_k)_{k\ge 7}\) is unimodal. \(\square \)

The following family of graphs \(T^*(r,a)\) from [25] yields another family of graphs with unimodal general position polynomial. Take a complete a-partite graph, each part of which contains r vertices and label the vertices in part i by \(i_1,\ldots ,i_r\). Then for each \(i\in [r]\), delete the edges of the clique induced by the vertices \(i_1, \ldots , i_a\).

Now suppose that S is a general position set of \(T^*(r,a)\). Any subset lying in a single partite set is in general position. Suppose that S contains three vertices (say with labels 1,2,3) in part A; then S can contain no vertices from other partite sets, for when we add a new vertex x from another part, the label of x will differ from that of at least two vertices of S. Suppose then that S contains two vertices \(a_1,a_2\) of a part A (say with labels 1,2); by the same reasoning S can only contain vertices with labels 1 and 2. If S intersects only two parts, it will be in general position, inducing either a or a \(2K_2\). However, S cannot contain vertices from more than two partite sets; if S contains a vertex \(b_1\) with label 1 in a part B and a vertex \(c_1\) with label 1 in a part C, then \(b_1,a_2,c_1\) is a shortest path, whereas if S contains a vertex \(b_1\) in B with label 1 and a vertex \(c_2\) with label 2 in C, then \(b_1,c_2,a_1\) would again be a shortest path. It follows that the general position polynomial of this graph is given by

$$\begin{aligned} \psi (T^*(r,a)) =&1+nx+{n \atopwithdelims ()2}x^2+2a(a-1){r \atopwithdelims ()2}x^3+{a \atopwithdelims ()2}{r \atopwithdelims ()2}x^4 \\&+\sum _{i\ge 3}\left[ a{r \atopwithdelims ()i}+r^i{a \atopwithdelims ()i}\right] x^i\,, \end{aligned}$$

where \(n = ra\).

Proposition 4.3

If \(a \in \{1,2\}\), then \(T^*(r,a)\) is unimodal.

Proof

If \(a = 1\), then \(T^*(r,1) = K_r\), which is unimodal. If \(a=2\), then \(T^*(r,2)\) is a complete bipartite graph without a perfect matching. Simplifying its general position polynomial gives

$$\begin{aligned} \psi (T^*(r,2)) = 1+2rx+{2r \atopwithdelims ()2}x^2+4{r \atopwithdelims ()2}x^3+{r \atopwithdelims ()2}x^4+\sum _{i\ge 3} 2{r \atopwithdelims ()i}x^i.\end{aligned}$$

Observe that the sequence \((2 \left( {\begin{array}{c}r\\ i\end{array}}\right) )_{i \ge 3}\) is unimodal. Thus if we can prove that the initial coefficients of \(\psi (T^*(r,2))\) are increasing, the general position polynomial is also unimodal. This holds for \(r \ge 10\), as \(1 \le 2 r \le \left( {\begin{array}{c}2 r\\ 2\end{array}}\right) \le 4 \left( {\begin{array}{c}r\\ 2\end{array}}\right) + 2 \left( {\begin{array}{c}r\\ 3\end{array}}\right) \le \left( {\begin{array}{c}r\\ 2\end{array}}\right) + 2 \left( {\begin{array}{c}r\\ 4\end{array}}\right) \le 2 \left( {\begin{array}{c}r\\ 5\end{array}}\right) \) holds for \(r \ge 10\).

Table 2 General position polynomials for \(a = 2\) and small values of r

The unimodality of the remaining cases can be checked by hand, see Table 2. \(\square \)

5 Concluding Remarks

Recall that the corona \(G\circ K_1\) of a graph G is obtained from G by attaching a pendent vertex to each the vertices of G. We wonder whether the following extension of Theorem 4.1 holds:

Problem 5.1

Assume that \(\psi (G)\) is unimodal. Then is \(\psi (G\circ K_1)\) also unimodal?

In Proposition 4.3 we have proved that if \(a \in \{1,2\}\), then \(T^*(r,a)\) is unimodal. This leads to:

Problem 5.2

For which pairs (ra) is the graph \(T^*(r,a)\) unimodal?

For example, \(T^*(r,3)\) is unimodal if \(r \ge 19\), but also for some smaller values of r.

Several variations of the general position number have been investigated in the literature. For example, a set \(S \subseteq V(G)\) is in monophonic position if no induced path of G contains three vertices of S (see [24]), whilst S is a mutual-visibility set if for any \(u,v \in S\) there exists a shortest uv-path in G that does not pass through \(S\setminus \{ u,v\} \) (see [9]). We suggest than an interesting direction for future research would be to explore the polynomials counting such sets and their relation to the general position polynomials.