ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 14 Oct 2015 14:27:50 +0200labelling the edges of posethttps://ask.sagemath.org/question/29820/labelling-the-edges-of-poset/ P = SetPartitions(3)
f = lambda q,p: q in p.refinements()
Po = Poset((P,f))
By using this command I have defined a poset in sage.
Po.show() displays the poset as a directed graph. My question is how to put labels to edges of this graph.
when I try to do so, I try to iterate over the edge set like:
for u in Po.edges() :
but sage saying the error message that poset object has no method edges.
Can any one tell me how to put label for this directed graph.
If we define the corresponding Hasse diagram then we can define label, but I want to do label for the edges in the poset but not for the edges in the Hasse diagram. because when we display the pose it looks nice to see, but when we print Hasse diagram it looks little messy.
Thanks for your valuable time.Thu, 08 Oct 2015 09:26:00 +0200https://ask.sagemath.org/question/29820/labelling-the-edges-of-poset/Answer by fidbc for <p>P = SetPartitions(3)
f = lambda q,p: q in p.refinements()
Po = Poset((P,f))</p>
<p>By using this command I have defined a poset in sage.</p>
<p>Po.show() displays the poset as a directed graph. My question is how to put labels to edges of this graph.
when I try to do so, I try to iterate over the edge set like:</p>
<p>for u in Po.edges() :</p>
<p>but sage saying the error message that poset object has no method edges.</p>
<p>Can any one tell me how to put label for this directed graph.</p>
<p>If we define the corresponding Hasse diagram then we can define label, but I want to do label for the edges in the poset but not for the edges in the Hasse diagram. because when we display the pose it looks nice to see, but when we print Hasse diagram it looks little messy.</p>
<p>Thanks for your valuable time.</p>
https://ask.sagemath.org/question/29820/labelling-the-edges-of-poset/?answer=29828#post-id-29828If you check the [manual](http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/posets/posets.html#sage.combinat.posets.posets.FinitePoset.show) for the `show` method you can see there is an argument called `cover_labels`. You can use this to put labels. I think that if you want to further manipulate the diagram you'll need to check the [manual](http://doc.sagemath.org/html/en/reference/graphs/sage/graphs/generic_graph.html#sage.graphs.generic_graph.GenericGraph.show) under the `show` method for DiGraphs, as this is what is being called through the Poset class.
Po=Posets.BooleanLattice(4)
label={}
for (i,x) in enumerate(Po.cover_relations()):
label[tuple(x)] = i
Po.show(cover_labels=label)
This produces.
![image description](/upfiles/14443105659870254.png)Thu, 08 Oct 2015 15:27:51 +0200https://ask.sagemath.org/question/29820/labelling-the-edges-of-poset/?answer=29828#post-id-29828Comment by GA316 for <p>If you check the <a href="http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/posets/posets.html#sage.combinat.posets.posets.FinitePoset.show">manual</a> for the <code>show</code> method you can see there is an argument called <code>cover_labels</code>. You can use this to put labels. I think that if you want to further manipulate the diagram you'll need to check the <a href="http://doc.sagemath.org/html/en/reference/graphs/sage/graphs/generic_graph.html#sage.graphs.generic_graph.GenericGraph.show">manual</a> under the <code>show</code> method for DiGraphs, as this is what is being called through the Poset class.</p>
<pre><code>Po=Posets.BooleanLattice(4)
label={}
for (i,x) in enumerate(Po.cover_relations()):
label[tuple(x)] = i
Po.show(cover_labels=label)
</code></pre>
<p>This produces.</p>
<p><img alt="image description" src="/upfiles/14443105659870254.png"/></p>
https://ask.sagemath.org/question/29820/labelling-the-edges-of-poset/?comment=29879#post-id-29879can you please explain the last line of your coding? thanks a lot.Fri, 09 Oct 2015 19:43:17 +0200https://ask.sagemath.org/question/29820/labelling-the-edges-of-poset/?comment=29879#post-id-29879Comment by fidbc for <p>If you check the <a href="http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/posets/posets.html#sage.combinat.posets.posets.FinitePoset.show">manual</a> for the <code>show</code> method you can see there is an argument called <code>cover_labels</code>. You can use this to put labels. I think that if you want to further manipulate the diagram you'll need to check the <a href="http://doc.sagemath.org/html/en/reference/graphs/sage/graphs/generic_graph.html#sage.graphs.generic_graph.GenericGraph.show">manual</a> under the <code>show</code> method for DiGraphs, as this is what is being called through the Poset class.</p>
<pre><code>Po=Posets.BooleanLattice(4)
label={}
for (i,x) in enumerate(Po.cover_relations()):
label[tuple(x)] = i
Po.show(cover_labels=label)
</code></pre>
<p>This produces.</p>
<p><img alt="image description" src="/upfiles/14443105659870254.png"/></p>
https://ask.sagemath.org/question/29820/labelling-the-edges-of-poset/?comment=29904#post-id-29904The `show` method takes an argument called `cover_labels` (which defaults to `None`). When you call `show` with a value for that argument it is used to label the cover relations of the poset. The argument `cover_labels` should be a dictionary (as in the example above) or a function having the cover relation pairs as keys or domain respectively. Whatever the dictionary/function value is will be used as a label in the diagram.Sat, 10 Oct 2015 16:16:36 +0200https://ask.sagemath.org/question/29820/labelling-the-edges-of-poset/?comment=29904#post-id-29904Comment by GA316 for <p>If you check the <a href="http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/posets/posets.html#sage.combinat.posets.posets.FinitePoset.show">manual</a> for the <code>show</code> method you can see there is an argument called <code>cover_labels</code>. You can use this to put labels. I think that if you want to further manipulate the diagram you'll need to check the <a href="http://doc.sagemath.org/html/en/reference/graphs/sage/graphs/generic_graph.html#sage.graphs.generic_graph.GenericGraph.show">manual</a> under the <code>show</code> method for DiGraphs, as this is what is being called through the Poset class.</p>
<pre><code>Po=Posets.BooleanLattice(4)
label={}
for (i,x) in enumerate(Po.cover_relations()):
label[tuple(x)] = i
Po.show(cover_labels=label)
</code></pre>
<p>This produces.</p>
<p><img alt="image description" src="/upfiles/14443105659870254.png"/></p>
https://ask.sagemath.org/question/29820/labelling-the-edges-of-poset/?comment=29928#post-id-29928thanks a lot. it woks nicely. one last question. how to format (say to make it bold or bigger the size) the labels added by these commands? thanks.Mon, 12 Oct 2015 07:31:28 +0200https://ask.sagemath.org/question/29820/labelling-the-edges-of-poset/?comment=29928#post-id-29928Comment by GA316 for <p>If you check the <a href="http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/posets/posets.html#sage.combinat.posets.posets.FinitePoset.show">manual</a> for the <code>show</code> method you can see there is an argument called <code>cover_labels</code>. You can use this to put labels. I think that if you want to further manipulate the diagram you'll need to check the <a href="http://doc.sagemath.org/html/en/reference/graphs/sage/graphs/generic_graph.html#sage.graphs.generic_graph.GenericGraph.show">manual</a> under the <code>show</code> method for DiGraphs, as this is what is being called through the Poset class.</p>
<pre><code>Po=Posets.BooleanLattice(4)
label={}
for (i,x) in enumerate(Po.cover_relations()):
label[tuple(x)] = i
Po.show(cover_labels=label)
</code></pre>
<p>This produces.</p>
<p><img alt="image description" src="/upfiles/14443105659870254.png"/></p>
https://ask.sagemath.org/question/29820/labelling-the-edges-of-poset/?comment=29994#post-id-29994please help me in editing these labels. I have struck at this point.Wed, 14 Oct 2015 12:11:52 +0200https://ask.sagemath.org/question/29820/labelling-the-edges-of-poset/?comment=29994#post-id-29994Comment by fidbc for <p>If you check the <a href="http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/posets/posets.html#sage.combinat.posets.posets.FinitePoset.show">manual</a> for the <code>show</code> method you can see there is an argument called <code>cover_labels</code>. You can use this to put labels. I think that if you want to further manipulate the diagram you'll need to check the <a href="http://doc.sagemath.org/html/en/reference/graphs/sage/graphs/generic_graph.html#sage.graphs.generic_graph.GenericGraph.show">manual</a> under the <code>show</code> method for DiGraphs, as this is what is being called through the Poset class.</p>
<pre><code>Po=Posets.BooleanLattice(4)
label={}
for (i,x) in enumerate(Po.cover_relations()):
label[tuple(x)] = i
Po.show(cover_labels=label)
</code></pre>
<p>This produces.</p>
<p><img alt="image description" src="/upfiles/14443105659870254.png"/></p>
https://ask.sagemath.org/question/29820/labelling-the-edges-of-poset/?comment=30000#post-id-30000Not sure if that functionality you ask is implemented in sage, sorry!Wed, 14 Oct 2015 14:27:50 +0200https://ask.sagemath.org/question/29820/labelling-the-edges-of-poset/?comment=30000#post-id-30000