Each edge for (u,v) , it is counted once for u and once for v in the sum. Therefore the sum is twice the number of edges.
If G is undirected m <= n(n-1)/2 If G is directed m <= n(n-1)