1 Introduction

Throughout this paper, we concentrate only on finite and simple graphs. Given a graph \(G=(V(G),E(G))\) and set the order \(n=|V(G)|\). The open neighborhood of a vertex \(v\in V(G)\) is \(N_G(v)=\{u\in V(G):uv\in E(G)\}\), and its closed neighborhood is \(N_G[v]=N_G(v) \cup \{v\}\). The degree of v in G, denoted by \(d_G(v)\), is defined as \(|N_G(v)|\). We use d(v) for \(d_G(v)\) if there is no ambiguity. The minimum degree and maximum degree among the vertices of G is denoted by \(\delta (G)\) and \(\Delta (G)\), respectively. For a set \(S \subseteq V(G)\), its open neighborhood is the set \(N_G(S) = \bigcup _{v\in S}N_G(v)\), and its closed neighborhood is \(N_G[S]= N_G(S) \cup S\). A set \(S\subseteq V(G)\) is called a dominating set of G if \(N_G[S]=V(G)\). The minimum cardinality over all dominating sets of G is domination number \(\gamma (G)\).

The domination problem of graphs plays a key role in graph theory and in practical applications, especially in theoretical computer science. For example, monitor a communication system by placing as few devices in the system as possible is closely related to the dominating set problem. The important theoretical and practical significance of the domination issues are emphasized in [6, 11, 12]. In the light of the above, the classical domination and its variations have been extensively studied in [7, 10, 13, 21, 23].

Roman domination, as a variation in domination, originated from the problem of how to develop defense strategies to defend the Roman Empire [20]. Naturally, in modern practical application, it is well suited to solving the security problems of communication networks so that network system is defended against attacks. Double Roman domination is the stronger version of Roman domination, which was introduced by Beeler et al. [4]. Since then, it has been attracted considerable attentions in recent years [1, 14, 17, 19, 22, 24].

A function \(f:V(G)\rightarrow \{0,1,2,3\}\) is a double Roman dominating function (DRD-function) on a graph G, if the following conditions hold.

  1. (i)

    If \(f(v)=0\), then vertex v has at least two neighbors in \(V_2\) or one neighbor in \(V_3\);

  2. (ii)

    If \(f(v)=1\), then vertex v has at least one neighbor in \(V_2\cup V_3\).

where \(V_i\) denotes the set of vertices assigned i by function f. The weight of a double Roman dominating function is the sum \(\sum _{v\in V(G)}f(v)\). This also equals to \(|V_1|+2|V_2|+3|V_3|\). The double Roman domination number \(\gamma _{dR}(G)\) is the minimum weight of a double Roman domination of G.

Recently, Mojdeh el at. [18] introduced a new version of double Roman domination, which is defined as follows. A restrained double Roman dominating function (for short, RDRD-function) \(f:V(G) \rightarrow \{0,1,2,3\}\) is a double Roman dominating function satisfying the property that the subgraph induced by \(V_0\) contains no isolated vertex. The weight of an RDRD-function f is the value \(w(f)=\sum _{v \in V(G)} f(v)\), and the minimum weight over all RDRD-functions on G is the restrained double Roman domination number (RDRD-number) \(\gamma _{\textrm{rdR}}(G)\) of G. For the sake of convenience, an RDRD-function f of a graph G with weight \(\gamma _{\textrm{rdR}}(G)\) is called a \(\gamma _{\textrm{rdR}}(G)\)-function. Note that, for any graph G, \(\gamma _{\textrm{rdR}}(G)\ge \gamma _{dR}(G)\).

In [18], Mojdeh el at. showed that the decision problem associated with computing RDRD-number of a graph is NP-hard, and then, they presented an upper bound on RDRD-number of a connected graph G in terms of the order of G and characterize the graphs attaining this bound. In the end of their paper, they also posed some open problems for further consideration. Among them, the following two problems are stated as follows.

Problem 1

For any graph G, provided the characterizations of graphs with small or large RDRD-numbers.

Problem 2

To provide some families of graphs for which there might be some polynomial-time algorithms for computing the RDRD-numbers.

Motivated by the above problems, we continue the research on the RDRD-number in this paper. In the next section, the characterizations of graphs with RDRD-numbers \(\{3,4,5\}\) are given. And then, we show the sharp bounds for \(\gamma _{\textrm{rdR}}(G)+\gamma _{\textrm{rdR}}(\overline{G})\) for any graph G with order at least 3 in Sect. 3. Finally, we present a linear time algorithm for computing the RDRD-number of any cograph and further give a characterization of cograph with RDRD-number \(2n-2\) in Sect. 4.

Before ending this section, some definitions and concepts are needed. Given a set \(S\subseteq V(G)\), G[S] denotes the subgraph of G induced by S. Let [n] be the set of positive integers at least 1 and at most n. A vertex v is called a common vertex if \(d(v)=n-1\). A pendant vertex is a vertex with degree one, the edge adjacent to pendant vertex is called as a pendant edge. If \(d(v)=0\), we call it an isolated vertex. For two vertex-disjoint graphs \(G_1=(V_1,E_1)\) and \(G_2=(V_2,E_2)\), the disjoint union of \(G_1\) and \(G_2\) is \(G_1\cup G_2=(V_1\cup V_2, E_1\cup E_2)\). The join of \(G_1\) and \(G_2\), denoted by \(G_1\vee G_2\), includes all possible edges between \(V_1\) and \(V_2\), that is \(G_1\vee G_2=(V_1\cup V_2, E_1\cup E_2\cup \{v_1v_2|v_1\in V_1,v_2\in V_2\})\). We follow [5] for graph theoretical notation and terminology not defined here.

