2
$\begingroup$

GraphLayout takes a complex specification including vertex, edge and packing layouts. These often have sub-options to control the details of the layout.

It is reasonable to expect packing layouts to have sub-options to control things such as the tightness of packing. Can we pass sub-options to packing layouts? Is there a way to control packing tightness or other parameters?


Why do I think this should be possible?

Here's a graph illustrating a complex GraphLayout specification.

Graph[{1 -> 2, 1 -> 5, 3 -> 4}, 
 VertexLabels -> Placed["Name", Center], 
 VertexSize -> {"Scaled", 0.2}, VertexShapeFunction -> "Capsule", 
 PerformanceGoal -> "Quality", 
 GraphLayout -> {
     "VertexLayout" -> {"LayeredEmbedding", "LeafDistance" -> 0.5}, 
     "PackingLayout" -> "ClosestPacking"}
 ]

enter image description here

When using an incorrect sub-option, Mathematica usually reports an error that includes the valis sub-option names. For example, if we misspell "LeafDistance" above, we get

Graph::moptx: Method option LeaDistance in LayeredDrawing is not one of {LayerSizeFunction,LeafDistance,Orientation,RootVertex,Rotation}.

These are all the documented sub-options, plus an undocumented one: "Rotation". How to use it is easy to guess: try "Rotation" -> Pi/2.

We can try to discover packing layout sub-options in the same way. If I use "PackingLayout" -> {"ClosestPacking", foo -> 1}, then I get

Graph::moptx: Method option foo in Automatic is not one of {Padding,PaddingFunction,PolyonimoNumber}.

This indicates that there should be sub-options (although polyomino is misspelt).

But trying to pass any of these sub-options causes the graph to fail to render. In fact just trying "PackingLayout" -> {"ClosestPacking"} (i.e. adding braces) causes the graph to fail to render. I get

enter image description here

Question: Can we somehow make use of these sub-options (if they are indeed implemented), either through documented or undocumented means?

$\endgroup$
  • 2
    $\begingroup$ I don't think you can do that, but you could send a suggestion for this. $\endgroup$ – halmir Oct 13 '17 at 13:35
  • $\begingroup$ @halmir Thanks, I will do that. $\endgroup$ – Szabolcs Oct 13 '17 at 13:36
1
$\begingroup$

When using GraphPlot instead of Graph, these sub-options work. But GraphPlot has other limitations compared to Graph, unfortunately. I am still looking for ways to control packing with Graph.

GraphPlot[
   {1 -> 2, 1 -> 5, 3 -> 4},
   Method -> "LayeredDrawing",
   PackingMethod -> {"ClosestPacking", Padding -> #}
   ] & /@ {1, 2}

enter image description here

$\endgroup$

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.