Let $G$ be an undirected graph with $n$ nodes and let $a_k$ denote the number of directed paths of length $k$.
Prove that $$a_1 \leq \sqrt{n a_2}.$$ Note that $a \to b \to a$, where $a$ and $b$ are adjacent nodes in $G$, is considered a path of length $2$. Also, it is easy to see that $a_1 \leq a_2.$
Let $A$ denote the adjacency matrix of $G$. I know that the sum of elements of $A$ is $a_1$ and that $a_2$ is the sum of elements of $A^2$. I tried to use that but couldn't get anywhere.
$a_1 = \sum_{v} \deg(v)$ and $a_2 = \sum_v \deg(v)^2$, where the latter is obtained by letting $v$ be the "middle vertex" of the length-2 path we're constructing.
With that in mind, the inequality you're asking for is exactly the Cauchy-Schwarz inequality $|\langle \mathbf{a}, \mathbf{b} \rangle | \le \|\mathbf{a}\| \|\mathbf{b}\|$ where $\mathbf{a} \in \mathbb{R}^n$ is the list of vertex degrees and $\mathbf{b} \in \mathbb{R}^n$ is a vector of all $1$s.