2
$\begingroup$

I have a graph with nodes that themselves are images of graphs. When there are many nodes in the graph the nodes are placed too close to one another and so the images overlap, preventing the edges from being seen.

I would like to set some minimum separation between nodes so that this stops happening. I have attempted to alter the SpringElectricalEmbedding's options, such as changing "RepulsiveForcePower", but to no avail.

The code I am using is the following, with NodeGraphImgs providing the node images and edges the graph's structure:

Graph[edges[[;; , 1]],
  VertexShape -> NodeGraphImgs,
  VertexSize -> Scaled[{0.12, 0.12}],
  VertexLabels -> None,
  EdgeStyle -> Thick,
  AspectRatio -> 1,
  GraphLayout -> {"SpringElectricalEmbedding", 
    "RepulsiveForcePower" -> -1},
  ImagePadding -> 100,
  ImageSize -> Full];

For example, below is a graph with the correct output: enter image description here

however if many nodes are in the graph, the output becomes indecipherable: enter image description here

If this is not possible, an alternative solution would be a way to increase the space in which the graph is draw, such that nodes are able to be placed further away. But I do not know how to do this consistently either.

$\endgroup$
  • $\begingroup$ You could decrease the vertex sizes and increase the image size. VertexSize is, by default, interpreted as a fraction of the shortest edge length. $\endgroup$ – Szabolcs Jun 13 '18 at 17:53

Your Answer

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

Browse other questions tagged or ask your own question.