1 Introduction and notation

In this paper, we follow the notation of Chartrand et al. (2015). Let \(G=(V_G,E_G)\) be a graph with vertex set \(V_G\) and edge set \(E_G\). For a vertex v of G, its neighborhood, denoted by \(N_{G}(v)\), is the set of all vertices adjacent to v, and the cardinality of \(N_G(v)\), denoted by \(\deg _G(v)\), is called the degree of v. The minimum degree of a vertex in G is denoted by \(\delta (G)\). A leaf is a vertex of degree one, whereas a support vertex (or support, for short) is a vertex adjacent to a leaf. A weak support is a vertex adjacent to exactly one leaf. The set of leaves and supports of a graph G are denoted by \(L_G\) and \(S_G\), respectively. The closed neighborhood of v, denoted by \(N_{G}[v]\), is the set \(N_{G}(v)\cup \{v\}\). In general, the neighborhood of X, denoted by \(N_{G}(X)\), is defined to be \(\bigcup _{v\in X}N_{G}(v)\), and the closed neighborhood of X, denoted by \(N_{G}[X]\), is the set \(N_{G}(X)\cup X\). If X is a set of vertices of a graph G and \(x\in X\), then the private neighborhood of x with respect to X is the set \(PN_G[x,X]=N_G[x]- N_G[X-\{x\}]\), and each vertex in \(PN_G[x,X]\) is called a private neighbor of x with respect to X. Finally, the distance between two vertices u and v in G is denoted by \(d_G(u,v)\), and the diameter of G is \(\mathrm{diam}(G)=\max \{ d_G(u,v) :u,v \in G\}\).

A subset D of \(V_G\) is a dominating set of a graph G if each vertex belonging to the set \(V_G -D\) has a neighbor in D. The cardinality of a minimum dominating set of G is called the domination number of G and is denoted by \(\gamma (G)\). Every minimum dominating set of G is called a \(\gamma \)-set of G. A subset \(C \subseteq V_G\) is a covering set of G if each edge of G has an end-vertex in C. The cardinality of a minimum covering set of G is called the covering number of G and is denoted by \(\beta (G)\). Any minimum covering set of G is called a \(\beta \)-set of G. Finally, a subset \(I \subseteq V_G\) is said to be independent in G if no two vertices in it are adjacent. The cardinality of a maximum independent set of G is called the independence number of G and is denoted by \(\alpha (G)\). A maximum independent set in G is called an \(\alpha \)-set of G. The set of all connected graphs G for which \(\gamma (G)=\beta (G)\) is denoted by \({\mathcal {C}}_{\gamma =\beta }\), whereas \({\mathcal {B}}\) denotes the set of all connected bipartite graphs in which the domination number is equal to the cardinality of the smaller partite set. It is easy to observe that the complete graph \(K_n\) is in \({\mathcal {C}}_{\gamma =\beta }\) if and only if \(n=2\), the cycle \(C_n\) is in \({\mathcal {C}}_{\gamma =\beta }\) if and only if \(n=4\), the path \(P_n\) is in \({\mathcal {C}}_{\gamma =\beta }\) if and only if \(n\in \{2, 3, 4, 5, 7\}\), whereas the complete bipartite graph \(K_{m,n}\) is in \({\mathcal {C}}_{\gamma =\beta }\) if and only if \(\min \{m,n\}\in \{1, 2\}\).

The problem of characterizing the set \({\mathcal {C}}_{\gamma =\beta }\) was posed by Laskar and Walikar (1981). Volkmann (1994) have characterized some subsets of \({\mathcal {C}}_{\gamma =\beta }\). A first complete characterization of the set \({\mathcal {C}}_{\gamma =\beta }\) was given by Hartnell and Rall (1995), and independently by Randerath and Volkmann (1998). A simpler characterization was then provided by Wu and Yu (2012), and eventually Arumugam et al. (2013) proposed another yet characterization, also studying the problem for hypergraphs. Another subset of \({\mathcal {C}}_{\gamma =\beta }\), the set of all connected graphs G in which \(\gamma (H) = \beta (H)\) for every non-trivial connected induced subgraph H of G, was characterized in Arumugam et al. (2013) and Dettlaff et al. (2016).

In this paper, in Theorem 1, we provide an alternative characterization of the set \({{\mathcal {C}}}_{\gamma =\beta }\) in terms of \(\alpha \)-sets. Since \(\alpha \)-sets and \(\beta \)-sets are related by the Gallai’s theorem (Gallai 1959), our characterization is natural (with respect to relations between \(\gamma , \beta \), and \(\alpha \)), however, from the algorithmic point of view, our characterization is less practical than, for example, that in Arumugam et al. (2013), which allows to recognize whether a graph G belongs to \({\mathcal {C}}_{\gamma =\beta }\) in \(O(\sum _{v \in V_G} \deg ^2(v))\) time, whereas ours—does not. Next, in Theorem 2, we provide an alternative characterization of the graphs belonging to the set \({\mathcal {B}}\). Then, in Theorem 3, we provide a constructive characterization of all the trees in the set \({\mathcal {B}}\). Next, we discuss a quadratic time algorithm for recognizing bipartite graphs belonging to the set \({\mathcal {B}}\), and then, based upon an analogous argument, we conclude that the algorithm of Arumugam et al. (2013) recognizes all the graphs belonging to the set \({\mathcal {C}}_{\gamma =\beta }\) in quadratic time either. Finally, we consider the related problem of patrolling grids with mobile guards, and show that this problem can be solved in \(O(n \log n + m)\) time, where n is the number of line segments of the input grid and m is the number of its intersection points. We emphasize that our proof techniques are similar to those in Arumugam et al. (2013), Hartnell and Rall (1995), Randerath and Volkmann (1998), Wu and Yu (2012), and so all the aforementioned non-constructive characterizations possess similarities.

2 Alternative characterization of the set \({\mathcal {C}}_{\gamma =\beta }\)

In our characterizations of the graphs belonging to the set \({\mathcal {C}}_{\gamma =\beta }\) or \({\mathcal {B}}\) we use the following Gallai’s theorem which relates the cardinality of the largest independent set and the cardinality of the smallest covering set in a graph.

Lemma 1

(Gallai 1959) If G is a graph, then \(\alpha (G)+\beta (G)=|V_G|\).

We now present a characterization of the graphs belonging to the set \({\mathcal {C}}_{\gamma =\beta }\) and give a self-contained proof of this characterization.

Theorem 1

Let G be a connected graph of order at least two, and let I be an \(\alpha \)-set of G. Then \(\gamma (G)=\beta (G)\) if and only if the following conditions are satisfied:

  1. (1)

    Each support vertex of G belonging to I is a weak support and each of its non-leaf neighbors is a support.

  2. (2)

    If vu is an edge of the graph \(G-I\), then both vertices v and u are supports in G.

  3. (3)

    If x and y are vertices belonging to \(V_G-(I \cup L_G\cup S_G)\) and \(d_G(x,y)=2\), then there are at least two vertices \({\overline{x}}\) and \({\overline{y}}\) in I such that \(N_G({\overline{x}})= N_G({\overline{y}})= \{x,y\}\).

Proof

