#18910: Boost minimum spanning tree
-------------------------------------+-------------------------------------
       Reporter:  borassi            |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.8
      Component:  graph theory       |   Resolution:
       Keywords:  Boost, minimum     |    Merged in:
  spanning tree                      |    Reviewers:
        Authors:  Michele Borassi    |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:                     |  ceda13f0b83784adce78b527099e08e7e003c6ac
  u/borassi/boost_minimum_spanning_tree|     Stopgaps:
   Dependencies:  #18876, #18906     |
-------------------------------------+-------------------------------------

Comment (by borassi):

 Hello!

 Yeah, I have some problems, too: it is difficult to decide which is the
 correct behavior. In your examples, I have trouble understanding which
 improvement you are suggesting: could you be a bit more specific?

 In particular, in the first two cases, you provide a weight function which
 is not correct, so a TypeError is raised (if you provide a function, the
 algorithm raises an error if it is not correct). In the third case, your
 graph is not weighted:

 {{{
 sage: g = Graph([(0,1,1), (1,2,'b')])
 sage: g.weighted()
 False
 }}}
 Hence, the algorithm simply says "Since the graph is not weighted, I
 ignore the label and set weight 1 to each edge".

 Maybe a problem occurs if the graph is weighted and no function is
 provided: in this case, the algorithm tries to use labels even if they are
 not numbers. In Boost algorithms, non-numeric weights are assumed to be 1,
 while in other algorithms labels are simply compared, and Python decides
 which is the biggest.

 {{{
 sage: g = Graph([(0,1,1), (1,2,'b')], weighted=True)
 sage: g.min_spanning_tree(algorithm="Prim_Boost")
 [(0, 1, 1), (1, 2, 'b')]
 sage: g.min_spanning_tree(algorithm="Prim_fringe")
 [(0, 1, 1), (1, 2, 'b')]
 sage: g.min_spanning_tree(algorithm="Prim_edge")
 [(0, 1, 1), (1, 2, 'b')]
 sage: g.min_spanning_tree(algorithm="Kruskal")
 [(0, 1, 1), (1, 2, 'b')]
 sage: g.min_spanning_tree(algorithm="Kruskal_Boost")
 [(0, 1, 1), (1, 2, 'b')]
 sage: g.min_spanning_tree(algorithm="NetworkX")
 [(0, 1, 1), (1, 2, 'b')]
 }}}
 In the latter example, do you think I should only improve the explanation,
 which is in the INPUT section of the documentation and in the examples? Or
 do you think I should raise an exception if a weight is not a number?

 Thank you very much!

 Michele

--
Ticket URL: <http://trac.sagemath.org/ticket/18910#comment:9>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

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

Reply via email to