hasse.Hasse
- class rewalt.hasse.Hasse(ogp)
Bases:
objectClass for “oriented Hasse diagrams” of oriented graded posets.
The oriented Hasse diagram is stored as a NetworkX directed graph whose nodes are the elements of the oriented graded poset.
The orientation information is encoded by having edges corresponding to input faces point from the face, and edges corresponding to output faces point towards the face. To recover the underlying poset’s Hasse diagram, it suffices to reverse the edges that point from an element of higher dimension.
Objects of the class can also store labels for nodes of the Hasse diagram, for example the images of the corresponding elements through a map or a diagram.
The class also has a method
draw()that outputs a visualisation of the Hasse diagram. This works with anydrawing.DrawBackend; currently available area Matplotlib backend, and
a TikZ backend.
- Parameters
ogp (
ogposets.OgPoset | ogposets.OgMap | diagrams.Diagram) – The oriented graded poset, or a map of oriented graded posets, or a diagram.
Notes
If given a map of oriented graded posets (or shapes), produces the Hasse diagram of its source, with nodes labelled with the images of elements through the map.
If given a diagram, produces the Hasse diagram of its shape, with nodes labelled with the images of elements through the diagram.
Methods
draw(**params)Outputs a visualisation of the Hasse diagram, using a backend.
Places the nodes of the Hasse diagram on the unit square canvas, and returns their coordinates.
Attributes
Returns the oriented Hasse diagram as a NetworkX graph.
Returns the labels of nodes of the Hasse diagram, in the same format as
ogposets.OgMap.mapping().Returns the set of nodes of the Hasse diagram, that is, the graded set of elements of the oriented graded poset it encodes.
- property nodes
Returns the set of nodes of the Hasse diagram, that is, the graded set of elements of the oriented graded poset it encodes.
- Returns
nodes – The set of nodes of the Hasse diagram.
- Return type
ogposets.GrSet
- property diagram
Returns the oriented Hasse diagram as a NetworkX graph.
- Returns
diagram – The oriented Hasse diagram.
- Return type
networkx.DiGraph
- property labels
Returns the labels of nodes of the Hasse diagram, in the same format as
ogposets.OgMap.mapping().- Returns
labels – The labels of the Hasse diagram.
- Return type
list[list]
- place_nodes()
Places the nodes of the Hasse diagram on the unit square canvas, and returns their coordinates.
The nodes are placed on different heights according to the dimension of the element their correspond to. Elements of the same dimension are then placed at different widths in order of position.
The coordinates are returned as a dictionary whose keys are the elements corresponding to nodes of the diagram.
- Returns
coordinates – The coordinates assigned to nodes.
- Return type
dict[tuple[float]]
- draw(**params)
Outputs a visualisation of the Hasse diagram, using a backend.
Currently supported are a Matplotlib backend and a TikZ backend; in both cases it is possible to show the output (as a pop-up window for Matplotlib, or as code for TikZ) or save to file.
Various customisation options are available, including different orientations and colours.
- Keyword Arguments
tikz (
bool) – Whether to output TikZ code (default isFalse).show (
bool) – Whether to show the output (default isTrue).path (
str) – Path where to save the output (default isNone).orientation (
str) – Orientation of the Hasse diagram: one of'bt'(bottom-to-top),'lr'(left-to-right),'tb'(top-to-bottom),'rl'(right-to-left) (default is'bt').bgcolor (multiple types) – The background colour (default is
'white').fgcolor (multiple types) – The foreground colour, given by default to nodes and labels (default is
'black').labels (
bool) – Whether to display node labels (default isTrue).inputcolor (multiple types) – The colour of edges corresponding to input faces (default is
'magenta').outputcolor (multiple types) – The colour of edges corresponding to output faces (default is
'blue').xscale (
float) – (TikZ only) Scale factor to apply to x axis in output (default is based on the dimension and maximal number of elements in one dimension).yscale (
float) – (TikZ only) Scale factor to apply to y axis in output (default is based on the dimension and maximal number of elements in one dimension).