Assume that \(\gamma (G)=\beta (G)\). Then, since I is an \(\alpha \)-set of G and G has no isolated vertex, \(J=V_G-I\) is a dominating set of G, and therefore \(\gamma (G)\le |J|\). In addition, \(\beta (G)=\gamma (G)\le |J|=|V_G|-|I|= |V_G|-\alpha (G)=\beta (G)\) (as \(\alpha (G)+\beta (G)=|V_G|\) by Lemma 1). Thus \(\gamma (G)=|J|\) and J is a \(\gamma \)-set of G. To prove the condition (1), consider a vertex v belonging to \(S_G\cap I\). Then \(|N_G(v)\cap L_G|=1\) (otherwise \(|N_G(v)\cap L_G|\ge 2\) and \(J^{\prime }= (J-(N_G(v)\cap L_G))\cup \{v\}\) would be a dominating set of G, which is impossible as \(|J^{\prime }|<|J|=\gamma (G)\)). Thus, let \(v^{\prime }\) be the only element of \(N_G(v)\cap L_G\). It remains to prove that \(N_G(v)\subseteq L_G\cup S_G\). Suppose to the contrary that \(N_G(v)-(L_G\cup S_G)\not =\emptyset \) and consider a vertex \(x\in N_G(v)-(L_G\cup S_G)\). Then \(N_G(x)\cap L_G=\emptyset \) (since \(x\notin S_G\)) and we now claim that \(J^{\prime \prime }= (J-\{v^{\prime },x\})\cup \{v\}\) is a dominating set of G. To prove this, it suffices to show that every vertex \(y \in V_G-J^{\prime \prime }\) has a neighbor in \(J^{\prime \prime }\). This is obvious if \(y\in \{v^{\prime }, x\}\cup (I-N_G(x))\). Thus assume that \(y\in N_G(x)\cap I\). In this case we have \(N_G(y)\cap (J-\{v^{\prime },x\})\not =\emptyset \) (as \(N_G(y)\subseteq J-\{v^{\prime }\}\) and \(|N_G(y)|\ge 2\)) and therefore \(N_G(y)\cap J^{\prime \prime }\not =\emptyset \). Consequently, \(J^{\prime \prime }\) is a dominating set of G, but this contradicts the minimality of J as \(|J^{\prime \prime }|<|J|= \gamma (G)\). This completes the proof of (1).

To prove (2), let us consider an edge vu of \(G-I\). From the fact that I is an \(\alpha \)-set of G it follows immediately that \(\{v, u\} \cap L_G=\emptyset \). It remains to prove that \(\{v, u\} \subseteq S_G\). Suppose to the contrary that \(v\not \in S_G\) or \(u\not \in S_G\), say \(v\not \in S_G\). In this case we claim that \(J-\{v\}\) is a dominating set of G. To observe this, it suffices to show that \(N_G(y)\cap (J-\{v\})\not =\emptyset \) if \(y\in V_G-(J-\{v\})= \{v\}\cup (I-N_G(v))\cup (N_G(v)\cap I)\). The statement is obvious if \(y=v\), as \(u\in N_G(v)\cap (J-\{v\})\). Thus assume that \(y\in I-N_G(v)\). In this case \(y\in I= V_G-J\) and \(y\not \in N_G(v)\), and therefore, \(N_G(y)\cap J\not =\emptyset \) (since J is a dominating set of G) and \(v\not \in N_G(y)\). Consequently, \(N_G(y)\cap (J-\{v\}) \not =\emptyset \). Finally assume that \(y\in N_G(v)\cap I\). Then \(N_G(y) \subseteq J\) (since I is independent), \(|N_G(y)|\ge 2\) (as \(y\not \in L_G\)), and consequently, \(N_G(y)\cap (J-\{v\}) \not =\emptyset \). This proves that \(J-\{v\}\) is a dominating set of G, contrary to the minimality of J. This finishes the proof of (2).

To prove the condition (3), let x and y be vertices belonging to \(J-(L_G\cup S_G)\) and such that \(d_G(x,y)=2\). Now, if \(b\in N_G(x)\cap N_G(y)\), then, since \(|(J-\{x,y\})\cup \{b\}|<|J|\), the set \((J-\{x,y\})\cup \{b\}\) does not dominate G. Therefore there exists \({\overline{x}} \in I-\{b\}\) for which \(N_G({\overline{x}})\subseteq \{x,y\}\). Thus, since \(\deg _G({\overline{x}})\ge 2\) (as \(\{x, y\}\cap (L_G\cup S_G)=\emptyset \)), \(N_G({\overline{x}}) =\{x,y\}\) and \({\overline{x}}\in I\) (otherwise, if \({\overline{x}}\in J\) then \(J-\{{\overline{x}}\}\) would be a smaller dominating set of G). Similarly, since \((J-\{x,y\})\cup \{{\overline{x}}\}\) does not dominate G, there exists \({\overline{y}} \in I- \{{\overline{x}}\}\) for which \(N_G({\overline{y}})= \{x,y\}\). This proves the condition (3).

Assume now that the conditions (1)–(3) are satisfied. We claim that \(\gamma (G)=|J|\), where \(J=V_G-I\). Suppose to the contrary that \(\gamma (G)<|J|\). Let D be a \(\gamma \)-set of G with \(|D\cap J|\) as large as possible. We get a contradiction in the three possible cases: (1) \(D\varsubsetneq J\), (2) \(D\subseteq I\), (3) \(D\cap J\not =\emptyset \) and \(D\cap I\not = \emptyset \).

Case 1. If \(D\varsubsetneq J\), then \(J-D\not =\emptyset \) and for a vertex \(v\in J-D\) there exists \(u\in N_G(v)\cap D\). Then vu is an edge in \(G-I\) and therefore \(v\in S_G\) (by the condition (2)). Thus the set \(N_G(v)\cap L_G\) is nonempty. Moreover \(N_G(v)\cap L_G\subseteq D\) (since every element of \(N_G(v)\cap L_G\) has to be dominated) and \(N_G(v)\cap L_G\subseteq I\) (by the choice of I), a contradiction to \(D\varsubsetneq J\).

Case 2. If \(D\subseteq I\), then \(D=I\) (as I is independent and no proper subset of I dominates all vertices in I). The set J also is independent as otherwise the set \(S_G\cap J\) would be non-empty (by the condition (2)) and it would be a subset of D (by the choice of D), which is impossible (as D and J are disjoint). Consequently, G is a bipartite graph and the sets \(I=D\) and J form a bipartition of \(V_G\) into independent sets, and \(|I|= |D|= \gamma (G)< |J|\le \alpha (G)=|I|\), a contradiction.

Case 3. Finally assume that \(D\cap J\not =\emptyset \) and \(D\cap I\not = \emptyset \). In this case, since \(|D\cap I|+|D\cap J|= \gamma (G)< |J|= |J-D|+|D\cap J|\) and \(D\cap I\not =\emptyset \), it follows that \(|J-D|>|D\cap I|\ge 1\). Now the choice of D, the maximality of I, and the condition (2) imply that each vertex belonging to \(J-D\) has a neighbor in \(D \cap I\). Therefore the pigeonhole principle implies that there are two vertices x and y in \(J-D\) which are adjacent to the same vertex in \(D \cap I\). Since \(N_G(I\cap L_G) \subset D\) (by the choice of D) as well as \(J \cap L_G \subset D\) (by (1) and the choice of D), the vertices x and y belong to \(J-(L_G\cup S_G)\). Therefore, by (3), there exist vertices \({\overline{x}}\) and \({\overline{y}}\) in I for which \(N_G({\overline{x}})= N_G({\overline{y}})=\{x,y\}\). Furthermore, the vertices \({\overline{x}}\) and \({\overline{y}}\) belong to \(D \cap I\) (as otherwise \({\overline{x}}\) and \({\overline{y}}\) would not be dominated by D). Now the set \(D^{\prime }= (D-\{{\overline{x}},{\overline{y}}\})\cup \{x, y\}\) is a dominating set of G, which is impossible as \(|D^{\prime }|=|D|\) and \(|D^{\prime }\cap J|>|D\cap J|\). This proves that \(\gamma (G)=|J|\) and implies that \(\gamma (G)=\beta (G)\) as \(|J|=|V_G|-|I|= |V_G|-\alpha (G)= \beta (G)\) (by Lemma 1).\(\square \)

