Hi Simon,

On Tue, Jan 25, 2011 at 03:45:35AM -0800, Simon King wrote:
> I just noticed that DiGraph produces graphs that are mutable. Is there
> any alternative implementation of digraphs (with multiple edges) in
> Sage that are immutable?

This is an often requested feature. Please open a ticket!

See e.g.:

http://groups.google.com/group/sage-combinat-devel/browse_thread/thread/211a073fe1e7f3d8/

Actually, I once needed it so badly, that I hacked a quick
workaround. And it inadvertently went into Sage as part of another
patch (oops, shame on me and on the reviewer!). So now you can do:

        sage: G = digraphs.DeBruijn(5,0)
        sage: hash(G)
        Traceback (most recent call last):
        ...
        TypeError: graphs are mutable, and thus not hashable
        sage: G._immutable = True
        sage: hash(G)
        -3360383311399787762

Please have a look at G.__hash__. To be used at your own risk; there
is absolutely no safety; in particular nothing prevents you from
changing the graph with all the bad consequences that could occur.

Cheers,
                                Nicolas
--
Nicolas M. ThiƩry "Isil" <nthi...@users.sf.net>
http://Nicolas.Thiery.name/

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

Reply via email to