# Elements with labels.¶

This module implements a simple wrapper class for pairs consisting of an “element” and a “label”. For representation purposes (repr, str, latex), this pair behaves like its label, while the element is “silent”. However, these pairs compare like usual pairs (i.e., both element and label have to be equal for two such pairs to be equal). This is used for visual representations of graphs and posets with vertex labels.

class sage.misc.element_with_label.ElementWithLabel(element, label)

Bases: object

Auxiliary class for showing/viewing Posets with non-injective labelings. For hashing and equality testing the resulting object behaves like a tuple (element, label). For any presentation purposes it appears just as label would.

EXAMPLES:

sage: P = Poset({1: [2,3]})
sage: labs = {i: P.rank(i) for i in range(1, 4)}
sage: print(labs)
{1: 0, 2: 1, 3: 1}
sage: print(P.plot(element_labels=labs))
Graphics object consisting of 6 graphics primitives

sage: from sage.misc.element_with_label import ElementWithLabel
sage: W = WeylGroup("A1")