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.

I generated some graphs. The smallest vertices in the 1st graph should be the same size as the smallest vertices in the second graph. The smallest vertices have the same size (VertexSize value is the same) in each graph. When I generate those graphs the size of the smallest vertices seems different: graph 1

graph 1

Those 2 graphs in cdf: dropbox link .

The size of graphs is set to 'Large'. How it can be fixed? I need that to do some animation. Thanks!

share|improve this question
    
Could you post code? –  Vitaliy Kaurov Feb 24 '13 at 20:04
1  
@Vitaliy Kaurov Thanks for your attention. Code that generates graph is a part of larger program (for my thesis) and it uses some data (reads from a file). I think it's worthless to give a long, quite complex code where most of it is not related to the problem. I just gave graphs in CDF. All data required to generate each graph can be easily obtained, i.e. FullForm. –  crobartie Feb 24 '13 at 21:08

2 Answers 2

up vote 4 down vote accepted

Use Scaled sizes to set size relative to displayed size:

Row[{CompleteGraph[5, VertexSize -> .5],
  CompleteGraph[10, VertexSize -> .5],
  CompleteGraph[5, VertexSize -> Scaled[.1]],
  CompleteGraph[10, VertexSize -> Scaled[.1]]}]

sizes

You likely want to force your graphs to have the same width using ImageSize->w

share|improve this answer
1  
Thank you! Now works like it should :) –  crobartie Feb 24 '13 at 21:10

The reason you get different vertex sizes is that by default the specified vertex size is interpreted in terms of the minimum distance between vertices. This is probably done so that no vertices touch or overlap as long as you have the vertex sizes smaller than 1.

g1 = Graph[{1 -> 2, 2 -> 3}, VertexSize -> 1/3, ImageSize -> {300, 300}];
g2 = Graph[{1 -> 2, 2 -> 3, 3 -> 1}, VertexSize -> 1/3, ImageSize -> {300, 300}];
Row[{g1 // Framed, "  ", g2 // Framed}]

Mathematica graphics

The trick for many of these problems is to use Scaled as mentioned by ssch in his answer. This scales the object in terms of image size. Its use for VertexSize is undocumented on the VertexSize doc page, but follows logically from many of its uses in other Graphics stuff.

However, this means that you now have to find a suitable size yourself, whereas the designed scaling method really makes sense for graphs.

You could keep using scaled sizes in terms of inter-vertex distance by using the following:

sc = Min[EuclideanDistance @@@ Subsets[AbsoluteOptions[g1, VertexCoordinates][[1, 2]], {2}]]/
     Min[EuclideanDistance @@@ Subsets[AbsoluteOptions[g2, VertexCoordinates][[1, 2]], {2}]]

Row[
 {
  g1 // Framed, "  ",
  Graph[{1 -> 2, 2 -> 3, 3 -> 1}, VertexSize -> 1/3 sc, 
    ImageSize -> {300, 300}] // Framed
  }
]

Mathematica graphics

share|improve this answer
    
Thank you too! Good to know for future. :) –  crobartie Feb 24 '13 at 21:43

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.