'k: number of switches
n: number of hosts per switch'

def build(self, k=2, n=1, **_opts):

    self.k = k
    self.n = n
    if (n == 1):
        genHostName = (lambda i, j: ('h%s' % i))
    else:
        genHostName = (lambda i, j: ('h%ss%d' % (j, i)))
    lastSwitch = None
    for i in irange(1, k):
        switch = self.addSwitch(('s%s' % i))
        for j in irange(1, n):
            host = self.addHost(genHostName(i, j))
            self.addLink(host, switch)
        if lastSwitch:
            self.addLink(switch, lastSwitch)
        lastSwitch = switch