2 Small RDRD-Numbers

In this section, the characterizations for graphs with RDRD-numbers \(\gamma _{\textrm{rdR}}(G)\in \{3,4,5\}\) are presented. Before giving the main results, we need the following proposition.

Proposition 2.1

If G is a connected graph of order \(n\ge 2\), then \(\gamma _{\textrm{rdR}}(G)\ge 3\).

Proof

It is known that \(\gamma _{dR}(G) \ge 3\) for any graph G with \(n(G)\ge 2\). Then, the result holds according to \(\gamma _{dR}(G) \le \gamma _{\textrm{rdR}}(G)\). \(\square \)

Observation 2.2

If \(|V_2|=|V_3|=0\), then \(|V_0|=|V_1|=0\).

Let \(f=(V_0,V_1,V_2,V_3)\) be a \(\gamma _{\textrm{rdR}}\)-function of a graph G with order at least 2. By the definition of RDRD-function, we have \(\gamma _{\textrm{rdR}}(G)=|V_1|+2|V_2|+3|V_3|\ge 3\). Firstly, we consider to give the characterization of the graphs with RDRD-number 3. We only consider the connected graph G, since there is no disconnected graph with RDRD-number 3.

Theorem 2.3

Let G be a connected graph of order \(n \ge 2\). Then, \(\gamma _{\textrm{rdR}}(G)=3\) if and only if one of the following two conditions holds.

  1. (i)

    G is a graph with \(n \ge 3\) containing a common vertex and no pendant edges.

  2. (ii)

    G is a \(K_2\).

Proof

Let G be a graph satisfying the condition (i). We define the function f by assigning 3 to the common vertex v and 0 to the remaining vertices. It is easy to see that f is an RDRD-function of G, and then, \(\gamma _{\textrm{rdR}}(G)\le 3\). Otherwise, G is a \(K_2\), then \(\gamma _{\textrm{rdR}}(G)\le 3\) by assigning the two vertices by 1 and 2, respectively. Hence, \(\gamma _{\textrm{rdR}}(G)=3\) by combining Proposition 2.1.

Conversely, if \(\gamma _{\textrm{rdR}}(G)=3\), then \(|V_1|+2|V_2|+3|V_3|=3\). The following two cases should be considered by using Observation 2.2.

Case 1 \(|V_3|=1\) and \(|V_1|=|V_2|=0\).

Without loss of generality, we assume \(V_3=\{v\}\). Since \(n \ge 2\) and the definition of RDRD-function, it follows that \(|V_0|\ge 2\) and \(n \ge 3\). And further, any vertex in \(V_0\) is adjacent to the vertex v and thus \(d(v)=|V_0|=n-1\). Since \(G[V_0]\) contains no isolated vertex, then the degree of any vertex in \(V_0\) is at least 2, this is, there is no pendant edge in G.

Case 2 \(|V_3|=0\) and \(|V_1|=|V_2|=1\).

From the definition of RDRD-function, we know that \(|V_0|=0\), and thus, \(n=|V_1|+|V_2|=2\). Then, \(G=K_2\). \(\square \)

Theorem 2.4

Let G be a graph of order \(n\ge 3\). Then, \(\gamma _{{rdR}}(G)=4\) if and only if one of the following conditions holds.

  1. (i)

    G is a connected graph with \(n \ge 4\) containing exactly one common vertex and one pendant edge.

  2. (ii)

    \(G=\overline{K_2}\vee G_1\) is a connected graph with \(n \ge 6\) and \(\Delta (G)=n-2\) such that \(G_1\) contains no isolated vertex.

  3. (iii)

    G is a \(P_3\).

  4. (iv)

    G is a disconnected graph and G is a \(\overline{K_2}\).

Proof

Note that, (iv) is trivial, we thus need to show that (i)–(iii) are true. Now we first prove that if G is a graph satisfying one of the above conditions (i)–(iii), then \(\gamma _{\textrm{rdR}}(G)=4\). If G satisfies the condition (i), then we define the function f by assigning 3 to the common vertex, 1 to the pendant vertex and 0 to the remaining vertices in G. If G satisfies the condition (ii), then we define f as follows. The two vertices in \(\overline{K_2}\) are assigned 2, and the remaining vertices are assigned 0. It is checked that f is an RDRD-function of G and \(\gamma _{\textrm{rdR}}(G)\le 4\). By using Theorem 2.3, we have \(\gamma _{\textrm{rdR}}(G)\ge 4\). So \(\gamma _{\textrm{rdR}}(G)=4\). Now if \(G=P_3\), then it is easy to check that \(\gamma _{\textrm{rdR}}(G)=4\).

Conversely, if \(\gamma _{\textrm{rdR}}(G)=4\), then \(|V_1|+2|V_2|+3|V_3|=4\). We will prove the result by considering the following cases.

Case 1 \(|V_3|=|V_1|=1, ~|V_2|=0\).

By the definition of RDRD-function, we get that \(|V_0|=n-2 \ge 2\) and \(n \ge 4\). Now we assume that \(V_1=\{x\},~ V_3=\{y\},~V_0=\{v_i| i\in [n-2]\}\). Again from the definition of RDRD-function, we know that x and \(v_i~(i\in [n-2])\) are adjacent to y, and \(G[V_0]\) has no isolated vertices. Thus, \(d(y)=n-1\) and \(d(v_i)\ge 2\) for \(i\in [n-2]\). Now we claim that x is a pendant vertex. Otherwise, \(\gamma _{\textrm{rdR}}(G)=3\) since Theorem 2.3. This is a contradiction. So G is a graph containing exactly one common vertex and one pendant edge.

Case 2 \(|V_3|=|V_1|=0, |V_2|=2\).

We get that \(|V_0|=n-2\). Let \(V_2=\{x,y\}\), \(V_0=\{v_i|i\in [n-2]\}\). By the definition of RDRD-function, every vertex in \(V_0\) is adjacent to both x and y, and \(G[V_0]\) has no isolated vertices. Thus, \(d(x)=d(y)\ge n-2\ge 2\) and \(d(v_i)\ge 3\) \((i\in [n-2])\). Since there are no pendant edges and Theorem 2.3, then \(\Delta (G)\le n-2\). It follows that \(\Delta (G)=n-2\). That is to say, \(3\le d(v_i)\le n-2\) for every \(i \in [n-2]\), and \(d(x)=d(y)=n-2\) (i.e., x and y are not adjacent). Set \(\overline{K_2}=\{x,y\}\) and \(G_1=G[V_0]\), then \(G=\overline{K_2}\vee G_1\). Finally, we only need to prove that \(n \ge 6\). Since \(3 \le d(v_i)\le n-2\), then \(n\ge 5\). Suppose \(n(G)=5\). Since \(G_1\) contains no isolated vertex, then there must be a vertex \(v_i \in G_1\) such that \(d_{G_1}(v_i)=2 > n(G_1)-2=1\), this is a contradiction.

Case 3 \(|V_1|=2, |V_2|=1, |V_3|=0\).

By using the definition of RDRD-function, we get that \(|V_0|=0\) and \(n=|V_1|+|V_2|=3\). From Theorem 2.3, we know that G is not a \(K_3\), and thus, \(G=P_3\). \(\square \)

Theorem 2.5

Let G be a graph of order \(n\ge 4\). Then, \(\gamma _{\textrm{rdR}}(G)=5\) if and only if one of the following conditions holds.

  1. (i)

    G is a connected graph with \(n \ge 5\) and \(\Delta (G)=n-2\) satisfying the following conditions.

    1. (a)

      G contains two non-adjacent vertices xy such that \(d(x)\le n-3\), \(d(y)=n-2\);

    2. (b)

      \(G[V\backslash \{x,y\}]\) contains no isolated vertex.

  2. (ii)

    G is a connected graph with \(n\ge 5\) containing exactly one common vertex and two pendant edges.

  3. (iii)

    G is a connected graph with \(n \ge 5\) and \(\Delta (G)=n-2\) satisfying the following conditions.

    1. (a)

      G contains two non-adjacent vertices xy such that \(d(x) \in \{n-3,n-2\}\) and \(d(y)=n-2\);

    2. (b)

      There exists only one vertex z in G with \(1 \le d(z) \le 2\), and \(G[V\backslash \{x,y,z\}]\) has no isolated vertex.

  4. (iv)

    G is a \(K_{1,3}\).

  5. (v)

    G is a disconnected graph and it is a disjoint union of an isolated vertex and a graph with RDRD-number 3.

Proof

Note that, (v) is trivial, we thus need to show that (i)–(iv) are also true. We first prove that if G satisfies one of the above conditions (i)–(iv), then \(\gamma _{\textrm{rdR}}(G)=5\). First, we have \(\gamma _{\textrm{rdR}}(G)\ge 5\) by Theorem 2.3 and Theorem 2.4. Now we only need to give the upper bounds.

If G is a graph satisfying (i), then we define f by assigning 2 to x, 3 to y and 0 to the remaining vertices. It is easy to check that f is an RDRD-function of G, and then, \(\gamma _{\textrm{rdR}}(G)\le 5\). If G is a graph satisfying (ii), then we define f by assigning 3 to the common vertex, 1 to the two pendant vertices and 0 to the remaining vertices in G. So f is an RDRD-function of G, and \(\gamma _{\textrm{rdR}}(G)\le 5\). If G is a graph satisfying (iii), then we give f by assigning 2 to xy, 1 to z and 0 to the remaining vertices in G. So f is an RDRD-function of G, and thus, \(\gamma _{\textrm{rdR}}(G)\le 5\). Now if G is a \(K_{1,3}\), then it is easy to check that \(\gamma _{\textrm{rdR}}(G)=5\).

Conversely, if \(\gamma _{\textrm{rdR}}(G)=5\), then \(|V_1|+2|V_2|+3|V_3|=5\). By Observation 2.2, the following cases should be considered.

Case 1 \(|V_3|=|V_2|=1, |V_1|=0\).

Let \(V_2=\{x\},V_3=\{y\},V_0=\{v_i|i\in [n-2]\}\). By the definition of RDRD-function, every vertex in \(V_0\) is adjacent to y, and \(G[V_0]\) contains no isolated vertex. We claim that x is not adjacent to y. If not, suppose x is adjacent to y, then we give an RDRD-function f as \((V-\{x,y\},\{x\},\emptyset ,\{y\})\). And thus, \(\gamma _{\textrm{rdR}}(G)\le 4\), a contradiction. From the above, we have \(d(y)=n-2\), \(d(x)\le n-2\). Now we want to prove \(\Delta (G)=n-2\), it is only to prove that every vertex in \(V_0\) has degree at most \(n-2\). Indeed, if a vertex \(v_0 \in V_0\) such that \(d(v_0)=n-1\), then a new RDRD-function can be defined as \((V-\{v_0,x\},\{x\},\emptyset , \{v_0\})\) and thus \(\gamma _{\textrm{rdR}}(G) \le 4\), this is a contradiction. Actually, \(d(x)\le n-3\), otherwise \(\gamma _{\textrm{rdR}}(G)=4\) through using Theorem  2.4 (ii).

Now we only need to show \(n\ge 5\). Note that, \(n \ge 4\) is obvious. Suppose that \(n=4\), and then, \(|V_0|=2\). Without lose of generality, set \(V_0=\{v_1,v_2\}\) and let \(v_1\) is adjacent to x. We define a new RDRD-function as \((V-{\{x,v_1}\},\{x\},\emptyset ,\{v_1\})\), then \(\gamma _{\textrm{rdR}}(G)\le 4\), this is a contradiction.

Case 2 \(|V_3|=1,|V_1|=2, |V_2|=0\).

From \(|V_0|=n-3\ge 2\), then \(n\ge 5\). Let \(V_1=\{x_1,x_2\}, V_3=\{y\},~V_0=\{v_i|i\in [n-3]\}\). By the definition of RDRD-function and \(|V_2|=0\), we get that every vertex in \(V_0 \cup V_1\) is adjacent to y. And further, \(G[V_0]\) contains no isolated vertex. Thus, \(d(y)=n-1\) and \(d(v_i)\ge 2\) for every \(i \in [n-3]\). We claim that \(x_1\) and \(x_2\) are pendant vertices. Otherwise, \(\gamma _{\textrm{rdR}}(G)\le 4\) by Theorem 2.3 (i) and Theorem 2.4, this is a contradiction. Thus, \(2\le d(v_i)\le n-3\) and G contains exactly one common vertex and two pendant edges.

Case 3 \(|V_2|=2,|V_1|=1, |V_3|=0\).

Since \(|V_0|=n-3\ge 2\), then \(n \ge 5\). Let \(V_2=\{x,y\},V_1=\{z\},V_0=\{v_i|i\in [n-3]\}\). By the definition of RDRD-function and \(V_3=\emptyset \), we know that every vertex in \(V_0\) is adjacent to both x and y, \(G[V_0]\) has no isolated vertices and z is adjacent to at least one vertex in \(V_2\). Without lose of generality, suppose z is adjacent to x. Now we claim x and y are not adjacent. Otherwise, an RDRD-function can be defined as \((V-\{x,y\},\{z\},\emptyset ,\{x\})\), then \(\gamma _{\textrm{rdR}}(G)\le 4\), a contradiction. From the above, \(d(x)=n-2\) and \(n-3\le d(y)\le n-2\) hold. If \(d(z)=n-1\) or \(d(v_i)=n-1\) for some \(i \in [n-3]\), then there is no pendant edge, and \(\gamma _{\textrm{rdR}}(G)=3\) by using Theorem 2.3, this is a contradiction. Thus, \(\Delta (G)=n-2\).

Now if \(d(y)=n-3\) and \(G[V{\setminus }\{x,y\}]\) has no isolated vertex, then G is a graph described in (i). Otherwise, there exists only one isolated vertex z in \(G[V\setminus \{x,y\}]\), then \(d(z)=1\). If \(d(y)=n-2\), then it implies that \((y,z)\in E(G)\). Suppose \(G[V\setminus \{x,y\}]\) contains no isolated vertex, then an RDRD-function can be defined as \((V-\{x,y\},\emptyset ,\{x,y\},\emptyset )\), it follows that \(\gamma _{\textrm{rdR}}(G)\le 4\), this is a contradiction. Now there is an isolated vertex z in \(G[V\setminus \{x,y\}]\), then \(d(z)=2\). Note that, \(3\le d(v_i)\le n-2\) for every \(i\in [n-3]\), then the vertex z is a vertex with minimum degree in G. Combining the above analysis, the result holds.

Case 4 \(|V_1|=3, |V_2|=1, |V_3|=0\).

From the definition of RDRD-function, we know that \(|V_0|=0\) and \(n=|V_1|+|V_2|=4\). Let \(V_1=\{x,y,z\}\), \(V_2=\{v\}\). By the definition of RDRD-function, v is adjacent to xy and z. If \(G[V_1]\) contains an edge, say (xy), then an RDRD-function can be defined as \(({\{x,y}\},\{z\},\emptyset ,\{v\})\), it follows \(\gamma _{\textrm{rdR}}(G)\le 4\), this is a contradiction. Thus, G is a \(K_{1,3}\). \(\square \)

3 Nordhaus–Gaddum Inequalities