From Theorem 1 we have the following two immediate corollaries.

Corollary 1

(Volkmann 1996) If a graph G belongs to the set \({\mathcal {C}}_{\gamma =\beta }\), then \(\delta (G) \le 2\).

Corollary 2

(Hartnell and Rall 1995; Randerath and Volkmann 1998) If a graph G belongs to the set \({\mathcal {C}}_{\gamma =\beta }\) and \(\delta (G)=2\), then G is a bipartite graph.

Figure 1 shows a graph G belonging to the set \({\mathcal {C}}_{\gamma =\beta }\). In this case the solid vertices form an \(\alpha \)-set I of G, whereas \(V_G-I\) is a \(\gamma \)- and \(\beta \)-set of G. Certainly, I satisfies the conditions (1)–(3) of Theorem 1. On the other hand the graph F shown in Fig. 1 does not belong to the set \({\mathcal {C}}_{\gamma =\beta }\), as \(\gamma (F)=2\), whereas \(\beta (F)=3\). Thus, no \(\alpha \)-set I of F satisfies all three conditions (1)–(3) of Theorem 1. It is easy to check that the sets \(I_1 =\{v_2, v_4, v_6\}\), \(I_2 =\{v_1, v_4, v_6\}\), \(I_3 =\{v_1, v_3, v_5\}\) are the only \(\alpha \)-sets of F, and, in addition, the \(\alpha \)-set \(I_k\) (\(k\in \{1, 2, 3\}\)) satisfies precisely the conditions \(\{(1), (2), (3)\}-\{(k)\}\) of Theorem 1.

Fig. 1
figure 1

Graphs G and F, where \(G \in {\mathcal {C}}_{\gamma =\beta }\), whereas \(F \not \in {\mathcal {C}}_{\gamma =\beta }\)

3 Bipartite graphs with the largest domination number

It is obvious that if \(G = ((A,B),E_G)\) is a bipartite graph, then each of the sets A and B is a dominating set in G and therefore \(\gamma (G) \le \min \{|A|,|B|\}\). For example, if A and B are partite sets of a path \(P_n\) (with \(n\ge 2\)) and \(|A|\le |B|\), then \(|A|= \lfloor n/2 \rfloor \), \(|B|=\lceil n/2 \rceil \), and \(\gamma (P_n)= \lceil n/3 \rceil \le \lfloor n/2 \rfloor =\min \{|A|,|B|\}\), in particular, \(\gamma (P_n) < \min \{|A|,|B|\}\) for \(n=6\) or \(n\ge 8\). Here we study graphs \(G = ((A,B),E_G)\) for which the equality \(\gamma (G) = \min \{|A|,|B|\}\) holds, that is, we study graphs belonging to the set \({\mathcal {B}}\) of bipartite graphs in which the domination number is equal to the cardinality of the smaller partite set. Such graphs were studied in Hartnell and Rall (1995) and Randerath and Volkmann (1998). Our characterization given in the next theorem is similar but different from those in Hartnell and Rall (1995) and Randerath and Volkmann (1998) [see Theorems 3.6 and 4.1 in Hartnell and Rall (1995), and Theorems 3.3 and 3.4 in Randerath and Volkmann (1998)]. Recently Miotk et al. (2019) observed that the graphs belonging to the set \({\mathcal {B}}\) can also be characterized in terms of some graph operations.

Theorem 2

Let \(G=((A,B),E_G)\) be a connected bipartite graph with \(1\le |A|\le |B|\). Then the following statements are equivalent:

  1. (1)

    \(\gamma (G)=|A|\).

  2. (2)

    \(\gamma (G)=\beta (G)=|A|\).

  3. (3)

    G has the following two properties:

    1. (a)

      Each support vertex of G belonging to B is a weak support and each of its non-leaf neighbors is a support.

    2. (b)

      If x and y are vertices belonging to \(A-(L_G\cup S_G)\) and \(d_G(x,y)=2\), then there are at least two vertices \({\overline{x}}\) and \({\overline{y}}\) in B such that \(N_G({\overline{x}})= N_G({\overline{y}})= \{x,y\}\).

Proof

Assume first that \(\gamma (G)=|A|\). We claim that then \(\alpha (G)=|B|\) and \(\beta (G)=|A|\). It is obvious that \(\alpha (G)\ge |B|\) (as B is independent in G). Thus, it suffices to prove that \(\alpha (G)\le |B|\). Suppose to the contrary that \(\alpha (G)> |B|\), and let I be an \(\alpha \)-set of G. Then \(|I|=\alpha (G)>|B|\), \(V_G-I\) is a dominating set of G, and therefore \(\gamma (G)\le |V_G-I|= |V_G|-|I| <|V_G|-|B|= |A|= \gamma (G)\), a contradiction. Thus, \(\alpha (G)=|B|\) and B is an \(\alpha \)-set of G. From the equality \(\alpha (G)=|B|\) and from Lemma 1 it follows that \(\beta (G)=|A|\). Consequently, (2) holds, and \(\gamma (G)=\beta (G)=|A|\). Now, since \(\gamma (G)= \beta (G)\) and B is an \(\alpha \)-set of G, Theorem 1 implies that G has the properties (a) and (b) of the statement (3).

Assume now that G has the properties (a) and (b) of the statement (3). In a standard way [as in Hartnell and Rall (1995) and Randerath and Volkmann (1998)], we prove that \(\gamma (G)=|A|\). Since A is a dominating set of G, we have \(\gamma (G)\le |A|\), and, therefore, it suffices to show that \(\gamma (G)\ge |A|\). Suppose to the contrary that \(\gamma (G)<|A|\). Let D be a \(\gamma \)-set of G with \(|D\cap A|\) as large as possible. Since \(|A-D|>|D\cap B|\ge 1\) and since each vertex in \(A-D\) has a neighbor in \(D\cap B\), the pigeonhole principle implies that there are two vertices x and y in \(A-D\) which are adjacent to the same vertex in \(D\cap B\). Since \(N_G(B\cap L_G) \subset D\) (by the choice of D) as well as \(A \cap L_G \subset D\) (by (a) and the choice of D), the vertices x and y belong to \(A-(L_G \cup S_G)\). Therefore, by (b), there exist vertices \({\overline{x}}\) and \({\overline{y}}\) in B for which \(N_G({\overline{x}})= N_G({\overline{y}})=\{x,y\}\). The vertices \({\overline{x}}\) and \({\overline{y}}\) belong to \(D\cap B\) (as otherwise \({\overline{x}}\) and \({\overline{y}}\) would not be dominated by D). Now, the set \(D^{\prime }= (D-\{{\overline{x}},{\overline{y}}\})\cup \{x, y\}\) is a dominating set of G, which is impossible as \(|D^{\prime }|=|D|\) and \(|D^{\prime }\cap A|>|D\cap A|\). \(\square \)

As an immediate consequence of Theorem 2 and its proof, we have the following results.

Corollary 3

Let \(G=((A,B),E_G)\) be a connected bipartite graph with \(1\le |A|\le |B|\). If \(\gamma (G)=|A|\), then \(\alpha (G)=|B|\) and \(\beta (G)=|A|\).

Corollary 4

The set \({\mathcal {B}}\) is a subset of the set \({\mathcal {C}}_{\gamma =\beta }\).

Corollary 5

Let T be a tree. If (AB) is a bipartition of T and \(1\le |A|\le |B|\), then the following statements are equivalent:

  1. (1)

    \(\gamma (T)=|A|\).

  2. (2)

    \(\gamma (T)=\beta (T)=|A|\).

  3. (3)

    T has the following two properties:

    1. (a)

      If \(v\in B\cap S_T\), then v is a weak support and \(N_T(v)-L_T\subseteq S_T\).

    2. (b)

      If x and y are vertices belonging to \(A-(L_T\cup S_T)\), then \(d_T(x,y)\not =2\) (or, equivalently, \(|N_T(z) \cap (A-S_T)|\le 1\) for every z belonging to \(B-(L_T\cup S_T))\).

The corona\(F \circ K_1\) of a graph F is the graph formed from F by adding a new vertex \(v^{\prime }\) and edge \(vv^{\prime }\) for each vertex v of F. A graph G is said to be a corona graph if \(G = F \circ K_1\) for some graph F. We note that a graph G is a corona graph if and only if each vertex of G is a leaf or it is adjacent to exactly one leaf of G, and consequently every corona graph belongs to the set \({\mathcal {C}}_{\gamma =\beta }\). Payan and Xuong (1982) and Fink et al. (1985) have proved that for a connected graph G of even order is \(\gamma (G)=|V_G|/2\) if and only if G is the cycle \(C_4\) or the corona \(F\circ K_1\) for any connected graph F [see also Topp and Vestergaard (1995) for a short proof]. From this (or directly from Theorem 2) we immediately have the following corollary.

Corollary 6

Let \(G=((A,B),E_G)\) be a connected bipartite graph with \(|A| = |B|\). Then \(\gamma (G)=|A|\) if and only if G is a 4-vertex cycle or the corona of a connected bipartite graph.

Simple examples illustrating relations between graphs considered in Theorems 1 and 2 , and Corollaries 12, and 46 are shown in Fig. 2.

Fig. 2
figure 2

Examples illustrating relations between graphs considered in Theorems 1 and 2, and Corollaries 1, 2, and 46

Let \({{\mathcal {T}}}_{{\max }}\) denote the set of trees for which the domination number is equal to the size of its smaller partite set. We now provide a constructive characterization of the trees belonging to the set \({{\mathcal {T}}}_{{\max }}\). Similar constructive characterizations of trees for different domination related parameters or properties have been presented in e.g. Alvarado et al. (2016), Henning and Klostermeyer (2017), Henning and Marcon (2016), and Rad (2017). Our characterization is based on four simple operations. To present these operations, we introduce some additional term. A vertex v of a graph G is called \(\gamma ^-\)-critical if \(\gamma (G-v) < \gamma (G)\) (or, equivalently, if \(\gamma (G-v) = \gamma (G)-1\)). Such vertices have been intensively studied [see e.g. Haynes and Henning (2003), Samodivkin (2008), and Sampathkumar and Neeralagi (1992)]. In particular, Sampathkumar and Neeralagi (1992) have observed that a vertex v of G is \(\gamma ^-\)-critical if and only if \(PN_G[v,D]=\{v\}\) for some \(\gamma \)-set D containing v.

Let \({{\mathcal {T}}}\) be the family of trees T that can be obtained from a sequence of trees \(T_0, \ldots , T_k\), where \(k\ge 0\), \(T_0=K_2\) and \(T=T_k\). In addition, if \(k\ge 1\), then for each \(i=1,\ldots ,k\), the tree \(T_i\) can be obtained from the tree \(T^{\prime }=T_{i-1}\) with the bipartition \((A^{\prime },B^{\prime })\), where \(|A^{\prime }| \le |B^{\prime }|\), by one of the following four operations \({{\mathcal {O}}}_1\), \({{\mathcal {O}}}_2\), \({{\mathcal {O}}}_3\), and \({{\mathcal {O}}}_4\) defined below and illustrated in Fig. 3.

\({{\mathcal {O}}}_1\):

Add a new vertex b to \(T^{\prime }\) and join b to an \(A^{\prime }\)-vertex \(a^{\prime }\) of \(T^{\prime }\).

\({{\mathcal {O}}}_2\):

Add a new vertex a to \(T^{\prime }\) and join a to a \(B^{\prime }\)-vertex \(b^{\prime }\) of \(T^{\prime }\) such that \(N_{T^{\prime }}(b^{\prime })\subseteq S_{T^{\prime }}\) and \(b^{\prime }\not \in L_{T^{\prime }}\).

\({{\mathcal {O}}}_3\):

Add two new vertices a and b to \(T^{\prime }\), and join b to a and to an \(A^{\prime }\)-vertex \(a^{\prime }\) of \(T^{\prime }\), where \(a^{\prime }\) is a support of \(T^{\prime }\).

\({{\mathcal {O}}}_4\):

Add two new vertices a and b to \(T^{\prime }\), and join a to b and to a \(B^{\prime }\)-vertex \(b^{\prime }\) of \(T^{\prime }\) which is not a \(\gamma ^-\)-critical vertex in \(T^{\prime }\).

Fig. 3
figure 3

Operations \(\mathcal{O}_1\), \(\mathcal{O}_2\), \(\mathcal{O}_3\), and \(\mathcal{O}_4\)

Each of the vertices \(a^{\prime }\) in the above defined operations \({{\mathcal {O}}}_1\) and \({{\mathcal {O}}}_3\), and \(b^{\prime }\) in the operations \({{\mathcal {O}}}_2\) and \({{\mathcal {O}}}_4\), is called the attacher of \(T^{\prime }\). We shall prove that the trees in \({{\mathcal {T}}}\) are precisely the trees belonging to the family \({{\mathcal {T}}}_{{\max }}\). Our first aim is to show that each tree in \({{\mathcal {T}}}\) belongs to the family \({{\mathcal {T}}}_{{\max }}\). For this purpose we prove the following lemma.

Lemma 2

If \(T \in {{\mathcal {T}}}\), then \(T \in {{\mathcal {T}}}_{\mathrm{max}}\).

Proof

Let \(T_0, T_1, T_2,\ldots \) be a sequence of trees, where \(T_0=K_2\) (with an arbitrary chosen bipartition \((A^{\prime },B^{\prime })\) of its 2-element vertex set) and every \(T_n\) can be obtained from the tree \(T_{n-1}\) by one of the operations \({{\mathcal {O}}}_1\), \({{\mathcal {O}}}_2\), \({{\mathcal {O}}}_3\), and \({{\mathcal {O}}}_4\). By induction on n we shall prove that \(T_n\in {{\mathcal {T}}}_{{\max }}\) for every \(n\in {\mathbb {N}}\). If \(n=0\), then \(T_0=K_2\) and \(T_0\in {{\mathcal {T}}}_{{\max }}\) (as \(\gamma (K_2)=\beta (K_2)=1\)). Assume that \(n\ge 1\) and \(T_{n-1}=((A^{\prime },B^{\prime }),E)\) is a tree, where \((A^{\prime },B^{\prime })\) is a bipartition of \(T_{n-1}\) for which \(|A^{\prime }|\le |B^{\prime }|\), and \(\gamma (T_{n-1}) = \beta (T_{n-1})=|A^{\prime }|\). We consider four cases depending on which operation is used to construct the tree \(T=T_n\) from \(T^{\prime }=T_{n-1}\).

Case 1. Tis obtained from \(T^{\prime }\)by Operation \({{\mathcal {O}}}_1\). In this case \((A^{\prime },B^{\prime }\cup \{b\})\) is the bipartition of T and \(|A^{\prime }|<|B^{\prime }\cup \{b\}|\). Now, since \(A^{\prime }\) is a \(\gamma \)-set of \(T^{\prime }\) and b is adjacent to the attacher \(a^{\prime }\) belonging to \(A^{\prime }\), \(A^{\prime }\) is a dominating set of T and therefore \(\gamma (T)\le |A^{\prime }|=\gamma (T^{\prime })\). Consequently, \(\gamma (T) =|A^{\prime }|\) (for if it were \(\gamma (T)< |A^{\prime }|\) and if D were a \(\gamma \)-set of T, then \((D-\{b\})\cup \{a^{\prime }\}\) would be a dominating set of \(T^{\prime }\) and it would be \(\gamma (T^{\prime })\le |(D-\{b\})\cup \{a^{\prime }\}|=|D|<|A^{\prime }| = \gamma (T^{\prime })\), which is a contradiction). This proves that \(T\in {{\mathcal {T}}}_{{\max }}\).

Case 2. Tis obtained from \(T^{\prime }\)by Operation \({{\mathcal {O}}}_2\). Now \(\gamma (T^{\prime })= |A^{\prime }|<|B^{\prime }|\) (for if it were \(\gamma (T^{\prime })= |A^{\prime }|=|B^{\prime }|\), then \(T^{\prime }\) would be the corona of a tree (see Corollary 6) and the operation \({{\mathcal {O}}}_2\) could not be applied to \(T^{\prime }\)) and \((A^{\prime }\cup \{a\},B^{\prime })\) is the bipartition of T. We now claim that \(\gamma (T)= |A^{\prime }\cup \{a\}|=|A^{\prime }|+1\). The inequality \(\gamma (T)\le |A^{\prime }|+1\) is obvious as \(A^{\prime }\cup \{a\}\) is a dominating set of T. Thus, it remains to prove that \(\gamma (T)\ge |A^{\prime }|+1\). Suppose to the contrary that \(\gamma (T) < |A^{\prime }|+1\). Let D be a \(\gamma \)-set of T. Since T is a connected graph of order at least three, it is obvious that we may assume that no leaf of T belongs to D. Then \(b^{\prime }\in D\) and, since \(N_T(b^{\prime })-\{a\}= N_{T^{\prime }}(b^{\prime }) \subseteq S_{T^{\prime }}= S_T- \{a\} \subseteq D\), a is the only private neighbor of \(b^{\prime }\) with respect to D in T, that is, \(PN_T[b^{\prime },D]=\{a\}\). This implies that \(D-\{b^{\prime }\}\) is a dominating set of \(T^{\prime }\). But then we have \(\gamma (T^{\prime }) \le |D-\{b^{\prime }\}|= \gamma (T)-1< |A^{\prime }|= \gamma (T^{\prime })\), a contradiction. This proves that \(T\in {{\mathcal {T}}}_{{\max }}\).

Case 3. Tis obtained from \(T^{\prime }\)by Operation \({{\mathcal {O}}}_3\). This time \((A^{\prime }\cup \{a\},B^{\prime }\cup \{b\})\) is the bipartition of T and, certainly, \(\gamma (T)\le |A^{\prime }\cup \{a\}|=|A^{\prime }|+1\). It remains to prove that \(\gamma (T)\ge |A^{\prime }|+1\). Suppose to the contrary that \(\gamma (T) < |A^{\prime }|+1\). Let D be a \(\gamma \)-set of T. Since T is a connected graph of order at least three, it is obvious that we may assume that no leaf of T belongs to D. This implies that b and the attacher \(a^{\prime }\) are in D. Now it is easy to observe that \(D-\{b\}\) is a dominating set of \(T^{\prime }\) and therefore \(\gamma (T^{\prime }) \le |D-\{b\}|= \gamma (T)-1< |A^{\prime }|= \gamma (T^{\prime })\), a contradiction. This proves that \(T\in {{\mathcal {T}}}_{{\max }}\).

Case 4. Tis obtained from \(T^{\prime }\)by Operation\({{\mathcal {O}}}_4\). In this case \((A^{\prime }\cup \{a\},B^{\prime }\cup \{b\})\) is the bipartition of T and \(|A^{\prime }\cup \{a\}|\le |B^{\prime }\cup \{b\}|\). Therefore \(\gamma (T)\le |A^{\prime }\cup \{a\}| =|A^{\prime }|+1\). We claim that \(\gamma (T)= |A^{\prime }\cup \{a\}|=|A^{\prime }|+1\). It remains to prove that \(\gamma (T)\ge |A^{\prime }|+1\). Suppose to the contrary that \(\gamma (T) < |A^{\prime }|+1\). Let D be a \(\gamma \)-set of T. Then \(\gamma (T)=|D|\le |A^{\prime }|=\gamma (T^{\prime })\). We may assume that \(a\in D\) (otherwise we could replace D with \((D-\{b\})\cup \{a\}\)). Now, the attacher \(b^{\prime }\) is dominated only by a (as otherwise \(D-\{a\}\) would be a dominating set of \(T^{\prime }\) and it would be \(\gamma (T^{\prime })\le |D-\{a\}|<|A^{\prime }|=\gamma (T^{\prime })\), a contradiction). Then \(D-\{a\}\) is a dominating set of \(T^{\prime }-b^{\prime }\). Consequently, \(\gamma (T^{\prime }- b^{\prime })\le |D-\{a\}|<|A^{\prime }|=\gamma (T^{\prime })\), contradicting the premise that \(b^{\prime }\) is not \(\gamma ^-\)-critical in \(T^{\prime }\), that is, \(\gamma (T^{\prime }- b^{\prime })\ge \gamma (T^{\prime })\) for the attacher \(b^{\prime }\) in Operation \({{\mathcal {O}}}_4\). This proves that \(T\in {{\mathcal {T}}}_{{\max }}\) and completes the proof. \(\square \)

We are now ready to provide a constructive characterization of the trees belonging to the family \({{\mathcal {T}}}_{{\max }}\).

Theorem 3

\({{\mathcal {T}}}={{\mathcal {T}}}_{{\max }}\).

Proof

It follows from Lemma 2 that \({{\mathcal {T}}}\subseteq {{\mathcal {T}}}_{{\max }}\). Conversely, suppose T is a tree belonging to the family \({{\mathcal {T}}}_{\mathrm{max}}\). Let (AB) be a bipartition of T, where \(1\le |A|\le |B|\). By induction on the order of T we shall prove that if \(\gamma (T)=|A|\), then T belongs to \({{\mathcal {T}}}\), that is, T can be obtained from \(K_2\) (which belongs to \({{\mathcal {T}}}\) and \({{\mathcal {T}}}_{{\max }}\)) by repeated applications of the operations \({{\mathcal {O}}}_1\), \({{\mathcal {O}}}_2\), \({{\mathcal {O}}}_3\), and \({{\mathcal {O}}}_4\). If T is a star on at least three vertices, then T can be obtained from \(K_2\) by repeated applications of operation \({{\mathcal {O}}}_1\) (that is, attaching leaves to the only A-vertex of \(K_2\)), thus implying that \(T\in {{\mathcal {T}}}\). Hence, we may assume that \(\text{ diam }(T)\ge 3\). We consider two cases: \(|A|=|B|\), \(|A|<|B|\).

Case 1. If \(|A|=|B|\) and \(\gamma (T)=|A|\), then it follows from Corollary  6 that T is the corona of some tree R. Thus T has a vertex, say v, of degree 2. Let \(v^{\prime }\) be the only non-leaf neighbor of v. Let l and \(l^{\prime }\) be the only leaves adjacent to v and \(v^{\prime }\), respectively. Now, it is obvious that the tree \(T^{\prime }=T-\{v,l\}\) is the corona (of the tree \(R-v\)) and therefore \(\gamma (T^{\prime })= |V_{T^{\prime }}|/2 = |A|-1=|B|-1\). Thus, \(T^{\prime }\in {{\mathcal {T}}}_{{\max }}\) and the induction hypothesis implies that \(T^{\prime }\in {{\mathcal {T}}}\). Consequently \(T\in {{\mathcal {T}}}\), since T can be rebuilt from \(T^{\prime }\) by applying the operation \({{\mathcal {O}}}_3\) (resp. \({{\mathcal {O}}}_4\)) if the attacher \(v^{\prime }\) is an A-vertex (resp. a B-vertex) in \(T^{\prime }\).

