2
$\begingroup$

Let's say I have a rather large adjacency matrix for a partial order relation. Say an 80x80 matrix. What is the best way to display Hasse diagram? I have tried AdjacencyGraph and it does a not so bad job of displaying the graph, but it is definitely not a "good" Hasse diagram. Any help would be greatly appreciated!

EDIT

I was successfully able to draw the graph using

Needs["Combinatorica`"];
Hasse = ShowGraph[HasseDiagram[FromAdjacencyMatrix[hasseMatrix, Type -> Directed]]]

after using the information from the answer @Dr.belisarius gave.

$\endgroup$
  • $\begingroup$ Take a look at HasseDiagram[ ] on the Combinatorica package $\endgroup$ – Dr. belisarius Jan 21 '16 at 5:27
  • $\begingroup$ reference.wolfram.com/mathematica/Combinatorica/tutorial/… $\endgroup$ – Dr. belisarius Jan 21 '16 at 5:29
  • $\begingroup$ I have tried to use HasseDiagram[], but for whatever reason it just spits HasseDiagram[insert.graph.here] as output. Perhaps I am not loading Combinatorica correctly? $\endgroup$ – jix816 Jan 21 '16 at 5:40
  • 1
    $\begingroup$ If you work on this, sooner or later you will come across the function TransitiveReductionGraph. I wanted to warn you now that that function is known to be buggy. Check the link to determine whether the bug would affect your results. $\endgroup$ – Szabolcs Jan 21 '16 at 8:56
3
$\begingroup$

For example (Partial order here is vertex reachability)

SeedRandom@42;
<< Combinatorica`
g = System`RandomGraph[{9, 7}, VertexLabels -> "Name"];
g1 = System`Graph[VertexList@g, DirectedEdge @@@ EdgeList@g]; 
ShowGraph[ HasseDiagram[ MakeGraph[VertexList[g1], 
                        GraphDistance[g1, #1, #2] =!= Infinity &]], VertexNumber -> True]

Mathematica graphics

$\endgroup$
  • 1
    $\begingroup$ Thank you! This is exactly what I want except I would like to feed in a matrix as the input. This is awesome, though! I wasn't able to get Mathematica to draw HasseDiagrams at all until this example. I was beginning to think it was some sort of installation malfunction, but, alas, it was user error. $\endgroup$ – jix816 Jan 21 '16 at 6:56
  • 2
    $\begingroup$ @jix816 Glad to hear that. May the force ... etc $\endgroup$ – Dr. belisarius Jan 21 '16 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.