Message Boards Message Boards

0
|
2286 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Attribute to change row spacing of components in Graph?

Posted 2 years ago

In a multi-component graph, the Graph entity will usually display the components in Rows. The Spacings between each row appears to be governed by AspectRatio as shown below.

Question: Is there an attribute (property) that a user can set to over-ride the default row spacing?

If not: it is of course possible to capture the vertex coordinates and shift the lower row upwards. But I would like to check if there is a simpler solution.

edges = Join[
   (1 -> # & /@ {11, 12, 13, 14}), (2 -> # & /@ {13, 15, 
      16}), (3 -> # & /@ {14, 16, 17}),
   (12 -> # & /@ {101}),
   (# -> 102 & /@ {16, 17}),
   (4 -> # & /@ {21, 22}), (5 -> # & /@ {23}), (6 -> # & /@ {24})
   ];
Print[
  Column[(
    Graph[
       edges,
       VertexLabels -> All,
       PlotLabel -> 
        Style[Row[{"AspectRatio \[Rule] ", #}], {Black, 12}],
       AspectRatio -> #,
       GraphLayout -> "LayeredDigraphEmbedding",
       ImageSize -> {1024*2/8, Automatic}
       ] & /@ {1, 1/2}
    ), Spacings -> 4]
  ];

enter image description here

POSTED BY: Richard Frost
2 Replies
GraphLayout -> {"VertexLayout" -> "LayeredDigraphEmbedding", 
  "PackingLayout" -> "ClosestPackingCenter"}

yields

enter image description here

POSTED BY: Richard Frost
Posted 2 years ago

It sounds like you want a tighter packing, so you might try

GraphLayout -> {"PackingLayout" -> "ClosestPacking"}

or

GraphLayout -> {"PackingLayout" -> "ClosestPackingCenter"}

But yeah, if you want fine-grained control over placement, you'll probably end up specifying your own vertex coordinates.

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract