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.Mon, 11 Nov 2013 08:13:50 -0600How to plot O(P) of a Poset P in sage?https://ask.sagemath.org/question/10571/how-to-plot-op-of-a-poset-p-in-sage/Hello,
I just installed sage. I want to use it to do some things with Posets for my Modern ALgebra Class. For example, I want to use it to compute and plot the O(P) of a poset P. (The Poset of the order ideals of P).
1- Where I can find examples of how to construct Posets? I know that in the references they are some examples, but is there some type of tutorial with Posets or pdf with examples?
2- How I can plot O(P)? I know that there is a method called P.directed_subsets('down') to compute the down sets of P. The problem is that this method returns a List... So I can't plot a hasse diagram of it... For example:
P = Poset((divisors(12), attrcall("divides")), facade=True)
A = P.directed_subsets('up')
sorted(list(A))
[[], [1, 2, 4, 3, 6, 12], [2, 4, 3, 6, 12], [2, 4, 6, 12], [3, 6, 12], [4, 3, 6, 12], [4, 6, 12], [4, 12], [6, 12], [12]]
3- I dont understand the order_ideals method. What are the parameters of this function??
Thanks!!
Note: As you see, I am very new here, some insight of how to work with sage is appreciated!Fri, 27 Sep 2013 15:03:42 -0500https://ask.sagemath.org/question/10571/how-to-plot-op-of-a-poset-p-in-sage/Answer by tmonteil for <p>Hello,</p>
<p>I just installed sage. I want to use it to do some things with Posets for my Modern ALgebra Class. For example, I want to use it to compute and plot the O(P) of a poset P. (The Poset of the order ideals of P).</p>
<p>1- Where I can find examples of how to construct Posets? I know that in the references they are some examples, but is there some type of tutorial with Posets or pdf with examples?</p>
<p>2- How I can plot O(P)? I know that there is a method called P.directed_subsets('down') to compute the down sets of P. The problem is that this method returns a List... So I can't plot a hasse diagram of it... For example:</p>
<pre><code> P = Poset((divisors(12), attrcall("divides")), facade=True)
A = P.directed_subsets('up')
sorted(list(A))
[[], [1, 2, 4, 3, 6, 12], [2, 4, 3, 6, 12], [2, 4, 6, 12], [3, 6, 12], [4, 3, 6, 12], [4, 6, 12], [4, 12], [6, 12], [12]]
</code></pre>
<p>3- I dont understand the order_ideals method. What are the parameters of this function??</p>
<p>Thanks!!</p>
<p>Note: As you see, I am very new here, some insight of how to work with sage is appreciated!</p>
https://ask.sagemath.org/question/10571/how-to-plot-op-of-a-poset-p-in-sage/?answer=15499#post-id-15499Concerning your first question, you can see how to construct a custom poset by typing:
sage: Poset?
and look at the `EXAMPLES:` section. There are also some pre-built posets in Sage, you can get the list by typing:
sage: posets.<TAB>
where `<TAB>` stands for the tabulation.
Concerning your second question, if `L` denotes the list you constructed, you can build the poset of its elements (viewed as subsets of `{1, 2, 4, 3, 6, 12}`) ordered by the inclusion as follows:
sage: PP = Poset(([Set(s) for s in L], attrcall("issubset")))
Concerning your third question, the parameter of the `.order_ideals()` method is a list of elements of your poset. It returns the elements of `P` that are smaller of some element of the given list.
In your case:
sage: P.order_ideal([12])
[1, 2, 4, 3, 6, 12]
sage: P.order_ideal([4])
[1, 2, 4]
sage: P.order_ideal([6])
[1, 2, 3, 6]
sage: P.order_ideal([6,4])
[1, 2, 4, 3, 6]
sage: P.order_ideal([])
[]
Fri, 27 Sep 2013 23:04:55 -0500https://ask.sagemath.org/question/10571/how-to-plot-op-of-a-poset-p-in-sage/?answer=15499#post-id-15499Comment by Shariff for <p>Concerning your first question, you can see how to construct a custom poset by typing:</p>
<pre><code>sage: Poset?
</code></pre>
<p>and look at the <code>EXAMPLES:</code> section. There are also some pre-built posets in Sage, you can get the list by typing:</p>
<pre><code>sage: posets.<TAB>
</code></pre>
<p>where <code><TAB></code> stands for the tabulation.</p>
<p>Concerning your second question, if <code>L</code> denotes the list you constructed, you can build the poset of its elements (viewed as subsets of <code>{1, 2, 4, 3, 6, 12}</code>) ordered by the inclusion as follows:</p>
<pre><code>sage: PP = Poset(([Set(s) for s in L], attrcall("issubset")))
</code></pre>
<p>Concerning your third question, the parameter of the <code>.order_ideals()</code> method is a list of elements of your poset. It returns the elements of <code>P</code> that are smaller of some element of the given list.</p>
<p>In your case:</p>
<pre><code>sage: P.order_ideal([12])
[1, 2, 4, 3, 6, 12]
sage: P.order_ideal([4])
[1, 2, 4]
sage: P.order_ideal([6])
[1, 2, 3, 6]
sage: P.order_ideal([6,4])
[1, 2, 4, 3, 6]
sage: P.order_ideal([])
[]
</code></pre>
https://ask.sagemath.org/question/10571/how-to-plot-op-of-a-poset-p-in-sage/?comment=16973#post-id-16973Woow thanks!
But now I have another question. For the sake of clarity, Ill paste my code: P = Poset((divisors(12), attrcall("divides")), facade=True)
A = P.directed_subsets('up')
L = sorted(list(A))
PP = Poset(([Set(s) for s in L], attrcall("issubset")))
PP._hasse_diagram_.plot() Is There a way to see the elements of the Poset PP in the hasse diagram?? I mean each element in the Poset as a node in the png created by the call PP._hasse_diagram_.plot() @tmonteilSun, 29 Sep 2013 16:33:04 -0500https://ask.sagemath.org/question/10571/how-to-plot-op-of-a-poset-p-in-sage/?comment=16973#post-id-16973Comment by Shariff for <p>Concerning your first question, you can see how to construct a custom poset by typing:</p>
<pre><code>sage: Poset?
</code></pre>
<p>and look at the <code>EXAMPLES:</code> section. There are also some pre-built posets in Sage, you can get the list by typing:</p>
<pre><code>sage: posets.<TAB>
</code></pre>
<p>where <code><TAB></code> stands for the tabulation.</p>
<p>Concerning your second question, if <code>L</code> denotes the list you constructed, you can build the poset of its elements (viewed as subsets of <code>{1, 2, 4, 3, 6, 12}</code>) ordered by the inclusion as follows:</p>
<pre><code>sage: PP = Poset(([Set(s) for s in L], attrcall("issubset")))
</code></pre>
<p>Concerning your third question, the parameter of the <code>.order_ideals()</code> method is a list of elements of your poset. It returns the elements of <code>P</code> that are smaller of some element of the given list.</p>
<p>In your case:</p>
<pre><code>sage: P.order_ideal([12])
[1, 2, 4, 3, 6, 12]
sage: P.order_ideal([4])
[1, 2, 4]
sage: P.order_ideal([6])
[1, 2, 3, 6]
sage: P.order_ideal([6,4])
[1, 2, 4, 3, 6]
sage: P.order_ideal([])
[]
</code></pre>
https://ask.sagemath.org/question/10571/how-to-plot-op-of-a-poset-p-in-sage/?comment=16734#post-id-16734Hello again, can you please check if you can answer my question about the png scale? This one: http://ask.sagemath.org/question/3194/png-scale-of-posets-and-order-from-left-ro-right It is important for me. Thanks @tmonteil Mon, 11 Nov 2013 08:13:50 -0600https://ask.sagemath.org/question/10571/how-to-plot-op-of-a-poset-p-in-sage/?comment=16734#post-id-16734