Case 2. If \(|A|<|B|\), then we consider two subcases: \(A\cap L_T\not = \emptyset \), \(A\cap L_T= \emptyset \).

Subcase 2a. Assume first that \(A\cap L_T\not = \emptyset \). Let v be a vertex belonging to \(A\cap L_T\), and let \(v^{\prime }\) be the only neighbor of v. Then it follows from Corollary 5 that every vertex belonging to \(N_T(v^{\prime })-\{v\}\) is a support vertex in T. Now \((A-\{v\},B)\) is a bipartition of the subtree \(T^{\prime }=T-v\) and it is easy to observe that \(\gamma (T^{\prime })= |A-\{v\}|<|B|\) (for if it were \(\gamma (T^{\prime })< |A-\{v\}|\) and if D were a \(\gamma \)-set of \(T^{\prime }\), then \(D\cup \{v\}\) would be a dominating set of T and it would be \(\gamma (T)\le |D\cup \{v\}| = \gamma (T^{\prime })+1<|A|=\gamma (T)\), a contradiction). Consequently, \(T^{\prime }\in {{\mathcal {T}}}_{{\max }}\) and the induction hypothesis implies that \(T^{\prime }\in {{\mathcal {T}}}\). Now, since every neighbor of \(v^{\prime }\) in \(T^{\prime }\) is a support vertex, the tree T can be rebuilt from \(T^{\prime }\) by applying the operation \({{\mathcal {O}}}_2\) with the attacher \(v^{\prime }\). This proves that \(T\in {{\mathcal {T}}}\).

Subcase 2b. Finally assume that \(A\cap L_T= \emptyset \). Then \(L_T\subseteq B\) and \(S_T\subseteq A\). Let \((x_0, x_1,\ldots , x_d)\) be the longest path in T. Since \(x_0\) and \(x_d\) are leaves in T and \(d=\text{ diam }(T)\ge 3\), necessarily \(x_0\in B\), \(x_1\in A\), \(x_2\in B\), \(x_3\in A\), \(\ldots \), \(x_d\in B\) and therefore \(d\ge 4\). If \(\deg _T(x_1)>2\), then \((A,B -\{x_0\})\) is a bipartition of the subtree \(T^{\prime }=T-x_0\) of T and it is obvious that \(\gamma (T^{\prime })= |A|\le |B -\{x_0\}|\). Thus \(T^{\prime }\in {{\mathcal {T}}}_{{\max }}\) and the induction hypothesis implies that \(T^{\prime }\in {{\mathcal {T}}}\). Now the tree T can be rebuilt from \(T^{\prime }\) by applying the operation \({{\mathcal {O}}}_1\) with the attacher \(x_1\). If \(\deg _T(x_1)=2\), then \((A-\{x_1\},B -\{x_0\})\) is a bipartition of the subtree \(T^{\prime }=T-\{x_0,x_1\}\) of T and \(|A-\{x_1\}|< |B -\{x_0\}|\). It is a simple matter to see that \(\gamma (T^{\prime })= |A-\{x_1\}|=|A|-1\). Thus \(T^{\prime }\in {{\mathcal {T}}}_{{\max }}\) and the induction hypothesis implies that \(T^{\prime }\in {{\mathcal {T}}}\). We now claim that \(x_2\) is not a \(\gamma ^-\)-critical vertex in \(T^{\prime }\). Suppose, contrary to our claim, that \(x_2\) is a \(\gamma ^-\)-critical vertex in \(T^{\prime }\). Then \(\gamma (T^{\prime }-x_2)=\gamma (T^{\prime })-1=|A|-2\). But now, if D is a \(\gamma \)-set of \(T^{\prime }-x_2\), then \(D\cup \{x_1\}\) is a dominating set of T and \(\gamma (T)\le |D\cup \{x_1\}|=|A|-1<\gamma (T)\), a contradiction. Consequently, since \(x_2\) is not a \(\gamma ^-\)-critical vertex in \(T^{\prime }\), the tree T can be rebuilt from \(T^{\prime }\) by applying the operation \({{\mathcal {O}}}_4\) with the attacher \(x_2\). This completes the proof. \(\square \)

4 Algorithmic consequences

Our characterization of graphs belonging to the set \({{\mathcal {C}}}_{\gamma =\beta }\), given in Theorem 1, is non-practical from algorithmic point of view, since this characterization involves \(\alpha \)-sets. However Theorem 2 allows us to propose a quadratic-time algorithm for recognizing bipartite graphs with the domination number equal to the size of the smaller partite set. The idea of our algorithm follows that in Arumugam et al. (2013) (see “Appendix” for the original algorithm), with the only difference of a slightly more thorough running time analysis, based upon the following obvious lemma.

Lemma 3

In a bipartite graph \(G=((A,B),E_G)\) of order n there are at most n / 2 subsets \(\{x,y\} \subseteq A\) such that \(d_G(x,y)=2\) and for which there are at least two vertices \({\overline{x}}\) and \({\overline{y}}\) in B satisfying \(N_G({\overline{x}})= N_G({\overline{y}}) = \{x,y\}\).

The next corollary is immediate from Theorem 2 and Lemma 3.

Corollary 7

Let \(G=((A,B),E_G)\) be a connected n-vertex bipartite graph with \(1\le |A| \le |B|\). If \(\gamma (G)=|A|\), then there are at most n / 2 subsets \(\{x,y\} \subseteq A -(L_G\cup S_G)\) for which \(d_G(x,y)=2\).

Theorem 4

If \(G=((A,B),E_G)\) is a connected n-vertex bipartite graph with \(1\le |A| \le |B|\), then the equality \(\gamma (G)=|A|\) can be verified in \(O(n^2)\) time.

Proof

First observe that if \(|A|=|B|\), then by Corollary 6 all we need is to verify whether G is a 4-vertex cycle or a corona graph, which can be done in \(O(n+m)\) time, where \(m=|E_G|\). Thus assume \(|A| < |B|\). Then it suffices to verify the properties (3a) and (3b) in Theorem 2. The first property can be easily verified in \(O(n^2)\) time by identifying and distinctly marking non-leaf and support vertices. To verify the second property, we first determine and distinctly mark the vertices in \(A^{\prime }=A - (L_G\cup S_G)\) by using the prior markings. Next, similarly as in Arumugam et al. (2013), by considering vertices in B of degree two whose both neighbors are in \(A^{\prime }\), we create a multigraph M (represented by the adjacency matrix, constructed in \(O(n^2)\) time) on the vertex set \(A^{\prime }\) in which the multiplicity of each edge joining two vertices is equal to the number of their common neighbors of degree two in B. Then, for each vertex \(b \in B\), we construct the list L(b) of vertices adjacent to b in \(A^{\prime }\). Since each of these lists is of length at most n, all that can be easily done in \(O(n^2)\) time. We continue by checking for each \(b \in B\) and every two vertices a and \(a^{\prime }\) belonging to L(b) whether the multiplicity of edge \(aa^{\prime }\) in M is at least 2, and we stop whenever checking fails (as then \(\gamma (G) \ne |A|\)). As observed in Arumugam et al. (2013), this may require \(\Theta (\sum _{b \in B} |L(b)|^2)=\Theta (\sum _{v \in V_G} \deg ^2(v))\) time. However, since a subset \(\{a,a^{\prime }\}\) can be checked at most \(n-2\) times, whereas at most n / 2 of such subsets can be positively examined (by Corollary 7), the algorithm always stops after \(O(n^2)\) steps.\(\square \)

