Hi Leif, On Fri, Apr 23, 2010 at 7:47 AM, Nathan O'Treally <not.rea...@online.de> wrote:
<SNIP> > And for the single-node undirected circular graph: there's only one > edge, so degree can't be larger than 1. I think the method degree() of CGraphBackend has a bug similar to that which is tracked at ticket #8395 [1]. For a graph with one vertex and a self-loop, i.e. only one edge, if you consider that edge as directed, then the degree reported by degree() is 2. However, if you consider the graph as undirected, the degree reported by degree() is 1. [mv...@sage ~]$ sage ---------------------------------------------------------------------- | Sage Version 4.3.5, Release Date: 2010-03-28 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- sage: from sage.graphs.base.sparse_graph import SparseGraphBackend sage: S = SparseGraphBackend(0) sage: S.loops(True) sage: S.add_edge(0, 0, None, directed=False) sage: S.has_edge(0, 0, None) True sage: S.degree(0, directed=False) 1 sage: S.degree(0, directed=True) 2 sage: sage: reset() sage: sage: from sage.graphs.base.dense_graph import DenseGraphBackend sage: D = DenseGraphBackend(0) sage: D.loops(True) sage: D.add_edge(0, 0, None, directed=False) sage: D.has_edge(0, 0, None) True sage: D.degree(0, directed=False) 1 sage: D.degree(0, directed=True) 2 Both SparseGraphBackend and DenseGraphBackend inherit the same degree() method from CGraphBackend. The above demonstrates a bug in the implementation of degree() as it doesn't handle self-loops consistently. I understand that the total degree of any graph is twice the number of edges. [1] http://trac.sagemath.org/sage_trac/ticket/8395 -- Regards Minh Van Nguyen -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org