# Squares of Low Maximum Degree This paper received support from EPSRC (EP/G043434/1), ERC (267959) and ANR project AGAPE. The results of this paper appeared (with alternative proofs) as an extended abstract in the proceedings of WG 2013 [2].

## Abstract

A graph is a square root of a graph if can be obtained from by adding an edge between any two vertices in that are of distance 2. The Square Root problem is that of deciding whether a given graph admits a square root. This problem is only known to be NP-complete for chordal graphs and polynomial-time solvable for non-trivial minor-closed graph classes and a very limited number of other graph classes. We prove that Square Root is -time solvable for graphs of maximum degree 5 and -time solvable for graphs of maximum degree at most 6.

## 1Introduction

The *square* of a graph is the graph with vertex set , such that any two distinct vertices are adjacent in if and only if and are of distance at most 2 in . In this paper we study the reverse concept: a graph is a *square root* of a graph if . There exist graphs with no square root (such as graphs with a cut-vertex), graphs with a unique square root (such as squares of cycles of length at least 7) as well as graphs with more than one square root (such as complete graphs).

In 1967 Mukhopadhyay [21] characterised the class of connected graphs with a square root. However, in 1994, Motwani and Sudan [20] showed that the decision problem Square Root, which asks whether a given graph admits a square root, is NP-complete. As such, it is natural to restrict the input to special graph classes in order to obtain polynomial-time results. For several well-known graph classes the complexity of Square Root is still unknown. For example, Milanic and Schaudt [19] posed the complexity of Square Root restricted to split graphs and cographs as open problems. In Table 1 we survey the known results.

The last two rows in Table 1 correspond to the results in this paper. More specifically, we prove in Section 3 that Square Root is linear-time solvable for graphs of maximum degree at most 5 via a reduction to graphs of bounded treewidth and in Section 4 that Square Root is -time solvable for graphs of maximum degree at most 6 via a reduction to graphs of bounded size.

graph class | complexity |
---|---|

planar graphs | linear |

non-trivial and minor-closed | linear |

-free graphs | linear |

-free graphs | linear |

-degenerate graphs | linear |

graphs of maximum degree | linear |

graphs of maximum degree | polynomial |

graphs of maximum average degree | polynomial |

line graphs | polynomial |

trivially perfect graphs | polynomial |

threshold graphs | polynomial |

chordal graphs | NP-complete |

Also the -Square Root problem, which is that of testing whether a given graph has a square root that belongs to some specified graph class , has also been well studied. We refer to Table 2 for a survey of the known results on -Square Root.

graph class | complexity |
---|---|

trees | polynomial |

proper interval graphs | polynomial |

bipartite graphs | polynomial |

block graphs | polynomial |

strongly chordal split graphs | polynomial |

ptolemaic graphs | polynomial |

3-sun-free split graphs | polynomial |

cactus graphs | polynomial |

graphs with girth at least for any fixed | polynomial |

graphs of girth at least 5 | NP-complete |

graphs of girth at least 4 | NP-complete |

split graphs | NP-complete |

chordal graphs | NP-complete |

Finally both Square Root and -Square Root have been studied under the framework of parameterized complexity. The generalization of Square Root that takes as input a graph with two subsets and of edges that need to be included or excluded, respectively, in any solution (square root)^{1}

## 2Preliminaries

We only consider finite undirected graphs without loops or multiple edges. We refer to the textbook by Diestel [5] for any undefined graph terminology.

Let be a graph. We denote the vertex set of by and the edge set by . The *length* of a path or a cycle is the number of edges of the path or cycle, respectively. The *distance* between a pair of vertices and of is the number of edges of a shortest path between them. The diameter of is the maximum distance between two vertices of . The *neighbourhood* of a vertex is defined as . The *degree* of a vertex is defined as . The *maximum degree* of is . A vertex of degree 1 and the (unique) edge incident to it are said to be a *pendant* vertex and *pendant* edge of respectively. A vertex subset of that consists of mutually adjacent vertices is called a *clique*.

A *tree decomposition* of a graph is a pair where is a tree and is a collection of subsets (called *bags*) of such that the following three conditions hold:

,

for each edge , for some , and

for each the set induces a connected subtree of .

The *width* of a tree decomposition is . The *treewidth* of a graph is the minimum width over all tree decompositions of . If restricted to be a path, then we say that is a *path decomposition* of a graph . The *pathwidth* of is the minimum width over all path decompositions of . A class of graphs has *bounded* treewidth (pathwidth) if there exists a constant such that the treewidth (pathwidth) of every graph from is at most .

