I am interested in the following problem: Given an $n\times n$ matrix, is there an undirected graph on $n$ vertices whose adjacency matrix squared is that matrix?

Is the computational complexity of this problem known?


  • Of course this can also be phrased as a search problem, where you are given the matrix $A^2$ for $A$ an adjacency matrix of an undirected graph and the problem is to find any adjacency matrix (of an undirected graph) $B$ such that $B^2 = A^2$.

  • Motwani and Sudan (Computing roots of graphs is hard, 1994) and Kutz (The complexity of Boolean matrix root computation, 2004) show similar but distinct problems from this one are NP-hard - they consider only the square of adjacency matrices under Boolean matrix multiplication.

  • $\begingroup$ The problem is equivalent to deciding the existence of $n$ vectors with given pairwise inner products. $\endgroup$ Commented Apr 6, 2015 at 17:02
  • 2
    $\begingroup$ Very recently there was a paper addressing this question for stochastic matrices rather than adjacency matrices (arxiv.org/abs/1411.7380). The property of being a square in this context is known as divisibility and is shown to be NP-complete in the paper I mentioned. $\endgroup$ Commented Apr 6, 2015 at 19:24
  • 2
    $\begingroup$ @MohammadAl-Turkistany how are they equivalent? The solution to OP's problem requires additional structure than generic vectors (integer valued, certain indices must be zero, etc). $\endgroup$
    – Jeremy Kun
    Commented Apr 6, 2015 at 22:02
  • $\begingroup$ This ought to be related to checking if a degree sequence is graphic. Notice that in $A^2$ the diagonal represents the degree sequence and $(A^2)_{ij}$ the number of common neighbours of vertices $i,j$. Thus it is a restriction to the graphic degree sequence problem. No idea how to solve it though. $\endgroup$
    – SamiD
    Commented Apr 28, 2015 at 20:52

2 Answers 2


It is known that squares of bipartite graphs can be recognized in polynomial time ( See this). In general, there is a characterization of the complexity of this problem based on the girth of the underlying graph.

Recently there was a optimization variant studied, which gives FPT algorithms for the problem when you want to test whether a graph has a square root with at most (respectively at least) $s$ edges for some given integer $s$.

  • 7
    $\begingroup$ Thanks for the response, but the results you mention are not relevant to this problem - they assume, as in the paper of Motwani and Sudan, that the given matrix is an adjacency matrix and the goal is to find another graph whose adjacency matrix squared under Boolean matrix multiplication is the given matrix. Whereas in this problem it is not Boolean, but integer matrix multiplication. In other words, this problem is not about the square root of a graph as they use the term. $\endgroup$
    – Ben Fish
    Commented Apr 4, 2015 at 18:56
  • $\begingroup$ @BenFish Oops. Misunderstood your question. For Integer matrices, I don't see any better way than just approximating the square root of the matrix, though I presume you are interested in computing this as the square root of a weighted graph (and I have no idea how to do that) $\endgroup$
    – Nikhil
    Commented Apr 5, 2015 at 5:56
  • $\begingroup$ @Nikhil the square root of a matrix is not unique, so doing this doesn't solve the question $\endgroup$
    – Lev Reyzin
    Commented Apr 5, 2015 at 20:22
  • $\begingroup$ @LevReyzin You are correct. In general, I think the uniqueness can be characterized from the spectrum of the matrix (maybe they don't provide a necessary and sufficient condition). There are some interesting results known for stochastic matrices -- See eprints.ma.man.ac.uk/1241/01/covered/MIMS_ep2009_21.pdf $\endgroup$
    – Nikhil
    Commented Apr 6, 2015 at 6:37

If the underlying graph is a sparse, random graph, one can solve the "graph square root" problem in polynomial time; this is also true for weighted graphs. Examples of papers that use this idea are Finding Overlapping Communities in Social Networks and Provable Bounds for Learning Some Deep Representations. Any idea about similar algorithms for graph cube roots, fourth roots etc.?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.