# Obtaining lattices quickly in SAGE

At the moment I use

posets = [p for p in Posets(n) if p.is_connected() and p.is_lattice()]


to obtain all connected lattices via SAGE. But this takes terrible long for n>=8. Is there a quicker way? It would somehow be natural when the connected lattices (or just connected posets) are saved in SAGE for some small n so that one does not have to filter trough the very large set of all posets. For example there are 53 connected lattices with 7 points , while there are 2045 posets on 7 points.

edit retag close merge delete

Sort by » oldest newest most voted

It is not usual to bundle a database of combinatorial objects coming with Sage by default.

It would be nice to have a (fast) enumerated set of all lattices on a given number of elements. Although my impression is that the set of lattices on a given number of vertices is not easy to generate recursively. Indeed, the lattice property of a poset does not behave well with respect to inclusion, so a recursive enumeration would not work as smoothly as it does for posets.

That said, depending on what you want to do, you could use an iterator:

n_elmt = 7
connected_lattice_iterator = (p for p in Posets(n_elmt) if p.is_connected() and p.is_lattice())


to generate all connected lattices one by one, but it does not increase the speed of generation...

more

This is a sort of an echo of the posted

posets = [p for p in Posets(n) if p.is_connected() and p.is_lattice()]


And the iterator is slow generator. The point remains: too few connected lattices among all posets on e.g a seven elements given vertex set.

( 2017-10-10 04:02:39 +0200 )edit

This is true. I appended the answer.

( 2017-10-10 22:12:28 +0200 )edit