3
$\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$
4
  • 2
    $\begingroup$ I don't think you can do that, but you could send a suggestion for this. $\endgroup$
    – halmir
    Commented Oct 13, 2017 at 13:35
  • $\begingroup$ @halmir Thanks, I will do that. $\endgroup$
    – Szabolcs
    Commented Oct 13, 2017 at 13:36
  • $\begingroup$ @Szabolcs Did WRI ever answer your mail regarding this issue? $\endgroup$ Commented May 13 at 12:34
  • 1
    $\begingroup$ @IstvánZachar It was a long time ago, and I don't recall receiving an answer. I actually forgot about this question, but needed the same a few days ago, and used the method in this question to discover sub-options. PolyominoNumber is no longer misspelt. BTW I did get your email and will respond, I'm sorry about the delay $\endgroup$
    – Szabolcs
    Commented May 13 at 12:52

1 Answer 1

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 and acknowledge you have read our privacy policy.

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