## 3Graphs of Maximum Degree at Most 5

In this section we prove that Square Root can be solved in linear time for graphs of maximum degree at most 5 by showing that squares of maximum degree at most 5 have bounded pathwidth. The latter enables us to use the following two lemmas. The first lemma can either be proven via a dynamic programming algorithm or by a non-constructive proof based on Courcelle’s theorem [4] (see [9] for details). The second lemma is due to Bodlaender.

We now prove the key result of this section.

Without loss of generality we assume that is connected; otherwise, we can consider the components of separately. Let be a square root of . Let . In we apply a breadth-first search (BFS) starting at . This yields the levels for some , where for . Note that and that is a partition of . Let be the corresponding BFS-tree of rooted in . Note that also defines a parent-child relation on the vertices of .

We prove the following two claims.

We prove Claim A as follows. First we show i) by observing that if had at least four children in , then contains the subgraph shown in Fig. ? a) and, therefore, , which is a contradiction.

We now prove ii). First assume that has exactly one descendant . Then has at most three children in due to i), and hence the total number of descendants of in is at most 4. Now assume that has at least two descendants in , say and . Let denote the lowest common ancestor of in . Note that is a descendant of or , so for some . Suppose . Then contains the subgraph shown in Fig. ? b) and hence , a contradiction. Hence, and, moreover, we may assume without loss of generality that is the parent in of all the descendants of in (as otherwise there exists a vertex with a neighbour , which means that the lowest common ancestor of and has six neighbours in ).

By i), we find that has at most three children. Hence, has at most three descendants in . To obtain a contradiction, assume that has at least two descendants in . If have distinct parents we again find that contains the forbidden subgraph shown in Fig. ? b). If have the same parent, contains the subgraph shown in Fig. ? c) and hence , a contradiction. Hence, has at most one descendant in . We conclude that the total number of descendants of in is at most 4. This completes the proof of ii). Consequently we have proven Claim A.

We prove Claim B as follows. Let be the path on vertices (in the order of the path). We set for all and define . We claim that is a path decomposition of . This can be seen as follows. Since the sets form a partition of , we find that . Moreover, for every edge with and we see that . Hence, for each edge , for some . Finally, if such that , then and . Therefore, the set induces a subpath of for each . It remains to observe that the width of is . This completes the proof of Claim B.

Because , and thus and . By Claim A, each vertex of has at most three children in and at most four descendants in . Hence, and . For , each vertex of has at most four descendants in and also at most four descendants in by Claim A ii). Therefore, each vertex of has at most seven descendants in . As , this means that . We conclude that for all . Consequently, Claim B implies that .

We are now ready to prove the main theorem of this section.

Let be a graph with . By Lemma ? we can check in time whether . If , then has no square root by Lemma ?. Otherwise, we solve Square Root in time by using Lemma ?.

The above approach cannot be extended to graphs of maximum degree at most 6. In order to see this, take a wall (see Figure 3) and subdivide each edge, that is, replace each edge by a path where is a new vertex. This gives us a graph , such that has degree at most 6. A wall of height has treewidth (see, for example, [5]). As subdividing an edge and adding edges does not decrease the treewidth of a graph, this means that the graph can have an arbitrarily large treewidth.

## 4Graphs of Maximum Degree at Most 6

In this section we show that the Square Root problem can be solved in time for -vertex graphs of maximum degree at most 6. In order to do this we need to consider the aforementioned generalization of Square Roots, which is defined as follows.

- Square Root with Labels
- Input:
a graph and two sets of edges .

- Question:
is there a graph with , and ?

Note that Square Root is indeed a special case of Square Root with Labels: choose .

The main idea behind our proof is to reduce to graphs with a bounded number of vertices by using the reduction rule that we recently introduced in [9] (the proof in [2] used a different and less general reduction rule, namely, the so-called path reduction rule, which only ensured boundedness of treewidth). In order to explain our new reduction we need the following definition. An edge of a graph is said to be *recognizable* if has a partition , where and , for some , such that the following conditions are satisfied:

and are disjoint cliques in ;

for and ;

for any , for ;

for any , for ;

for any , there is an such that ;

for any , there is a such that .

This leads to an algorithmic and a structural lemma, which we both need.

We are now ready to prove the aforementioned structural result. Its proof relies on Lemma ?.

