Hi Jonas,

I'm forwarding your email to sage-support.


---------- Forwarded message ----------
From: Jonas Hägglund <[email protected]>
Date: 2010/1/18
Subject: [Sage Bug Report]
To: [email protected]


Dear Professor Stein,
I found the following bug in graphs/graph.py:
g = Graph('Shc?GC@@g...@?@?...@k?op@?aa?a...@?')
g.girth() for this returns 6, but the girth of the graph is 5.
The problem can be found here:
    def girth(self):
        """
        ...
        """
        n = self.num_verts()
        best = n+1
        for i in self.vertex_iterator():
            span = set([i])
            depth = 1
            thisList = set([i])
            while 2*depth <= best and 3 < best:
                nextList = set()
                for v in thisList:
                    for u in self.neighbors(v):
                        if not u in span:
                            span.add(u)
                            nextList.add(u)
                        else:
                            if u in thisList:
                                best = depth*2-1
                                break
                            if u in nextList:
                                best = depth*2  ### OBS this can
overwrite the best value ###
                thisList = nextList
                depth += 1
        if best == n+1:
            from sage.rings.infinity import Infinity
            return Infinity
        return best
My recommendation is that 'if u in nextList:' is changed to 'if u in
nextList and best > 2*depth:' which should fix the problem.

Thanks for a great software project,
Jonas Hägglund. PhD-student in Mathematics, Umeå University, Sweden


-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to