# degree versus in_degree

I have a problem when calling degree and in_degree on directed graph I loaded. In particular, I had thought, for a particular node, that degree = in + out degree but am getting a situation where in_degree > degree for a given node. Here is the output for a graph I loaded:

sage: T.in_degree(vertices=,labels=True)
{0: 628}
sage: T.degree(vertices=,labels=True)
{0: 394}


This is also the case for other nodes in the graph.

Any idea what's going on here?

thanks! --David

edit retag close merge delete

1

There might be a bug, could you please provide the code for T so that we can inspect further ?

Sort by » oldest newest most voted

This is an answer, because it could not be inserted as a comment. The following code starts the check in a special case of a directed graph given by the divisibility relation on the integers from $1$ to $120$:

sage: g = DiGraph([[1..120], lambda i,j: i != j and i.divides(j)])
sage: checklist = []
sage: for v in g.vertices():
....:     in_v  = g. in_degree(vertices=[v], labels=True)[v]
....:     out_v = g.out_degree(vertices=[v], labels=True)[v]
....:     deg_v = g.    degree(vertices=[v], labels=True)[v]
....:     checklist.append( in_v + out_v == deg_v )
....:
sage: False in checklist
False
sage: checklist == 120*[True]
True


So the checklist contains only the True value. This is ok. Which is the result for the graph T from the OP? Which is the method used to construct it? Is there a minimal example reproducing the same error / incompatibility?!

more