Lemma 3 allows to conclude that all the graphs belonging to the set \({\mathcal {C}}_{\gamma =\beta }\) can also be recognized in \(O(n^2)\) time. Namely, Arumugam et al. (2013) proposed an algorithm that recognizes whether a given graph G belongs to the set \({\mathcal {C}}_{\gamma =\beta }\) in the claimed time complexity of \(O(\sum _{v \in V_G} \deg ^2(v))\) (again see “Appendix”). The most time consuming step in their algorithm (Step 3.2.4 in “Appendix”), after a preprocessing step for determining the relevant bipartition (AB) of the subgraph H resulting from G by deleting all edges whose both end-vertices are support vertices, is to check whether for every non-support distinct vertices \(a,a^{\prime } \in A\), if a and \(a^{\prime }\) have some common neighbor, then they have at least two common neighbors of degree two, which takes \(O(\sum _{b \in B} \deg ^2_H(b))=O(\sum _{v \in V_G} \deg ^2(v))\) time in total. However, similarly as in the proof of Theorem 4, notice that a 2-element subset \(\{a,a^{\prime }\}\) of A can be checked at most \(n-2\) times, whereas at most n / 2 such subsets can ‘pass the test’ by Lemma 3 and Theorem 1.1 in Arumugam et al. (2013). Hence, we obtain the following corollary.

Corollary 8

Let G be an n-vertex graph without isolated vertices. Then the equality \(\gamma (G)=\beta (G)\) can be verified in \(O(n^2)\) time.

Fig. 4
figure 4

Bipartite graph G with \(\sum _{v \in V_G-A} \deg ^2_G(v)=\Theta (n^2)\)

It is a natural question to ask whether the running time analysis of our algorithm [and that in Arumugam et al. (2013)] can be improved, say, to obtain the running time \(O(n^{2-\varepsilon })\) for some \(\varepsilon >0\). Showing that there exists an infinite class of bipartite graphs \(G=((A,B),E_G)\) in which the most time consuming step of our algorithm being of order \(\sum _{b \in B} |L(b)|^2\) can be \(\Theta (n^{2})\), we prove that this question has a negative answer. Let n and p be integers, where \(n\ge 16\) and \(p=\lfloor \sqrt{n}/2 \rfloor \). The multigraph of order p in which every two vertices are joined by exactly two multiple edges is denoted by \(K_p^{\prime \prime }\). Now let G be the graph obtained from the join \(K_p^{\prime \prime }+{\overline{K}}_{n-p^2}\) by subdividing each of its double edges exactly once (as illustrated in Fig. 4, where \(S(K_p^{\prime \prime })\) is the subdivision graph of \(K_p^{\prime \prime }\)). It is obvious that G is a leafless bipartite graph in which \(A=V_{K_p^{\prime \prime }}\) and \(B=V_G-A\) are partite sets and \(1<|A|=p<n-p= |B|\). Because sets \(L_G\) and \(S_G\) are empty, and for every distinct vertices x and y in A there are distinct vertices \({\overline{x}}\) and \({\overline{y}}\) in B such that \(N_G({\overline{x}})= N_G({\overline{y}})= \{x,y\}\), it follows from Theorem 2 that \(\gamma (G)=|A|\). On the other hand, it immediately follows from the construction of G that \(\sum _{v \in B} \deg ^2_G(v)= \Theta (n^2)\), and so our algorithm [and that in Arumugam et al. (2013)], when executed on G, will stop only after \(\Theta (n^2)\) steps. Of course, this example does not prove the quadratic lower bound for verifying the equality \(\gamma (G)=\beta (G)\) by any algorithm (cf. Arumugam et al. 2013, Remark 4.2, p. 1865).

5 Mobile guards in grids

We finalize our paper with a practical application of Theorem 4 in guarding grids. Namely, let \({{\mathcal {S}}}=\{S_1,S_2,\ldots ,S_n \}\) be a family of distinct vertical and horizontal closed line segments in the plane, where every two collinear line segments are disjoint. This family is called a grid if \(n\ge 2\) and the union \(\bigcup {{\mathcal {S}}}= S_1 \cup S_2 \cup \cdots \cup S_n\) is a connected subset of \({\mathbb {R}}^2\). The intersection graph of the family \({{\mathcal {S}}}\) is denoted by \(G_{{\mathcal {S}}}\) (and it is the graph with vertex-set \({{\mathcal {S}}}\) and edge-set \(\{S_iS_j:i\not =j, \,\,S_i, S_j\in {{\mathcal {S}}},\,\, \text{ and } \,\, S_i\cap S_j\not =\emptyset \}\)). It is obvious that if \({{\mathcal {S}}}\) is a grid, then \(G_{{\mathcal {S}}}\) is a connected bipartite graph and the pair \((V_{{\mathcal {S}}},H_{{\mathcal {S}}})\) is its bipartition, where \(V_{{\mathcal {S}}}\) (\(H_{{\mathcal {S}}}\), resp.) is the set of all vertical (horizontal, resp.) line segments of \({{\mathcal {S}}}\) (Ntafos 1986). An example of a grid \({\mathcal {S}}\) and the intersection graph \(G_{{\mathcal {S}}}\) (corresponding to the family \({{\mathcal {S}}}= V_{{\mathcal {S}}}\cup H_{{\mathcal {S}}}\), where \(V_{{\mathcal {S}}}=\{x, y,z, u,v\}\) and \(H_{{\mathcal {S}}}=\{a, b, c, d, e, f, g, h\}\)) are shown in Fig. 5.

Fig. 5
figure 5

Grid \({\mathcal {S}}\) and its intersection graph \(G_{{\mathcal {S}}}\)

A mobile guard is a guard traveling along a line segment of a grid, and patrolling this line segment and all the intersected line segments. We identify a mobile guard traveling along a line segment x with the same segment x and say that x patrols itself and the line segments intersected by x. A set \({\mathcal {C}}\subseteq {\mathcal {S}}\) of mobile guards is called a patrolling set of the grid \({\mathcal {S}}\) if every line segment \(x\in {{\mathcal {S}}}\) is either an element of \({{\mathcal {C}}}\) or is intersected by an element of \({{\mathcal {C}}}\). The problem of mobile guards patrolling a grid is a variant of the traditional art gallery problem and it was formulated by Ntafos (1986), and then its next variants were studied in a number of papers, see, for example, Bose et al. (2013), Brimkov (2013), Dumitrescu et al. (2014), Fekete et al. (2018), Katz et al. (2005), Korman et al. (2017) and Tan and Jiang (2018). Katz et al. (2005) observed that the decision problem associated with finding the minimum cardinality of a set of mobile guards patrolling a given grid is NP-complete. On the other hand it is obvious that all vertical line segments of a grid \({\mathcal {S}}\) (as well as all horizontal line segments of \({\mathcal {S}}\)) form a patrolling set of \({\mathcal {S}}\) and therefore the smallest number of mobile guards patrolling \({\mathcal {S}}\) is at most \(\min \{|V_{{\mathcal {S}}}|,|H_{{\mathcal {S}}}|\}\). A grid \({\mathcal {S}}\) is said to be extremal if the number of mobile guards required to patrol \({\mathcal {S}}\) is equal to \(\min \{|V_{{\mathcal {S}}}|,|H_{{\mathcal {S}}}|\}\), and we refer to the problem of recognizing extremal grids as the extremal guard cover problem. From the obvious fact that a subset \({\mathcal {C}}\) of a grid \({\mathcal {S}}\) is a set of mobile guards patrolling \({{\mathcal {S}}}\) if and only if \({\mathcal {C}}\) is a dominating set of the intersection graph \(G_{{\mathcal {S}}}\) (see Katz et al. 2005), it follows that \({\mathcal {S}}\) is an extremal grid if and only if \(G_{{\mathcal {S}}}\) is a bipartite graph in which the domination number is equal to the cardinality of the smaller of bipartite sets of the graph \(G_{{\mathcal {S}}}\). Thus the extremal guard cover problem for a grid \({\mathcal {S}}\) with n line segments can be solved by considering the intersection graph \(G_{{\mathcal {S}}}\) [which can be constructed in \(O(n \log n + m)\) time, where \(m=O(n^2)\) is the number of intersection points of line segments of \({\mathcal {S}}\), see Balaban (1995)] and then recognizing whether the domination number of \(G_{{\mathcal {S}}}\) is equal to \(\min \{|V_{{\mathcal {S}}}|,|H_{{\mathcal {S}}}|\}\), which can be done in \(O(n^2)\) time (by Theorem 4). However, since here geometry is involved and intersection graphs of grids form a restricted class of bipartite graphs, some significant improvement in the last statement is possible. We begin with the following lemma.

