Message Boards Message Boards

2 Replies
6 Total Likes
View groups...
Share this post:

Using SetPropery and VertexSize

Posted 11 years ago
I have two loosely related questions about SetProperty and VertexSize:

Suppose we have a largeish graph:

1. Why does SetProperty[g, VertexSize -> Large] make the vertices smaller than default instead of larger?  This is a bit counterintuitive.  I can work around it by specifying a number, e.g. VertexSize -> 10.  However, the actual size will still depend on the size of the graph (if we have a graph with 1000 nodes instead of 100, it'll be different).

What I'm aiming for is setting the vertex size in a general way so that it'll be a reasonable factor bigger than the default regardless of the size of the graph.  The application is highlighting a particular vertex, e.g. SetProperty[g, VertexSize -> {10 -> Large}].  I don't know how to choose a vertex size value that'll work for a graph of any size.  For example making the highlighted vertex precisely twice bigger than the rest would probably work well.

(I know I can highlight by colouring, but this is in addition to that.)

2. How can I set the VertexSize when using a predefined graph style?  For example the following doesn't work:
RandomGraph[BarabasiAlbertGraphDistribution[100, 1],
  GraphStyle -> "LargeNetwork"],
VertexSize -> {10 -> 5}
POSTED BY: Szabolcs Horvát
2 Replies
Consider a not-styled graph:
g = RandomGraph[BarabasiAlbertGraphDistribution[100, 1]]

Change all vertex sizes relatively to plot diagonal
SetProperty[g, VertexSize -> {"Scaled", .02}]

Change single vertex color and size relatively to plot diagonal
SetProperty[g, {VertexSize -> {10 -> {"Scaled", .04}},  VertexStyle -> {10 -> Red}}]

Now consider styled graph
h = RandomGraph[BarabasiAlbertGraphDistribution[100, 1], GraphStyle -> "LargeNetwork"]

Change single vertex size relatively to plot diagonal
SetProperty[h, {VertexShapeFunction -> {10 -> "Circle"}, VertexSize -> {10 -> {"Scaled", .04}}}]

Use another method and add color
SetProperty[h, VertexStyle -> {10 -> {Red, PointSize[.04]}}]

POSTED BY: Vitaliy Kaurov
Great tips Vitaliy, I don't know how I could have missed some of those basic options (probably too sleepy when posting).  I tried VertexSize -> Scaled[...] but it typically gives ellipses instead of circles becaues the plot aspect ratio is not square.
POSTED BY: Szabolcs Horvát
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract