Ask Your Question
1

degree versus in_degree

asked 2019-09-12 20:01:24 +0100

djp gravatar image

updated 2019-09-13 15:13:53 +0100

tmonteil gravatar image

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=[0],labels=True)
{0: 628}
sage: T.degree(vertices=[0],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 flag offensive close merge delete

Comments

1

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

tmonteil gravatar imagetmonteil ( 2019-09-12 22:06:53 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-09-13 22:58:55 +0100

dan_fulea gravatar image

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?!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2019-09-12 20:01:24 +0100

Seen: 581 times

Last updated: Sep 13 '19