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.

edit retag close merge delete

Sort by » oldest newest most voted

If you check the manual 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 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.

more

can you please explain the last line of your coding? thanks a lot.

( 2015-10-09 12:43:17 -0600 )edit

The 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.

( 2015-10-10 09:16:36 -0600 )edit

thanks 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.

( 2015-10-12 00:31:28 -0600 )edit

( 2015-10-14 05:11:52 -0600 )edit

Not sure if that functionality you ask is implemented in sage, sorry!

( 2015-10-14 07:27:50 -0600 )edit