Ask Your Question

Revision history [back]

So essentially you want to turn a leq-matrix into a LatticePoset and get its Hasse diagram:

sage: M = Matrix([ [ 1, 1, 1, 1, 1 ], [ 0, 1, 1, 1, 1 ], [ 0, 0, 1, 1, 1 ], [ 0, 0, 0, 1, 1 ], [ 0, 0, 0, 0, 1 ] ])
sage: L = LatticePoset((range(M.nrows()), lambda i,j: M[i,j] == 1))
sage: H = L._hasse_diagram
sage: (H.edges(labels=False), len(H))
([(0, 1), (1, 2), (2, 3), (3, 4)], 5)

I don't understand why you write a different labeling of the vertices, but I hope this helps.