In this section, we provide sharp bounds on the sum of the RDRD-numbers of a graph and its complement, that is, Nordhaus–Gaddum inequalities for RDRD-numbers of a graph.

Proposition 3.1

[22] Let G be an n-vertex graph and \(n\ge 3\). Then, \(8\le \gamma _{dR}(G)+\gamma _{dR}(\overline{G})\le 2n+3\).

Proposition 3.2

Let G be a graph with n vertices and \(\Delta (G)=\Delta \). Then, \(\gamma _{\textrm{rdR}}(G)\le 2n-\Delta \).

Proof

Let v be a vertex with the degree \(\Delta \). Then, \((\emptyset ,N(v),V(G)\setminus N(v),\emptyset )\) is a RDRD-function of G, thus \(\gamma _{\textrm{rdR}}(G)\le \Delta +2(n-\Delta )=2n-\Delta \). \(\square \)

Now we give the main theorem in this section as follows.

Theorem 3.3

Let G be a graph with the order \(n \ge 3\). Then,

$$\begin{aligned} 9\le \gamma _{\textrm{rdR}}(G)+\gamma _{\textrm{rdR}}(\overline{G})\le 3n. \end{aligned}$$

Proof

Let G be a graph with \(n\ge 3\). For the lower bound of the inequality, recall \(\gamma _{\textrm{rdR}}(G)\ge \gamma _{dR}(G)\) and Proposition 3.1, we get \(\gamma _{\textrm{rdR}}(G)+\gamma _{\textrm{rdR}}(\overline{G})\ge \gamma _{dR}(G)+\gamma _{dR}(\overline{G})\ge 8\). Now we want to prove that there is no graph satisfying \(\gamma _{\textrm{rdR}}(G)+\gamma _{\textrm{rdR}}(\overline{G})=8\). Suppose G is a graph satisfying \(\gamma _{\textrm{rdR}}(G)+\gamma _{\textrm{rdR}}(\overline{G})=8\). The result will be proved by considering the following two cases.

Case 1. \(\gamma _{\textrm{rdR}}(G)=3,\gamma _{\textrm{rdR}}(\overline{G})=5\).

Since \(\gamma _{\textrm{rdR}}(G)=3\) and Theorem 2.3 (i), we have \(\Delta (G)=n-1\) and \(\delta (G)\ge 2\). And thus, \(\Delta (\overline{G})\le n-3\) and \(\delta (\overline{G})=0\). This is to say, there is an isolated vertex in \(\overline{G}\), say v. Set \(\overline{G}_1=\overline{G}-\{v\}\). Then, \(\Delta (\overline{G}_1) \le n(\overline{G}_1)-2\). By using Theorem 2.3, \(\gamma _{\textrm{rdR}}(\overline{G}_1)>3\). So \(\gamma _{\textrm{rdR}}(\overline{G})=\gamma _{\textrm{rdR}}(\overline{G}_1)+\gamma _{\textrm{rdR}}(\overline{G}[v]) > 5\), a contradiction.

Case 2. \(\gamma _{\textrm{rdR}}(G)=\gamma _{\textrm{rdR}}(\overline{G})=4\).

As stated in Theorem 2.4 (iv), if G is disconnected and \(\gamma _{\textrm{rdR}}(G)=4\), then \(G=\overline{K_2}\), a contradiction. Now we complete this proof by the following subcases, since \(\gamma _{\textrm{rdR}}(G)=4\) and Theorem 2.4. If G is a graph described in Theorem 2.4 (i), then \(\Delta (G)=n-1\) and thus, \(\overline{G}\) is disconnected (note that, there is no disconnected graph with \(n\ge 3\) satisfying \(\gamma _{\textrm{rdR}}(G)=4\)), a contradiction. If G is a graph described in Theorem 2.4 (ii), then \(\Delta (G)=n-2\) and \(\delta (G)\ge 3\). It follows that \(\Delta (\overline{G})\le n-4\) and \(\delta (\overline{G})\ge 1\). It is easy to check that \(\overline{G}\) is not a graph described in any case of Theorem 2.4. Thus, \(\gamma _{\textrm{rdR}}(\overline{G})\ne 4\), a contradiction. Finally, \(G=P_3\), and then, \(\gamma _{\textrm{rdR}}(P_3)+\gamma _{\textrm{rdR}}(\overline{P_3})=9\), a contradiction.

Combining the above analysis, we know that \(\gamma _{\textrm{rdR}}(G)+\gamma _{\textrm{rdR}}(\overline{G})\ge 9\).

For the upper bound, we can get the following inequality by Proposition 3.2.

$$\begin{aligned} \gamma _{\textrm{rdR}}(G)+\gamma _{\textrm{rdR}}(\overline{G})&\le (2n-\Delta (G))+(2n-\Delta (\overline{G}))\\&=4n-(\Delta (G)+\Delta (\overline{G}))\\&=4n-(\Delta (G)+(n-\delta (G)-1))\\&=3n-(\Delta (G)-\delta (G))+1. \end{aligned}$$

In above inequality, if G is a irregular graph, note that, \(\Delta (G)>\delta (G)\), then we have \(\gamma _{\textrm{rdR}}(G)+\gamma _{\textrm{rdR}}(\overline{G})\le 3 n\). If G is a regular graph, then \(\gamma _{\textrm{rdR}}(G)+\gamma _{\textrm{rdR}}(\overline{G})\le 3n+1\). Now we want to prove that there is no regular graph attaining this upper bound.

