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.

This code:

Clear[ighamiltMol,timeList,hamiltMol,];

timeList={Abs[0.333333 E^(-I t) + 0.333333 E^(I t) + 0.166667 E^(-2 I t) + 
   0.166667 E^(2 I t)]^2, 
 Abs[0.\[VeryThinSpace]+ 0.166667 E^(-I t) - 0.166667 E^(I t) + 
   0.166667 E^(-2 I t) - 0.166667 E^(2 I t)]^2, 
 Abs[-0.166667 E^(-I t) - 0.166667 E^(I t) + 0.166667 E^(-2 I t) + 
   0.166667 E^(2 I t)]^2, 
 Abs[-0.333333 E^(-I t) + 0.333333 E^(I t) + 0.166667 E^(-2 I t) - 
   0.166667 E^(2 I t)]^2, 
 Abs[0.\[VeryThinSpace]- 0.166667 E^(-I t) - 0.166667 E^(I t) + 
   0.166667 E^(-2 I t) + 0.166667 E^(2 I t)]^2, 
 Abs[0.166667 E^(-I t) - 0.166667 E^(I t) + 0.166667 E^(-2 I t) - 
       0.166667 E^(2 I t)]^2}

hamiltMol={{0, 1, 0, 0, 0, 1}, {1, 0, 1, 0, 0, 0}, {0, 1, 0, 1, 0, 0}, {0, 0, 1,
   0, 1, 0}, {0, 0, 0, 1, 0, 1}, {1, 0, 0, 0, 1, 0}}

ighamiltMol = 
  Dynamic@AdjacencyGraph[hamiltMol, 
    VertexLabels -> Placed["Name", Tooltip], 
    GraphStyle -> "SpringEmbedding", 
    VertexShapeFunction -> (Disk[#1, timeList[[#2]]] &)];

Animator[Dynamic[t], {0, 19}, .5]
ighamiltMol

Generates this animation (2 pictures shown, notice the resizing): Mathematica graphics Mathematica graphics

I would like my disks' radii not to exceed 2/3 of the distance between two vertices, so that the graph needs no resizing.

The same method applied to GraphPlot[] and GraphPlot3D[] also does not work, producing results like those obtained with AdjacencyGraph[]. I've tried setting a DataRange->{}, but it doesn't work either. Rescale[]ing didn't work.

(Note that this is not a problem in a Graphics[] environment.)

I don't know what to try next.

share|improve this question
1  
Your pasted code is incomplete. E.g. in the first snippet, hamiltMoland timeCoeff are not defined. –  Yves Klett Mar 16 '12 at 7:34
    
They are - commented out. hamiltMol is an adjacency matrix and timeCoeff[] looks in a table containing complex exponentials, one per vertex. The problem occurs even with a square and a Sin[] varying disk radius. –  CHM Mar 16 '12 at 8:16
2  
Working code will get you more takers. Just paste in a toy example, if the original is too complex. –  Yves Klett Mar 16 '12 at 8:44
1  
@YvesKlett The code has been edited. –  CHM Mar 16 '12 at 20:15
add comment

1 Answer 1

up vote 4 down vote accepted

Assuming that timecoeff is scaled between 0 and 1 you could do something like this (I just made something up for timecoeff and hamiltMol):

Clear[ighamiltMol, t]; t = 0;
timeCoeff[i_] := (1 + Sin[t + 2.5 i])/2
hamiltMol = NestList[RotateRight, {0, 1, 0, 0, 0, 1}, 5];

ighamiltMol = 
 Dynamic@AdjacencyGraph[hamiltMol,(*hamiltMol is a symmetric sparse/
   adjacency matrix*)
   EdgeShapeFunction -> (Line[#1] &),
   VertexLabels -> Placed["Name", Tooltip], 
   GraphStyle -> "SpringEmbedding", 
   VertexShapeFunction -> ({{Opacity[0], Disk[#1, #3]},
       Disk[#1, #3 timeCoeff[#2] ]} &),
   VertexSize -> 
    4/3];(*timeCoeff[] looks in a list of complex \
exponentials*)Animator[Dynamic[t], {0, 2 Pi}, .1]
ighamiltMol

Mathematica graphics

This works by using a VertexShapeFunction which consists of two disks on top of each other, namely a transparent one with a fixed radius, and a solid one with a varying radius. The option VertexSize -> 4/3 makes sure that the maximum radius is equal to 2/3 time the mimimum length of all vertices.

share|improve this answer
    
Changing VertexSize doesn't work for me, neither does adding a normalization factor to timeCoeff[]. I think the problem lies in the space that's allocated for the graph by Mathematica - it's constantly updated. What I'd like is for the graph to be centered in a wider canvas, so there's no need to resize. –  CHM Mar 16 '12 at 20:33
1  
The invisible disks should prevent the size of the graph from changing as t changes. VertexSize only works in combination with multiplying the radius of the disks with the third argument supplied to VertexShapeFunction. –  Heike Mar 16 '12 at 20:43
    
Turns out EdgeShapeFunction was essential. Thank you =) –  CHM Mar 16 '12 at 20:59
1  
Heike, congratulations on the first tag badge! –  Mr.Wizard Mar 18 '12 at 18:53
    
Thanks @Mr.Wizard. –  Heike Mar 18 '12 at 19:12
add comment

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.