hasse diagram of a subset of a poset in sage

289 Views Asked by At

E = {1,2,3} P = SetPartitions(E) This gives the set of all partitions of E,. I have a subset Q of P and I want to construct the directed graph whose vertex set is this set Q and we draw an arrow from p to q in this graph if q covers p. How to construct this graph for a given P and Q?

The definition of covering relation can be found here : https://en.wikipedia.org/wiki/Covering_relation

Thanks for your valuable timing.

1

There are 1 best solutions below

0
On

If I understand this correctly, you mean something like

E = {1,2,3,4}
P = SetPartitions(E)
P_ = uniq([P.random_element() for i in range(5)])
Poset( (P_, lambda a, b: P.is_less_than(a, b)) )

In general you can use lambda like

Poset( (divisors(12), lambda a, b: a%b == 0) )