On 13.02.2017 00:10, gogurt wrote: > 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): > mat = gt.adjacency(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?
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 -- Tiago de Paula Peixoto <[email protected]>
signature.asc
Description: OpenPGP digital signature
_______________________________________________ graph-tool mailing list [email protected] https://lists.skewed.de/mailman/listinfo/graph-tool
