# Two ways of calculating the degree sequence

So I'm trying to calculate the degree sequence of G, an undirected, connected
simple graph. As far as I see it, there are two ways to do this. Iterate
over all the vertices, or sum the rows of the adjacency matrix. So:

def degree_sequence1(G):
degs = []
for v in G.vertices():
degs.append(v.out_degree() + v.in_degree())
degs.sort()

return degs

def degree_sequence2(G):
degs = np.squeeze(np.asarray(mat.sum(axis=0)))
degs.sort()

return degs

The first way definitely works. But when I try to use the second method, I
find that even if I run this code on a connected network I get zeroes in my
degree sequence. Which shouldn't be possible if the graph is connected. So I
know that I'm understanding something wrong here.

Can somebody point out where I went wrong here?

Thanks!

I tried the second function with a connected graph, and I did not see any
zeros. Maybe it would help if you would provide a small but _complete_
example that shows the problem.

Best,
Tiago