Let be a connected graph with that has no recognizable edges. Assume that has a square root . We select a vertex for which there exists a vertex , such that . We apply a breadth-first search on starting at to obtain levels , where for . Note that and that is a partition of . We say that a vertex is a *child* of a vertex , and that is a *parent* of if , and for some . It is worth mentioning that this parent-child relation differs from the relation defined by the corresponding BFS-tree. In particular, a vertex may have several parents. We also say that a vertex is a *grandchild* of a vertex and that is a *grandparent* of if there is a vertex such that is a parent of and is a parent of . A vertex is a *descendant* of a vertex if , for some , with and there is an -path of length .

We now prove a sequence of claims.

We prove Claim A as follows. For contradiction, assume there exists a vertex for some that has two distinct children such that and have distinct children respectively, as shown in Fig. ?. Notice that possibly ( respectively) is a child of ( respectively) as well. As , has a parent , and has a parent . By Lemma ?, is contained in a cycle of of length at most 6. If is adjacent to a vertex in , then and hence . Consequently ; a contradiction. Therefore, and thus . If has a neighbour in , then , because and hence is distinct from . This is again a contradiction. Therefore contains one of , , say contains . Hence for some and ; see also Fig. ?. However, then is adjacent to in . Hence , a contradiction. This completes the proof of Claim A.

We prove Claim B as follows. Note that for all , every vertex has at least two neighbours in that belong to . Hence the fact that implies that has at most four neighbours in belonging to . In other words, the total number of children and grandchildren of is at most four.

We use induction on . Let or , As the total number of children and grandchildren of is at most four, the claim holds. Let . Recall that has at most four children. Hence the claim holds for . Let . If has no grandchildren the claim holds. Now suppose that has exactly one grandchild . If , then the number of descendants of in is one. If , then by the induction hypothesis the number of descendants of in is at most four, since these vertices are descendants of as well. Finally suppose that has at least two grandchildren. Then, by Claim A, there is a unique child of that is the parent of all grandchildren of , and no other child of has children. By the induction hypothesis, the number of descendants of in is at most four. As all descendants of in are descendants of , the claim holds. This completes the proof of Claim B.

Recall that is a vertex that is of distance of .

We prove Claim C as follows. To obtain a contradiction, we assume that has another child for some , so . Since has no recognizable edge, Lemma ? tells us that in every non-pendant edge is contained in a cycle of length at most .

Let us first assume that there is no cycle of length at most 6 in that contains both and ; this case will be studied later. Let and be two cycles in of length at most 6 that contain and , respectively. As and , has an edge and has an edge for some . Note that and both belong to . If , then in we see that is adjacent to , , , , , and . Hence contradicting . It follows that .

Let be an edge of and let be an edge of , such that . If or does not belong to , then , a contradiction. Hence, Recall that there is no cycle of length at most 6 that contains both and . This implies that (in remove in the first case and replace by in the latter two cases) and (in replace by in the first case and remove in the second case). As both and are adjacent to , this implies that , and . However, this means that is a cycle of length in that contains both and , a contradiction. Consequently, we may assume that there is a cycle in of length at most that contains both and . Since , we need to distinguish three cases.

. .

Then has an edge for some such that (see Fig. ?). Then, has an edge for some . However, then we obtain , a contradiction.

.

Then has an edge for some such that (see Fig. ?). Similarly to Case 1, has an edge for some . Note that as has length at most 6. Hence, (note that this is not in contradiction with Claim A as may hold).

If , then , a contradiction. If , then . If , then . If or , then . Hence, .

The edge is non-pendant and thus included in a cycle of length at most 6 by Lemma ?. Assume that is a shortest cycle of this type. Let be the other edge in incident with . We distinguish three subcases.

.

If , then , a contradiction. Hence, . Then, has an edge for some . As is a shortest cycle with , we find that (as otherwise the cycle obtained from after removing would be shorter) . Recall that . Hence . If , this means that , a contradiction. Therefore, . Let be the next vertex of , so . As has length at most 6, , so . Recall that and are not in , thus either. As , . Hence, , a contradiction.

and for some .

Recall that and are not in . Hence either. If , this means that . Hence, , that is, . Let be the next vertex of , so . Recall that . If , this means that . It follows that , that is, . Let be the next vertex of , so . As has length at most 6, we find that . As has length at most 6, we find that and thus (see Fig. ?).

