public
Last active

Generating Hasse diagrams in Mathematica

  • Download Gist
hasse.nb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
(* Combinatorica contains HasseDiagram,so we need to load it. *)
<<Combinatorica`;
 
(* The set the partial order operates on. *)
nums = {1, 2, 4, 7, 8, 14, 30};
 
(* Define our partial order. *)
pOrder[x_, y_] := Divisible[y, x];
 
(* Generate a directed graph from the partial order. *)
g = MakeGraph[nums, pOrder];
 
(* Now create our Hasse diagram *)
h = HasseDiagram[g];
 
(* Finally, let's see the resulting graph. *)
ShowGraph[h, VertexStyle -> PointSize[0.05], VertexLabel -> True,
VertexLabelColor -> White, VertexLabelPosition -> {0.012, 0}]

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.