Hi Sam and everyone,

thanks @Sam for bringing this up. src/sage/graphs/tutte_polynomial.py has
been scaring me for some time and I hope this will lead to its becoming
better.

One thing that goes wrong in your example (but I am unsure if it is the
main issue!) is this:

sage: G = Graph();
sage: G.allow_multiple_edges(True);
sage: #edges are (u,v,l), where (u,v) is the edge and l is the label, which
determines edge order
sage:
G.add_edges([(0,1,1),(1,5,2),(5,3,3),(5,2,4),(2,4,5),(0,2,6),(0,3,7),(0,4,8),(0,5,9)]);
sage: g = G.tutte_polynomial();
sage: G.edges()
[(0, 1, 1),
 (0, 2, 6),
 (0, 3, 7),
 (0, 4, 8),
 (0, 5, 9),
 (1, 5, 2),
 (2, 4, 5),
 (2, 5, 4),
 (3, 5, 3)]
sage: with removed_edge(G, (1,5)):
    show(G)
....:
sage: G.edges()
[(0, 1, 1),
 (0, 2, 6),
 (0, 3, 7),
 (0, 4, 8),
 (0, 5, 9),
 (1, 5, None),
 (2, 4, 5),
 (2, 5, 4),
 (3, 5, 3)]

The "removed_edge" context manager was supposed to either re-insert the
removed edge upon finishing, or not removing it in the original G to begin
with. From what we see, it has *tried* to re-insert it, but it forgot the
label. This is doubly strange because the "contract_edge" context manager
in the same file is well aware of labels.

I am not sure if this explains the bug, however.

  Best regards,
  Darij

On Sat, Feb 21, 2015 at 5:09 PM, Sam Hopkins <samuelfhopk...@gmail.com>
wrote:

> I believe there must be some error in the code that implements the Tutte
> polynomial of a graph in Sage. For example, the code
>
> G = Graph();
> G.allow_multiple_edges(True);
> #edges are (u,v,l), where (u,v) is the edge and l is the label, which
> determines edge order
>
> G.add_edges([(0,1,1),(1,5,2),(5,3,3),(5,2,4),(2,4,5),(0,2,6),(0,3,7),(0,4,8),(0,5,9)]);
> g = G.tutte_polynomial();
> print g(1,1);
> print G.spanning_trees_count();
>
> produces
>
> T(1,1): 60 Number of spanning trees: 52
>
> But of course T_G(1,1) should be equal to the number of spanning trees.
> And I am tending to believe that the error is with the Tutte polynomial
> computation and not the second "spanning_trees_count()" method.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-combinat-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-combinat-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-combinat-devel@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-combinat-devel.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-combinat-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-combinat-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to