Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

share|improve this question
1  
Strange. Quick fix: PlotRangePadding -> Scaled@.2. –  Kuba Jun 17 at 7:06
1  
Works like a charm on v8: see here. –  Öskå Jun 17 at 9:15
    
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. –  Sander Jun 19 at 4:18

1 Answer 1

up vote 1 down vote accepted

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

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

Manipulate[
 Column[{
   Slider[Dynamic@i, {1, 12, 1}],
   Dynamic@HighlightGraph[h, f[[i]]]
   }],
 TrackedSymbols -> i,
 Deployed -> True
 ]
share|improve this answer
    
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! –  Sander Jun 19 at 4:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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