4
$\begingroup$

I have a list of sets of integers, forming semi-lattice under inclusion relation. I need to visualize transitive reduction of the semi-lattice's Hasse Diagram. What is a good way to do this in Mathematica?

For instance, take these sets

sets = {Range[0, 5], Range[1, 2], Range[2, 3], Range[1, 2], 
  Range[3, 5]}

The graph should look something like this, minus the dashed lines (those are edge that get removed by transitive reduction)

enter image description here

$\endgroup$

1 Answer 1

7
$\begingroup$
sets = {Range[0, 5], Range[3], Range[1, 2], Range[2, 3], Range[1, 2],  Range[3, 5]};


vSF = Inset[Framed[NumberLinePlot[Interval[MinMax @ #2], 
 PlotRange -> {MinMax@sets, All}, Spacings -> 0, 
 PlotStyle -> Directive[AbsoluteThickness[5], Orange, CapForm["Round"]], 
 Ticks -> {Range @@ MinMax@sets}], RoundingRadius -> 5], #] &;


TransitiveReductionGraph[
 RelationGraph[UnsameQ[##] && SubsetQ[#2, #] &, sets], 
 VertexShapeFunction -> vSF, 
 PerformanceGoal -> "Quality"]

enter image description here

$\endgroup$
1
  • $\begingroup$ beautiful, thanks! $\endgroup$ Jan 23 at 6:42

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.