I am not sure what you mean by complete $k$-<br>
partite graph....<br>There is the python-graph package(<a href="http://code.google.com/p/python-graph/" target="_blank">http://code.google.com/p/python-graph/</a>) you might wanna check out.<br>It does return a complete graph.. may be u can tweak it??<br clear="all">

==============================================<br>Anand J<br><a href="http://sites.google.com/a/cbcs.ac.in/students/anand">http://sites.google.com/a/cbcs.ac.in/students/anand</a><br>==============================================<br>

The man who is really serious,<br>with the urge to find out what truth is,<br>has no style at all. He lives only in what is.<br>                  ~Bruce Lee<br><br>Love is a trade with no accounting policies.<br>                 ~Aang Jie<br>

<br>
<br><br><div class="gmail_quote">On Tue, Nov 24, 2009 at 05:35, Paul Miller <span dir="ltr"><<a href="http://paul.w.miller.please.dont.spam.me">paul.w.miller.please.dont.spam.me</a>@<a href="http://wmich.edu">wmich.edu</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I was wondering if there were any neat tools (like for instance,<br>
something from itertools) that would help me write the following function<br>
more elegantly.  The return value should, of course, be the complete $k$-<br>
partite graph $K_{n_1, n_2, \dots, n_k}$:<br>
<br>
def completeGraph (*ns):<br>
    '''<br>
    Returns the complete graph $K_{n_1, n_2, \dots, n_k}$ when passed<br>
    the sequence \code {n_1, n_2, \dots, n_k}.<br>
    '''<br>
    if len (ns) == 1:<br>
        return completeGraph ( * ([1] * ns[0]) )<br>
    n = sum (ns)<br>
    vertices = range (n)<br>
    partition_indices = [sum (ns[:i]) for i in range (len (ns))]<br>
    partite_sets = [vertices[partition_indices[i]:partition_indices[i+1]]<br>
\<br>
                    for i in range (len (partition_indices) - 1)]<br>
    partite_sets.append (vertices[partition_indices [-1]:] )<br>
<br>
    edges = []<br>
    for i in range (len (partite_sets)):<br>
        for j in range (i + 1, len (partite_sets)):<br>
            edges.extend ([ (u, v) for u in partite_sets [i] for v in \<br>
                           partite_sets [j] ])<br>
<br>
    return graph.Graph (vertices = vertices, edges = edges)<br>
<br>
Many thanks!<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>