ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 29 Nov 2020 12:13:27 -0600Filtering certain posetshttps://ask.sagemath.org/question/54438/filtering-certain-posets/I want to filter the set of all connected posets with n points using sage.
I want to filter out the posets whose underlying undirected graph of its Hasse diagram is not a tree (equivalently, the incidence algebra is not hereditary) and such that there is no element x in the poset P such that any other element of P is comparable to y.
Is there an easy method to do this with sage?Sun, 29 Nov 2020 04:17:39 -0600https://ask.sagemath.org/question/54438/filtering-certain-posets/Answer by FrédéricC for <p>I want to filter the set of all connected posets with n points using sage.
I want to filter out the posets whose underlying undirected graph of its Hasse diagram is not a tree (equivalently, the incidence algebra is not hereditary) and such that there is no element x in the poset P such that any other element of P is comparable to y.
Is there an easy method to do this with sage?</p>
https://ask.sagemath.org/question/54438/filtering-certain-posets/?answer=54445#post-id-54445Maybe something like this
sage: def banana(n):
....: for P in posets(n):
....: if not P.is_connected():
....: continue
....: H = P.hasse_diagram()
....: if H.to_undirected().is_tree():
....: continue
....: dg = H.transitive_closure()
....: if any(dg.degree(x) == n - 1 for x in dg):
....: continue
....: yield P Sun, 29 Nov 2020 06:31:37 -0600https://ask.sagemath.org/question/54438/filtering-certain-posets/?answer=54445#post-id-54445Comment by klaaa for <p>Maybe something like this</p>
<pre><code>sage: def banana(n):
....: for P in posets(n):
....: if not P.is_connected():
....: continue
....: H = P.hasse_diagram()
....: if H.to_undirected().is_tree():
....: continue
....: dg = H.transitive_closure()
....: if any(dg.degree(x) == n - 1 for x in dg):
....: continue
....: yield P
</code></pre>
https://ask.sagemath.org/question/54438/filtering-certain-posets/?comment=54448#post-id-54448Thank you very much!Sun, 29 Nov 2020 12:13:27 -0600https://ask.sagemath.org/question/54438/filtering-certain-posets/?comment=54448#post-id-54448