Hi Anne, > Isn't the following a big bug in posets in sage: > > sage: P = Poset(([1,2,3,4],[[1,4],[2,3],[3,4]]), facade = True) > sage: P.is_graded() > False > > The definition of grading is that all maximal chains of every interval > have the same length. This is given in the above poset, but sage says > it is not graded.
The code seems to assume that the poset has a least element. It uses the level_sets() function of sage/graphs/digraph.py to compute the level sets of the Hasse diagram of the poset; then it assumes that the 0-th level set (i. e., the set of vertices having no predecessor) must be the 0-th rank of the grading, that the 1-st level set (i. e., the set of vertices having all their predecessors in the 0-th level set but not lying therein themselves) must be the 1-th rank, that the 2-nd level set (i. e., the set of vertices having all their predecessors in the <=1-st level sets but not lying therein themselves) must be the 2-nd rank, etc. In the case of your P, the 0-th level set is {1,2}, and then we get a rank mismatch at vertex 4. > How should this be fixed? I am wondering about that too. My first idea would be Gaussian elimination, with each covering relation (P.cover_relations()) giving an equation of the form a_i - a_j = 1. Not sure this is anywhere near optimal, though. The nice thing about systems of linear equations with every equation containing only 2 nonzero coefficients is that, if you perform Gaussian elimination on such a system, it retains this property (that every equation has only 2 nonzero coefficients) all the way through (this is even true for Gröbner basis, keyword "binomial basis" IIRC), so it is a very sparse-matrix problem, but I don't know whether Sage has any code optimized for this case. Best regards, and sorry if this was all known already, Darij -- 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.