There are currently no projects
This tab is intentionally left blank.
It’s that time of year again; the new students have started at DIKU and start their careers as computer science students with the course DiMS — Discrete Mathematical Structures, taught from the book by the same name.
Part of the curriculum is learning about Hasse diagrams, which in essence are a way of easily visualizing the relationships between different elements under a partial order.
Now, a student came and asked me about how to draw these diagrams in Mathematica, so I got some code working which did just that. The resulting diagram, is the picture used for this post.
In the spirit of sharing, here is the Mathematica-code I used to generate this picture:
(* Combinatorica contains HasseDiagram,so we need to load it. *) (* The set the partial order operates on. *) (* Define our partial order. *) (* Generate a directed graph from the partial order. *) (* Now create our Hasse diagram *) (* Finally, let's see the resulting graph. *)
<
nums = {1, 2, 4, 7, 8, 14, 30};
pOrder[x_, y_] := Divisible[y, x];
g = MakeGraph[nums, pOrder];
h = HasseDiagram[g];
ShowGraph[h, VertexStyle -> PointSize[0.05], VertexLabel -> True,
VertexLabelColor -> White, VertexLabelPosition -> {0.012, 0}]