Fig. 6
figure 6

Illustration for the proof of Lemma 4

Lemma 4

Let \(G_{{\mathcal {S}}} = ((A,B),E_{G_{{\mathcal {S}}}})\) be the intersection graph of a grid \({\mathcal {S}}\). If \(G_{{\mathcal {S}}}\) is leafless and for any two distinct vertices x and y belonging to A, and having a common neighbor, there exists a vertex z in B such that \(N_{G_{{\mathcal {S}}}}(z)= \{x,y\}\), then \(\max \{\deg _{G_{{\mathcal {S}}}}(b):b \in B\} \le 4\).

Proof

Without loss of generality assume that \(A=V_{{\mathcal {S}}}\), \(B=H_{{\mathcal {S}}}\), and suppose that some horizontal line segment h intersects five vertical line segments \(v_1, v_2,\ldots , v_5\), say at points \(C_1(x_1,y_0), C_2(x_2,y_0),\ldots , C_5(x_5,y_0)\), respectively, with \(x_1< x_2< \cdots < x_5\). Let \(\varepsilon \) be a real number such that \(0<\varepsilon \le \min \{x_{i+1}-x_i :i=1, \ldots ,4 \}/100\). Since the line segment h (as a vertex of \(G_{{\mathcal {S}}}\)) is a common neighbor of every two distinct line segments belonging to the set \(\{v_1, \ldots , v_5\}\), by assumption for every two indexes i and j (\(1\le i<j\le 5\)) there exists a horizontal line segment \(h_{ij}\) which intersects the line segments \(v_i\) and \(v_j\) only. Assume that \(h_{ij}\) intersects \(v_i\) and \(v_j\) at points \(L_{ij}(x_i,y_{ij})\) and \(R_{ij}(x_j,y_{ij})\), respectively, for some \(y_{ij}\). These points define two new points \(L^+_{ij}(x_i+\varepsilon ,y_{ij})\) and \(R^-_{ij}(x_j-\varepsilon ,y_{ij})\), respectively, which lie between \(L_{ij}\) and \(R_{ij}\) (see Fig. 6 for an illustration). Now it follows from the choice of \(\varepsilon \) that the points \(C_1, C_2,\ldots , C_5\) together with the polygonal chains \(C_iL^+_{ij}R^-_{ij}C_j\), where \(1\le i<j\le 5\), form a planar representation of the complete non-planar graph \(K_5\), a contradiction. \(\square \)

The next corollary is immediate from Lemma 4 and Theorem 2.

Corollary 9

Let \(G_{{\mathcal {S}}} = ((A,B),E_{G_{{\mathcal {S}}}})\) be the intersection graph of a grid \({\mathcal {S}}\). If \(1 \le |A| \le |B|\) and \(\gamma (G_{{\mathcal {S}}})=|A|\), then \(|N_{G_{{\mathcal {S}}}}(b) -(L_{G_{{\mathcal {S}}}}\cup S_{G_{{\mathcal {S}}}})| \le 4\) for every b in B.

In our last theorem we present the announced time complexity upper bound for the extremal guard cover problem.

Theorem 5

If \({{\mathcal {S}}}\) is a grid with n distinct line segments, then the extremal guard cover problem for \({{\mathcal {S}}}\) can be solved in \(O(n \log n + m)\) time, where m is the number of intersection points of line segments of \({\mathcal {S}}\).

Proof

Let \(G_{{\mathcal {S}}}=((A,B),E_{G_{{\mathcal {S}}}})\) be the intersection graph of \({\mathcal {S}}\) with \(1 \le |A| \le |B|\). As already mentioned, the graph \(G_{{\mathcal {S}}}\) can be constructed in \(O(n \log n + m)\) time (Balaban 1995), and thus it remains to show that in the same time we can verify whether \(\gamma (G_{{\mathcal {S}}})=|A|\).

First, similarly as in the proof of Theorem 4, if \(|A|=|B|\), then we verify whether \(G_{{\mathcal {S}}}\) is \(C_4\) or a corona graph, which can be done in \(O(n+m)\) time. Thus assume \(|A| < |B|\). In this case it suffices to verify the properties (3a) and (3b) in Theorem 2. The first property can be verified in \(O(n+m)\) time by identifying and distinctly marking non-leaf and support vertices. To verify the second property, we first determine and distinctly mark the vertices in \(A^{\prime }=A - (L_{G_{{\mathcal {S}}}}\cup S_{G_{{\mathcal {S}}}})\) by using the prior markings. Next, in linear time we check if the inequality \(\max _{b \in B} |N(b) - (L_{G_{{\mathcal {S}}}} \cup S_{G_{{\mathcal {S}}}})| \le 4\) holds for every b in B. If \(\max _{b \in B} |N(b) - (L_{G_{{\mathcal {S}}}} \cup S_{G_{{\mathcal {S}}}})| \ge 5\) for some \(b\in B\), then we stop as \(\gamma (G_{{\mathcal {S}}}) \ne |A|\) (by Corollary 9). Otherwise for each vertex in B of degree two whose both neighbors x and y are in \(A^{\prime }\), we list the set \(\{x,y\}\). Then we sort the resulting list L of 2-element sets lexicographically in order to compute the number of sets on the list that occur exactly once. If there is at least one such set, then we stop, as \(\gamma (G_{{\mathcal {S}}}) \ne |A|\) (by the property (5b) in Theorem 2). Otherwise, we continue by truncating the list to store now each set only once. Since the original list is of length at most n, all that can be done in \(O(n \log n)\) time. Next, similarly as in Arumugam et al. (2013), for each vertex \(b \in B\), we construct the list L(b) of vertices adjacent to b in \(A^{\prime }\). Since each of these lists is of length at most 4 (by the stop condition positively verified above), all that can be done in O(n) time. Finally, using a binary search on L, for each \(b \in B\) and each 2-element subset \(\{x, y\}\) of L(b) we check whether \(\{x,y\}\) is on the (truncated) list L, and we stop whenever checking fails (as then \(\gamma (G_{{\mathcal {S}}}) \ne |A|\)). This may require checking as many as \(\Theta (\sum _{b \in B} |L(b)|^2)\) sets, however, since we handle the case \(|L(b)| \le 4\), the total running time of our algorithm becomes then \(O(n \log n+m)\) as required.\(\square \)