• user warning: Got error 28 from storage engine query: SELECT DISTINCT t.* FROM drupal_term_node r INNER JOIN drupal_term_data t ON r.tid = t.tid INNER JOIN drupal_vocabulary v ON t.vid = v.vid LEFT JOIN drupal_forum_access fa ON t.tid = fa.tid LEFT JOIN drupal_acl acl_fa ON acl_fa.name = t.tid AND acl_fa.module = 'forum_access' LEFT JOIN drupal_acl_user aclu_fa ON aclu_fa.acl_id = acl_fa.acl_id AND aclu_fa.uid = 0 WHERE ((fa.grant_view >= 1 AND fa.rid IN (1)) OR fa.tid IS NULL OR aclu_fa.uid = 0) AND ( r.vid = 69915 )ORDER BY v.weight, t.weight, t.name in /var/www/dikutal.dk/modules/taxonomy/taxonomy.module on line 632.
  • user warning: Got error 28 from storage engine query: SELECT DISTINCT node.nid AS nid, node.title AS node_title, node.language AS node_language, node.type AS node_type, node.vid AS node_vid, node_revisions.teaser AS node_revisions_teaser, node_revisions.format AS node_revisions_format, node_data_field_date.field_date_value AS node_data_field_date_field_date_value FROM drupal_node node LEFT JOIN drupal_content_field_date node_data_field_date ON node.vid = node_data_field_date.vid LEFT JOIN drupal_term_node term_node ON node.vid = term_node.vid AND (term_node.tid = 9 OR term_node.tid = 10 OR term_node.tid = 12 OR term_node.tid = 19 OR term_node.tid = 18 OR term_node.tid = 13 OR term_node.tid = 16 OR term_node.tid = 17 OR term_node.tid = 11 OR term_node.tid = 14 OR term_node.tid = 15) LEFT JOIN drupal_node_revisions node_revisions ON node.vid = node_revisions.vid INNER JOIN drupal_node_access na ON na.nid = node.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 1 AND na.realm = 'book_page_access_view') OR (na.gid = 1 AND na.realm = 'forum_access'))) AND ( ((node.status <> 0) AND (node.type in ('event')) AND (term_node.tid IS NULL)) AND (DATE_FORMAT(ADDTIME(node_data_field_date.field_date_value, SEC_TO_TIME(7200)), '%Y-%m-%d') >= '2014-10-22') )ORDER BY node_data_field_date_field_date_value ASC LIMIT 0, 3 in /var/www/dikutal.dk/sites/all/modules/views/includes/view.inc on line 771.

A Hasse diagram generated in Mathematica.

A Hasse diagram generated in Mathematica.

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. *)
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}]

Handlinger