-
-
Save dorman99/bbb624e7cfb9be0552cc486e75b1458c to your computer and use it in GitHub Desktop.
Generating Hasse diagrams in Mathematica
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* 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}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment