# What does the formula of an Adjacency matrix of an undirected graph trasposed matrix equal?

Let $A\in\mathbb{R}^{n\times n}$ be the adjacency matrix of an undirected network with n nodes and let 1 $\in R^n$ be a column vector whose elements are all 1. What does the formula $1^T \cdot A \cdot 1$ equal?

Two times the number of edges of a graph or The square of the number of nodes of a graph?

and why?

• Shouldn't it be $A\in\mathbb{R}^{n\times n}$ and $1^T \cdot A \cdot 1$? Commented Apr 7, 2016 at 19:52
• Have you played around with some toy examples, like $3\times 3$ or $4\times 4$? Commented Apr 8, 2016 at 8:16
$1^T \cdot A \cdot 1$ is the sum of all the entries in the matrix $A$. These entries are, in position $ij$, 1 if there is an edge from vertex $i$ to vertex $j$, and 0 otherwise. (Or, in a multigraph, the number of edges from vertex $i$ to vertex $j$.) Since your graph is undirected, each edge shows up twice: once in position $ij$ and once in position $ji$ (except for any loops, which just show up in position $ii$.)
(With loops, it is still true, if you adopt an appropriate convention, e.g. put a 1 in entry $ii$ and count loops as half an edge, or else put a 2 in entry $ii$ (because the loop is incident to vertex $i$ twice.))