Suppose G is d-regular satisfying \(\gamma _{\textrm{rdR}}(G)+\gamma _{\textrm{rdR}}(\overline{G})=3n+1\). By symmetry, we can assume that \(d\le (n-1)/2\). Since Proposition 3.2 and equality holds, we get that \(\gamma _{\textrm{rdR}}(G)=2n-d\) and \(\gamma _{\textrm{rdR}}(G)=n+d+1\).

Take any vertex \(v\in V(G)\). Let \(G_1=G[V(G)\setminus N[v]]\). If there exists a vertex u outside N[v] which has at least one neighbor outside N[v], then define a new RDRD-function as \((\emptyset ,N(v)\cup N_{G_1}(u),V(G)-N(v)-N_{G_1}(u),\emptyset )\), and further \(\gamma _{\textrm{rdR}}(G) \le 2n-d-1\), a contradiction. Thus, every vertex outside N[v] has all neighbors in N[v]. If there exists a vertex \(w \in N(v)\) which has at least two neighbors outside N[v], then we define a new RDRD-function as \((\emptyset ,(N(v)-\{w\})\cup N_{G_1}(w), V(G)-N_{G_1}(w)-(N(v)-\{w\}),\emptyset )\). It follows that \(\gamma _{\textrm{rdR}}(G) \le 2n-d-1\), this is a contradiction. Now we get that every vertex in N(v) has at most one neighbor outside N[v].

Counting the edges joining N[v] and \(V(G){\setminus } N[v]\) from both sides, we have \(d(n-d-1)\le d\). By simplification, \(n\le d+2\) for \(d\ne 0\). Note that, \(n\ge 2d+1\), we only need to consider two cases, \(d=1\) or \(d=0\). If \(d=1\), then \(n=3\), the graph is not exists. If \(d=0\), then \(G=\overline{K_n}\). We can get \(\gamma _{\textrm{rdR}}(\overline{K_n})+\gamma _{\textrm{rdR}}(K_n)=2n+3\). Note \(2n+3<3n+1\) always holds for \(n\ge 3\), this is a contradiction.

Combining the above analysis, there is no regular graph attaining this upper bound \(3n+1\). Thus, we have \(\gamma _{\textrm{rdR}}(G)+\gamma _{\textrm{rdR}}(\overline{G})\le 3n\) for regular graph G. \(\square \)

Note that, both the bounds in the above theorem are sharp. In fact, if G or \(\overline{G}\) is \(C_3\), \(P_3\), \(C_4\) or \(P_4\), then the upper bound is arrived; if G or \(\overline{G}\) is \(C_3\) or \(P_3\), the lower bound is arrived.

4 The RDRD-Number of a Cograph

In this section, we present a linear time algorithm to compute the RDRD-number of a connected cograph G, it is easily applied to all cographs, since the RDRD-number of a disconnected cograph equals the sum of RDRD-numbers of its connected components.

A cograph is exactly not containing the induced path of four vertices, and it is also called \(P_4\)-free graph. It can be defined recursively as follows:

  1. (i)

    Starting from a single vertex graph.

  2. (ii)

    Two cographs performing disjoint union and join are cographs.

  3. (iii)

    The complement of a cograph is a cograph. There have been many studies on cographs in recent years

[2, 3, 15]. A cograph has a property that each cograph corresponds to a unique tree representation, called a cotree [8]. We denote the cotree of a cograph G by \(T_G\). The leaves of \(T_G\) are the vertices of G and internal nodes of \(T_G\) are labeled join or union depending on the corresponding operation. The labels join and union appear alternately along every path starting from the root of \(T_G\). A cograph can be recognized and the corresponding cotree can be constructed in linear time [9]. Figure 1 illustrates a cograph G and its corresponding cotree \(T_G\).

Fig. 1
figure 1

The cograph G and the cotree \(T_G\)

Lemma 4.1

Let G be a connected cograph with \(G=G_1\vee G_2\), where \(G_i\) \((i\in \{1,2\})\) is a cograph with \(n(G_i)\ge 2\) and \(V(G_1)\cap V(G_2)=\emptyset \). Then,

  1. (i)

    \(\gamma _{\textrm{rdR}}(G)=3\) if and only if one of \(G_1\) and \(G_2\) contains a common vertex.

  2. (ii)

    \(\gamma _{\textrm{rdR}}(G)=4\) if and only if one of \(G_1\) and \(G_2\) is \(\overline{K_2}\), and there is no isolated vertex in the other graph with order \(n_0 \ge 4\) and maximum degree at most \(n_0 -2\).

  3. (iii)

    \(\gamma _{\textrm{rdR}}(G)=5\) if and only if one of the following conditions holds.

    1. (a)

      One of \(G_1\) and \(G_2\) contains two non-adjacent vertices xy, where \(d(x)\le n-3\), \(d(y)=n-2\), \(n(G_1)+n(G_2)\ge 5\) and \(\Delta (G_i)\le n(G_i)-2\) \((i\in \{1,2\})\).

    2. (b)

      One of \(G_1\) and \(G_2\) is \(\overline{K_2}\), and there is exactly one isolated vertex in the other graph, where \(n(G_1)+n(G_2)\ge 5\) and \(\Delta (G_i)\le n(G_i)-2\) \((i\in \{1,2\})\).

  4. (iv)

    \(\gamma _{\textrm{rdR}}(G)=6\) otherwise.

