The issue is that the graph is not seen as weigthed by default. So either 
you provide a weight function, or you have to set the graph has weigthed. 
Then you get what you expect.

sage: G = Graph([(0,1,78), (0,2,99), (0,5,20), (1,3,16), (1,6,68), (1,7,34), 
(2,4,43), (2,5,13), (3,4,70), (3,7,2), (4,5,76), (4,7,77), (5,7,31), (6,7,74
)]) 
sage: G.weighted()
False
sage: E = G.min_spanning_tree()
sage: print(sum(e[2] for e in E), E)
(391, [(0, 1, 78), (0, 2, 99), (0, 5, 20), (1, 3, 16), (1, 6, 68), (1, 7, 34
), (4, 5, 76)])
sage: E = G.min_spanning_tree(weight_function=lambda e:e[2])
sage: print(sum(e[2] for e in E), E)
(193, [(0, 5, 20), (1, 3, 16), (1, 6, 68), (2, 4, 43), (2, 5, 13), (3, 7, 2
), (5, 7, 31)])
sage: G.weighted()
False
sage: G.weighted(True)
sage: G.weighted()
True
sage: E = G.min_spanning_tree()
sage: print(sum(e[2] for e in E), E)
(193, [(0, 5, 20), (1, 3, 16), (1, 6, 68), (2, 4, 43), (2, 5, 13), (3, 7, 2
), (5, 7, 31)])




Le mardi 5 décembre 2017 02:38:39 UTC+1, fco...@uea.edu.br a écrit :
>
> Hello.
>
> Apparently, min_spanning_tree is not operating properly (see 
> printscreens). Manually, the result is 193. I tried several algorithms and 
> the error persists. Or am I wrong?
>
> Regards,
> Flávio.
>
>

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

Reply via email to