On Mon, 23 Nov 2009 19:57:05 -0800, Richard Thomas wrote: > Not sure exactly how you're representing graphs, this seems like the > simplest way of listing the edges. > > def complete_partite(*sizes): > total = sum(sizes) > nodes, edges = range(total), [] > for group in xrange(len(sizes)): > low = sum(sizes[:group-1]) > high = sum(sizes[:group]) > edges.extend((i, j) for i in xrange(low, high) > for j in xrange(high, total)) > return nodes, edges
Thanks! I think this is what I was looking for (unless the collective wisdom of c.l.py can come up with something *even more* elegant). :-) -- http://mail.python.org/mailman/listinfo/python-list