Proof

Let \(f=(V_0,V_1,V_2,V_3)\) be a \(\gamma _{\textrm{rdR}}\)-function of G. By the definition of RDRD-function of G, we have \(\gamma _{\textrm{rdR}}(G)=|V_1|+2|V_2|+3|V_3|\ge 3\). Since G is the join of \(G_1\) and \(G_2\), then every vertex in \(G_1\) is adjacent to every vertex in \(G_2\). Since \(n(G_i)\ge 2\), it implies that \(n(G)\ge 4\), \(\delta (G)\ge 2\) and there are no pendant edges in G.

  1. (i)

    If \(v\in G_1\)(or \(G_2\)) has a common vertex, then it is also a common vertex in G. By Theorem 2.3 (i), \(\gamma _{\textrm{rdR}}(G)=3\). Conversely, if \(\gamma _{\textrm{rdR}}(G)=3\), we only need to consider the graph described in Theorem 2.3 (i). Let v be the common vertex in G. Then v is also a common vertex in \(G_1\) (or \(G_2\)), say \(v\in G_1\). Since \(n(G_1)\ge 2\), then \(G[V(G)\setminus \{v\}]\) contains no isolated vertices. Now we define a RDRD-function as \((V(G){\setminus } \{v\},\emptyset ,\emptyset ,v)\). Thus, \(\gamma _{\textrm{rdR}}(G)=3\).

  2. (ii)

    If one of \(G_1\) and \(G_2\) is \(\overline{K_2}\), and there are no isolated vertices in the other graph, where \(n(G_1)+n(G_2)\ge 6\) and \(\Delta (G_i)=n-2\) \((i\in \{1,2\})\). By Theorem 2.4 (ii), then \(\gamma _{\textrm{rdR}}(G)=4\). Conversely, if \(\gamma _{\textrm{rdR}}(G)=4\), then only possibility that meets the conditions of cographs is the graphs described in Theorem 2.4 (ii). That is \(G=\overline{K_2} \vee G_0\) and \(G_0\) contains no isolated vertex. If \(G_0\) is a cograph, then the result holds. Suppose \(G_0\) is not a cograph, then there exists a induced path \(P_4=v_1v_2v_3v_4\) in \(G_0\). It is easy to check that \(P_4\) is still an induced path under the operation \(\vee \). It implies that \(P_4=v_1v_2v_3v_4\) is an induced path in G, a contradiction.

  3. (iii)

    If the conditions in Lemma 4.1 (iii) (a) are satisfied, without loss of generality, we assume that \(G_1\) contains two non-adjacent vertices xy, where \(d(x)\le n-3\), \(d(y)=n-2\), \(n(G_1)+n(G_2)\ge 5\) and \(\Delta (G_i)\le |V(G_i)|-2\) \((i\in \{1,2\})\). It implies that there exists at least one vertex in \(G_1\) besides x and y. Thus, \(G[V(G){\setminus }\{x,y\}]\) has no isolated vertices. By Theorem 2.5 (i), \(\gamma _{\textrm{rdR}}(G)=5\). If the conditions in Lemma 4.1 (iii) (b) are satisfied, without loss of generality, we assume that \(G_1\) is \(\overline{K_2}\), and there is exactly one isolated vertex v in \(G_2\), where \(n(G_1)+n(G_2)\ge 5\) and \(\Delta (G_i)\le |V(G_i)|-2\) \((i\in \{1,2\})\). It implies that the degree of vertices in \(G_1\) is \(n-2\), \(d(v)=1\) and v is isolated in \(G[V(G\setminus G_1)]\), further \(G[V(G\setminus G_1\cup \{v\})]\) has no isolated vertices. Thus, \(\gamma _{\textrm{rdR}}(G)=5\) by using Theorem 2.5 (iii). Conversely, if \(\gamma _{\textrm{rdR}}(G)=5\), then the possibilities that meet the conditions of cographs with \(n(G)\ge 4\) and \(\delta (G)\ge 2\) are (i) and (iii) of Theorem 2.5. That is \(|V(G_1)|+|V(G_2)|\ge 5\) and \(\Delta (G_i)\le |V(G_i)|-2\) \((i\in \{1,2\})\). Case 1. For the class of graphs in Theorem 2.5 (i), there are two non-adjacent vertices, say xy, with degree \(d(x)\le n-3\), \(d(y)=n-2\) in G. In this case, there are only two possible RDRD-functions for G as follows. If \(d(x) < n-3\), then \(f(x)=2,f(y)=3\), and the remaining vertices are assigned 0; if \(d(x)=n-3\), then \(f(x)=f(y)=2\), the only vertex adjacent to y but not adjacent to x is assigned 1, and the remaining vertices are 0. From the definition of the operation \(\vee \), we know that x and y are both in the same subgraph, say \(x,y\in G_1\), and whatever the possible assignments, there is always at least one vertex in \(G_1\) besides x and y. Thus, in this case, \(G[V(G)\setminus \{x,y\}]\) will not have isolated vertices. Combining the above analysis, the condition (iii) (a) holds. Case 2. For the class of graphs in Theorem 2.5 (iii), there are two non-adjacent vertices, say xy, with degree \(d(x)\in \{n-3,n-2\}\), \(d(y)=n-2\). If \(d(x)=n-3\), then we can get the class of cographs in Lemma 4.1 (iii) (a). If \(d(x)=n-2\), then x and y are both in the same subgraph, say \(x,y\in G_1\). Now we claim that there are no other vertices except xy in \(G_1\). Otherwise, if there exists another vertex v in \(G_1\), we define a new RDRD-function as \((V(G){\setminus } \{x,y\},\emptyset ,\{x,y\},\emptyset )\), and thus, \(\gamma _{\textrm{rdR}}(G) \le 4\), this is a contradiction. Thus, \(G_1\) is \(\overline{K_2}\). By Theorem 2.5 (iii), we can get that there is exactly one isolated vertex in the \(G_2\). Combining the above analysis, the condition (iii) (b) holds.

  4. (iv)

    For any connected cograph \(G =G_1 \vee G_2\). Let \(u\in V(G_1)\) and \(v\in V(G_2)\), it is easy to see \((V(G)-\{u,v\},\emptyset ,\emptyset ,\{u,v\})\) is an RDRD-function of G. Then, \(\gamma _{\textrm{rdR}}(G) \le 6\). And further if G is not any case (i)–(iii), then \(\gamma _{\textrm{rdR}}(G)=6\). This completes the proof. \(\square \)

Observation 4.2

For a connected cograph \(G=G_1\vee G_2\), where \(G_1\) has order 1, and let s to be the number of isolated vertices in \(G_2\). Then,

$$\begin{aligned}{ \gamma _{\textrm{rdR}}(G)=\left\{ \begin{array}{llll} s+2, &{}\quad if\ and\ only\ if s= n(G_2),\\ s+3, &{}\quad if\ and\ only\ if 0\le s\le n(G_2)-1. \end{array} \right. } \end{aligned}$$

Based on Lemma 4.1 and Observation 4.2, we give Algorithm 1 for computing the RDRD-number of a connected cograph G.

figure a

In the following, we present the correctness and complexity of Algorithm 1.

Theorem 4.3

The restrained double Roman domination number of cograph can be computed in linear time.

Proof

By Lemma 4.1 and Observation 4.2, the algorithm is correct. Now we analyze its time complexity. For a cograph G, it is a linear time to determine \(G_1\) and \(G_2\) in [9]. Since determining the degree of each vertex needs a linear time, then the number of isolated vertices can be determined in a linear time. Further, finding the vertex that meets the required degree condition is in a linear time. And it is also linear time to determine whether a graph is \(\overline{K_2}\). Hence, the time complexity to computing the RDRD-number of a cograph is linear. \(\square \)

In [16], the authors gave the characterizations of connected graphs with RDRD-number \(2n-1\). As an application of the above algorithm, we give the characterization of cographs with RDRD-number \(2n-2\).

Corollary 4.4

Let G be a cograph, then \(\gamma _{rdR}(G)=2n-2\) if and only if \(G\in \{P_3,2K_2,K_1\cup K_{1,2},C_4\}\).

Proof

If \(G\in \{P_3,2K_2,K_1\cup K_{1,2},C_4\}\), then it is easy to check \(\gamma _{\textrm{rdR}}(G)=2n-2\) by Algorithm 1. Conversely, if \(\gamma _{\textrm{rdR}}(G)=2n-2\), then \(2\le \gamma _{\textrm{rdR}}(G)=2n-2\le 6\) by the definition of RDRD-function and Lemma 4.1, that is \(2\le n(G)\le 4\). Now we complete the proof as follows.

If \(n=2\), then \(\gamma _{\textrm{rdR}}(G)=2\). It is easy to check that there is no cograph satisfying the condition. If \(n=3\), then \(\gamma _{\textrm{rdR}}(G)=4\). Note that, there is no disconnected cograph G with \(\gamma _{\textrm{rdR}}(G)=4\). For connected cograph, we can get the only case satisfying the condition is \(K_1\vee \overline{K_2}\), that is \(G=P_3\) by Observation 4.2. If \(n=4\), then \(\gamma _{\textrm{rdR}}(G)=6\). Now we consider the components of G. If the number of components of G at least 3. By using Observation 4.2, we sum the RDRD-numbers of each connected component in G , and then we know that there is no cograph can meet \(\gamma _{rdR}=2n-2\). If G has two connected components, then the cographs meet the condition are \(K_1\cup K_{1,2}\) and \(2K_2\) by Observation 4.2. If G has one connected component, that is G is connected. Let \(G=G_1\vee G_2\). If one of \(G_1\) and \(G_2\) has order 1, say \(n(G_1)=1\). It follows \(n(G_2)=3\). Then, \(\gamma _{\textrm{rdR}}(G)\le n(G_2)+2=5\) by Observation 4.2. This is a contradiction. If \(n(G_i)=2\) \((i\in \{1,2\})\), then the \(d_{G_i}(v)=1\), otherwise \(\gamma _{\textrm{rdR}}(G)=3\) by Lemma 4.1. Thus, the connected cograph is \(\overline{K_2}\vee \overline{K_2}\), that is \(C_4\). \(\square \)