Let $G$ be a graph on $n$ vertices, $A = AG$ its adjacency matrix, and $I_n$ the $n \times n$ identity matrix. Prove that $G$ is connected if and only if the matrix $(I_n + A)^{n−1}$ has no $0$'s.
For the if part- as $G$ is connected there is a path between any two vertices, the maximum size of the path can be $n$ as there are $n$ vertices because of this observation there is always a path from any $u$ to any $v$ of length $n-1$. Thus $(I_n+A)^{n-1}$ is non zero. (But I am not convinced with the idea).
For the only if part I am not getting any convincing idea either.
Thank you.
For vertices $u,v$ in $G$, and an integer $k \geqslant 0$, the $(u,v)$-th entry of $A^k$ is the number of walks of length $k$ from $u$ to $v$ in $G$. If we denote this number by $W_k(u,v)$, then the $(u,v)$-th entry of $(I_n+A)^{n-1}$ is equal to $$\sum_{k=0}^{n-1}\binom{n-1}{k}W_k(u,v).$$ This is nonzero if and only if $W_k(u,v)$ is nonzero for some $0 \leqslant k \leqslant n-1$.