ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 13 Sep 2019 22:58:55 +0200degree versus in_degreehttps://ask.sagemath.org/question/47853/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=[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!
--DavidThu, 12 Sep 2019 20:01:24 +0200https://ask.sagemath.org/question/47853/degree-versus-in_degree/Comment by tmonteil for <p>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:</p>
<pre><code>sage: T.in_degree(vertices=[0],labels=True)
{0: 628}
sage: T.degree(vertices=[0],labels=True)
{0: 394}
</code></pre>
<p>This is also the case for other nodes in the graph.</p>
<p>Any idea what's going on here?</p>
<p>thanks!
--David</p>
https://ask.sagemath.org/question/47853/degree-versus-in_degree/?comment=47863#post-id-47863There might be a bug, could you please provide the code for `T` so that we can inspect further ?Thu, 12 Sep 2019 22:06:53 +0200https://ask.sagemath.org/question/47853/degree-versus-in_degree/?comment=47863#post-id-47863Answer by dan_fulea for <p>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:</p>
<pre><code>sage: T.in_degree(vertices=[0],labels=True)
{0: 628}
sage: T.degree(vertices=[0],labels=True)
{0: 394}
</code></pre>
<p>This is also the case for other nodes in the graph.</p>
<p>Any idea what's going on here?</p>
<p>thanks!
--David</p>
https://ask.sagemath.org/question/47853/degree-versus-in_degree/?answer=47909#post-id-47909This 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?!
Fri, 13 Sep 2019 22:58:55 +0200https://ask.sagemath.org/question/47853/degree-versus-in_degree/?answer=47909#post-id-47909