#20155: Graph Generators: Add Turan Graph
-------------------------------------+-------------------------------------
       Reporter:  mcognetta          |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  minor              |    Milestone:  sage-7.1
      Component:  graph theory       |   Resolution:
       Keywords:  graphs             |    Merged in:
        Authors:  Marco Cognetta     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/mcognetta/graph_generators__add_turan_graph|  
718ad7841a15352bc482f904ce8be89ff198086b
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by mcognetta):

 Replying to [comment:3 dcoudert]:
 > Hello,
 >
 > If the method for assigning positions to vertices is also valid for
 multipartite complete graphs, you could instead add it to the
 `CompleteMultipartiteGraph` method and then just call this method with
 appropriate parameters. This would thus improve both methods. Your method
 could thus be reduced to:
 > {{{
 > if n < r:
 >    raise ValueError('n should be at least r')
 > if n < 1:
 >    raise ValueError('n should be at least 1')
 > if r < 1:
 >    raise ValueError('r should be at least 1')
 >
 > name = "Turan Graph with n: {}, r: {}".format(n,r)
 >
 > if r == 1:
 >    g = Graph(name=name)
 >    g.add_vertices(range(n))
 >    return g
 >
 > if r == 2:
 >    g = graphs.CompleteBipartiteGraph(floor(n/2),ceil(n/2))
 >    g.name(name)
 >    return g
 >
 > sizes = [ceil(n/r) for i in range(n%r)]
 > sizes += [floor(n/r) for i in range(r-(n%r))]
 > g = graphs.CompleteMultipartiteGraph(sizes)
 > g.name(name)
 > return g
 > }}}
 > I'm not sure the case `r==2` is actually needed.
 >
 > Also, I don't understand the need for method `calculate_positions` since
 it is called only once. You could simply add the code in the method.
 >
 > I think there is no need for importing `math`. You should try calling
 `floor` and `ceil` directly.
 >
 > There are several typos in the method descriptions: `wih`, `properity`,
 etc.
 >
 > You must add some `TESTS` to ilustrate the errors when calling the
 method with wrong parameters.
 >
 > Thanks for your first patch.
 >
 > David.


 Yes, I think that I will end up doing this. I wrote the code before really
 thinking about just using the CompleteMultipartiteGraph code.


 I originally tried to just use ceil() and floor() but I got an error that
 I couldn't fix.

 I will edit this patch and reupload it.

 Thanks.

--
Ticket URL: <http://trac.sagemath.org/ticket/20155#comment:5>
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 https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to