If has a neighbour in distinct from , then , a contradiction. Hence, . If has a neighbour in distinct from and , then that neighbour cannot be in , as is a shortest cycle containing . Consequently, we find that , a contradiction. Hence, . Recall that . Moreover, as is a shortest cycle containing , we find that . Consequently, if has a neighbour in distinct from , then , a contradiction. Hence, . As is a shortest cycle containing , we find that . Consequently, if has a neighbour in distinct from , then , a contradiction. Hence, . If has a neighbour distinct from , then , a contradiction. Hence, . If has a neighbour distinct from , then , a contradiction. Hence, .

Now consider the (non-pendant) edge , which must be in a cycle of length at most 6 due to Lemma ?. As and , we find that contains no vertex of . Now, by traversing starting at in opposite direction from , we find that contains the cycle . Hence . which means that is not a cycle, a contradiction.

and

Let be the next vertex of , so . As has length at most 6, we find that . Recall that . Then we find that , a contradiction.

.

Then has an edge for some (see Fig. ?). Let be the next vertex of , so . As has length at most 6, we find that . Hence, if , then , a contradiction. This means that , and consequently and .

Again let be a shortest cycle amongst all cycles that contains . Recall that the length of is at most 6 by Lemma ?. Let be the other edge in incident with . As in Case 2, we distinguish three subcases.

.

If , then . Hence, , that is, . Let be the next vertex of , so . As is a shortest cycle containing , we find that (otherwise remove from to obtain a shorter cycle). As due to Claim A, we find that . Since and , we find that either. Then holds, a contradiction.

and for some .

If , then . First suppose , so . Let be the next vertex of , so . As and has length at most 6, we find that . However, then , a contradiction. Now suppose, , so . Let be the next vertex of , so . Recall that due to Claim A. Then holds, a contradiction.

and

As has length at most 6, we find that . Then , a contradiction.

We considered all possibilities, and in each case we obtained a contradiction. Hence we have proven Claim C.

To prove Claim D, it suffices to run a breadth-first search in from , to consider the resulting levels , where where for , and to apply Claim C.

We are now ready to complete the proof. We do this by first showing that . To obtain a contradiction, assume that . By Lemma ?, has a cycle of length at most 6 that contains . As is the unique child of by Claim C and is the unique parent of by Claim D, we find that has an edge , where , , such that contains an path of length at most 3 with .

Suppose that . Then has a parent . By Claim C, . Therefore, , a contradiction. Hence . Suppose that . Then has edges such that . Again, has a parent and due to Claim C. It follows that ; a contradiction. Hence, has a vertex of .

As contains a vertex of , has length at least 2. If has length 2, then . However, this is a contradiction, as is the unique child of by Claim C. Hence, has length 3, which implies that for some or for some and .

First suppose that for some . Let be a parent of . As is the unique child of by Claim C, we find that . Then , a contradiction. Now suppose that for some and . Note that , as is the unique child of by Claim . As has length at most 6, we find that . This means that in , is adjacent to , so , a contradiction. We conclude that .

As , we find that . Since , . As , this means that . If , then for some and each vertex of is a child of . As , this means that , so . Suppose . By Claim B, for . Because , .

We are now ready to prove our main result. Its proof uses Lemmas ? and ?.

Let be a graph of maximum degree at most 6. We construct an instance of Square Root with Labels from by setting . Then we preprocess using Lemma ?. In this way we either solve the problem (and answer `no`

) or obtain an equivalent instance of Square Root with Labels that has no recognizable edges. In the latter case we know from Lemma ? that if has a square root, then each component of has at most 103 vertices. Hence, if has a component with at least 100 vertices, then we stop and return `no`

. Otherwise, we solve the problem for each component of in constant time by brute force. Applying Lemma ? takes time , as . The remainder of our algorithm takes constant time. Hence, its total running time is .

We cannot extend this approach for graphs of maximum degree at most 7. In particular, the following example shows that we cannot obtain an analog of Lemma ? for graphs of maximum degree at most 7. Let be the graph obtained from two paths and by adding the edge for . Notice that has no recognizable edges while . However, its size can be arbitrarily large.

## 5Conclusion

We showed that Square Root can be solved in polynomial time for graphs of maximum degree at most 6. We pose two open problems. First, can we solve Square Root in polynomial time on graphs of maximum degree at most 7; this will require new techniques. Second, does there exist an integer such that Square Root is NP-complete for graphs of maximum degree at most ?

### Footnotes

