"Nicolas M. Thiery" <nicolas.thi...@u-psud.fr> writes: > As for posets, I don't know. I would tend to first write a draft of > the method in Posets, and then decide if the interfaces and > implementations are similar enough to be shared or not.
Here goes: # http://www.combinatorics.org/Volume_16/PDF/v16i2r9.pdf # Figure 1 # # D[1]=[4,7]; D[2]=[5,7]; D[3]=[4,5]; D[4]=[6,9]; D[5]=[6,8]; D[7]=[8,9] # P = Poset(D) # e = [P(i) for i in range(1,10)] # # gives [2, 3, 1, 5, 4, 7, 8, 9, 6] # perhaps easier to follow: label elements from bottom to top, left to right a-i: # F = dict() # F['b']=['d','f']; F['c']=['e','f']; F['a']=['d','e']; F['d']=['g','h']; F['e']=['g','i']; F['f']=['i','h'] # P = Poset(F) # e = [P('b'), P('c'), P('a'), P('d'), P('e'), P('g'), P('f'), P('i'), P('h')] # promotion(P, e) # yields [c, a, b, e, d, f, i, h, g] def promotion(P, e): extension = copy(e) pred = 0 succ = 0 x = extension[pred] rest = extension[pred+1:] covers = P.upper_covers(x) while covers: # find the first element in the extension that covers x for y in rest: succ = succ + 1 if y in covers: # replace pred by x extension[succ] = x pred = succ covers = P.upper_covers(y) rest = extension[pred+1:] x = y break return extension[1:] + [y] -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To post to this group, send email to sage-combinat-devel@googlegroups.com. To unsubscribe from this group, send email to sage-combinat-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.