A HighlightGraph inside a Manipulate initially displays correct however after approximately 2 seconds, the layout changes and the text, links and nodes get displaced. It appears to be caused by the Manipulate cell, after the initially correct display - is again being evaluated after two seconds (judging by the appearance of the darkening of the evaluation indicator right side of the cell).

Please find a simplified example and see how components "jump" away from the initial, correct placement.

The real problem I experience is on a larger graph and the effect is substantially more dramatic, as nodes are displaced in a manner that the graph becomes illegible.

Despite the simplicity of this mock-up, It does show the reevaluation (if that is what it is) after two seconds and the displacement of nodes and text.

What is causing this and how can I avoid it, preferable without changing what I am trying to display?

To my knowledge, it is only happening when I combine a graph with self-loops and Vertex labelling inside a Manipulate wrapped around HighlightGraph.

f = {1 <-> 5, 5 <-> 6, 5 <-> 5, 6 <-> 4, 4 <-> 5, 5 <-> 3, 3 <-> 6, 
     6 <-> 2, 2 <-> 4, 4 <-> 1, 1 <-> 3, 3 <-> 2, 2 <-> 1};
h = Graph[f, VertexLabels -> description, ImagePadding -> 10];
Manipulate[HighlightGraph[h, f[[i]]], {i, 1, 12, 1}] 

Mathematica graphics

  • 1
    $\begingroup$ Strange. Quick fix: PlotRangePadding -> Scaled@.2. $\endgroup$ – Kuba Jun 17 '14 at 7:06
  • 1
    $\begingroup$ Works like a charm on v8: see here. $\endgroup$ – Öskå Jun 17 '14 at 9:15
  • $\begingroup$ Thanks for the fix (it helps) but I'm afraid I need to dig a bit deeper if the problem cannot be replicated on your machines. $\endgroup$ – Sander Jun 19 '14 at 4:18

I didn't have this problem with 9.01. As an alternative you might try:

h = Graph[f, VertexLabels -> "description", ImagePadding -> 60, 
   ImageSize -> 400];

   Slider[Dynamic@i, {1, 12, 1}],
   Dynamic@HighlightGraph[h, f[[i]]]
 TrackedSymbols -> i,
 Deployed -> True
  • $\begingroup$ Thanks for a working alternative and more important for given me some ideas what is actually causing this behaviour (some interference with scoping used by Manipulate). I'm afraid though I have some digging to do as this behaviour is not replicable by anyone else and I want to find out the cause. Thanks! $\endgroup$ – Sander Jun 19 '14 at 4:26

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.