- We give a formal definition of this generalization in Section 4, as we need it for proving that Square Root is -time solvable for graphs of maximum degree at most 6.

### References

**A linear-time algorithm for finding tree-decompositions of small treewidth.**

Hans L. Bodlaender.*SIAM Journal on Computing*, 25:305–1317, 1996.**Sparse square roots.**

Manfred Cochefert, Jean-François Couturier, Petr A. Golovach, Dieter Kratsch, and Daniël Paulusma. In*Graph-Theoretic Concepts in Computer Science - 39th International Workshop, WG 2013*, volume 8165 of*Lecture Notes in Computer Science*, pages 177–188. Springer, 2013.**Parameterized algorithms for finding square roots.**

Manfred Cochefert, Jean-François Couturier, Petr A. Golovach, Dieter Kratsch, and Daniël Paulusma.*Algorithmica*, 74:602–629, 2016.**The monadic second-order logic of graphs III: tree-decompositions, minor and complexity issues.**

Bruno Courcelle.*ITA*, 26:257–286, 1992.*Graph Theory, 4th Edition*, volume 173 of*Graduate Texts in Mathematics*.

Reinhard Diestel. Springer, 2012.**Square-root finding problem in graphs, a complete dichotomy theorem.**

Babak Farzad and Majid Karimi.*CoRR*, abs/1210.7684, 2012.**Complexity of finding graph roots with girth conditions.**

Babak Farzad, Lap Chi Lau, Van Bang Le, and Nguyen Ngoc Tuy.*Algorithmica*, 62:38–53, 2012.**Finding cactus roots in polynomial time.**

Petr A. Golovach, Dieter Kratsch, Daniël Paulusma, and Anthony Stewart. In*Proceedings of the 27th International Workshop on Combinatorial Algorithms (IWOCA 2016)*, Lecture Notes in Computer Science, to appear, 2016.**A linear kernel for finding square roots of almost planar graphs.**

Petr A. Golovach, Dieter Kratsch, Daniël Paulusma, and Anthony Stewart. In*Proceedings of the 15th Scandinavian Symposium and Workshops on Algorithm Theory (SWAT 2016)*, Leibniz International Proceedings in Informatics, to appear, 2016.**Squares of low clique number.**

Petr A. Golovach, Dieter Kratsch, Daniël Paulusma, and Anthony Stewart. In*14th Cologne Twente Workshop 2016 (CTW 2016)*, Electronic Notes in Discrete Mathematics, to appear, 2016.**Bipartite roots of graphs.**

Lap Chi Lau.*ACM Transactions on Algorithms*, 2:178–208, 2006.**Recognizing powers of proper interval, split, and chordal graphs.**

Lap Chi Lau and Derek G. Corneil.*SIAM Journal on Discrete Mathematics*, 18:83–102, 2004.**Polynomial time recognition of squares of ptolemaic graphs and 3-sun-free split graphs.**

Van Bang Le, Andrea Oversberg, and Oliver Schaudt.*Theoretical Computer Science*, 602:39–49, 2015.**A unified approach for recognizing squares of split graphs.**

Van Bang Le, Andrea Oversberg, and Oliver Schaudt.*Manuscript*, 2015.**The square of a block graph.**

Van Bang Le and Nguyen Ngoc Tuy.*Discrete Mathematics*, 310:734–741, 2010.**A good characterization of squares of strongly chordal split graphs.**

Van Bang Le and Nguyen Ngoc Tuy.*Information Processing Letters*, 111:120–123, 2011.**Algorithms for square roots of graphs.**

Yaw-Ling Lin and Steven Skiena.*SIAM Journal on Discrete Mathematics*, 8:99–118, 1995.**A characterization of line graphs that are squares of graphs.**

Martin Milanic, Andrea Oversberg, and Oliver Schaudt.*Discrete Applied Mathematics*, 173:83–91, 2014.**Computing square roots of trivially perfect and threshold graphs.**

Martin Milanic and Oliver Schaudt.*Discrete Applied Mathematics*, 161:1538–1545, 2013.**Computing roots of graphs is hard.**

Rajeev Motwani and Madhu Sudan.*Discrete Applied Mathematics*, 54:81–88, 1994.**The square root of a graph.**

A. Mukhopadhyay.*Journal of Combinatorial Theory*, 2:290–295, 1967.**Square roots of minor closed graph classes.**

Nestor V. Nestoridis and Dimitrios M. Thilikos.*Discrete Applied Mathematics*, 168:34–39, 2014.