Function Repository Resource:

HasseDiagram

Source Notebook

Construct a Hasse diagram of a poset

Contributed by: Wolfram Staff (original content by Sriram V. Pemmaraju and Steven S. Skiena)

ResourceFunction["HasseDiagram"][f,s]

constructs a Hasse diagram of the partial order set (poset) defined by the binary relation f and set s.

Details and Options

ResourceFunction["HasseDiagram"][f,s] effectively constructs the transitive reduction graph of the relation graph defined by the binary relation f and set s.
ResourceFunction["HasseDiagram"] accepts the options of Graph.

Examples

Basic Examples (3) 

The Hasse diagram of the set of all subsets of a three-element set, ordered by inclusion:

In[1]:=
ResourceFunction["HasseDiagram"][SubsetQ, Subsets[{"x", "y", "z"}], VertexShapeFunction -> "Name"]
Out[1]=

Permutations differing by one transposition, ordered by the number of inversions:

In[2]:=
ResourceFunction[
 "HasseDiagram"][(Count[#1 - #2, 0] == 2 && ResourceFunction["InversionCount"][#1] > ResourceFunction["InversionCount"][#2]) &, Permutations[{1, 2, 3, 4}], VertexShapeFunction -> "Name"]
Out[2]=

Positive integers ordered by divisibility:

In[3]:=
ResourceFunction["HasseDiagram"][(Mod[#1, #2] == 0) &, Range[12], VertexLabels -> "Name"]
Out[3]=

Applications (1) 

Display the domination lattice on integer partitions using the resource function DominatingIntegerPartitionQ:

In[4]:=
ClearAll@dominationLattice
In[5]:=
dominationLattice[n_, opts___] := ResourceFunction["HasseDiagram"][
  ResourceFunction["DominatingIntegerPartitionQ"], IntegerPartitions[n], opts, VertexShapeFunction -> "Name"]
In[6]:=
dominationLattice[8]
Out[6]=

Version History

  • 1.0.0 – 28 July 2020

Related Resources

License Information