# Use VertexSize with more than 999 Vertices?

**URL:** <https://community.wolfram.com/t/use-vertexsize-with-more-than-999-vertices/10418>\
**Category:** Questions\
**Tags:** graphics-and-visualization, graphs-and-networks\
**Created:** [April 27, 2017, 8:55pm UTC](https://community.wolfram.com/t/use-vertexsize-with-more-than-999-vertices/10418 "2017-04-27T20:55:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lvveen](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/lvveen/32/4003_2.png) [@lvveen](https://community.wolfram.com/u/lvveen)\
**Post date:** [April 27, 2017, 8:55pm UTC](https://community.wolfram.com/t/use-vertexsize-with-more-than-999-vertices/10418/1 "2017-04-27T20:55:33Z")

</div>

Mathematica Version 11.1/ Windows 10

I’m working om a dataset with 4000+ Vertices and wanted to make some of the Vertices a bit larger.  
After spending a lot of time I found some suggestions like here:

> [@Using SetPropery and VertexSize](https://wolfram.discourse.group/t/191/1):
>
> I have two loosely related questions about SetProperty and VertexSize: Suppose we have a largeish graph: g=RandomGraph[BarabasiAlbertGraphDistribution[100,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 diff…

But it seems that the VertexSize is limited to a maximum of 1000 Vertices.  
I couldn’t find any documentation to such a limit and I would really think it’s a pity to find this is bug.  
So perhaps there’s a workaround.

(The code is clumsy but I found it to be the most predictable)

```
> h = RandomGraph[{999, 800}, ImageSize -> {800, 800}]

```

 ![g1.jpg](https://global.discourse-cdn.com/wolfram/original/2X/2/2ef960456638125c3a2ba3a87b319c2d44fe2d0f.jpeg)

```
vertexdata = {VertexList[h], 
    Rescale@BetweennessCentrality[h]/50}\[Transpose];
vertexes = 
  Property[#[[1]], {VertexStyle -> RandomChoice[{ Yellow, Red, Blue}],
       VertexSize -> Scaled[#[[2]]]}] & /@ vertexdata;
Graph[vertexes, EdgeList[h]]

```

 ![g2.jpg](https://global.discourse-cdn.com/wolfram/original/3X/f/5/f5d8b8e3baac9040a84c6eb9a31f10933a2dbc71.jpeg)

Now I change the number of vertices to 1000 and the Graphs is shown directly with small vertices (points)

 ![g3.jpg](https://global.discourse-cdn.com/wolfram/original/2X/3/3330c5bb01b114b6be0f0d518adb5ff4ee6dc772.jpeg)

I execute the same code and the result is not as desired. Only the colors are changed but not the size.

 ![g4.jpg](https://global.discourse-cdn.com/wolfram/original/2X/9/944209a9770df22fcfe266402bddd4be3fd5c38c.jpeg)

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/szhorvat/32/3531_2.png) [@szhorvat](https://community.wolfram.com/u/szhorvat)\
**Post date:** [April 28, 2017, 12:25pm UTC](https://community.wolfram.com/t/use-vertexsize-with-more-than-999-vertices/10418/2 "2017-04-28T12:25:11Z")

</div>

I played a bit with this. An explicit setting of `VertexShapeFunction -> "Circle"` should fix it.

I suspect that the drawing method changes for large graphs, either to optimize appearance or rendering performance.

---

<div class="post-metadata">

**Author:** ![lvveen](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/lvveen/32/4003_2.png) [@lvveen](https://community.wolfram.com/u/lvveen)\
**Post date:** [April 28, 2017, 1:50pm UTC](https://community.wolfram.com/t/use-vertexsize-with-more-than-999-vertices/10418/3 "2017-04-28T13:50:31Z")

</div>

Hi Scabolcs, Where did you use the VertexShapeFunction. When I use it I get errors (Unknown box name with Graph Elements [Circle]) or it doesn’t change anything.  
When I use

```
Graph[Range[1000], {}, VertexShapeFunction -> "Circle"]

```

the graph output is a blank. With Range[999] I see the 999 vertices.  
So where in my code did you use the VertexShapeFunction → “Circle”?  
Thx!

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/szhorvat/32/3531_2.png) [@szhorvat](https://community.wolfram.com/u/szhorvat)\
**Post date:** [April 28, 2017, 3:20pm UTC](https://community.wolfram.com/t/use-vertexsize-with-more-than-999-vertices/10418/4 "2017-04-28T15:20:10Z")

</div>

I did not actually download your notebook. I just tested what happens with more than 999 vertices.

Now I tried your notebook and I believe there is (_yet another!_) bug in Mathematica’s graph functionality. That is why you get the pink boxes. You should report this to Wolfram Support (please do).

`VertexShapeFunction -> "Circle"` should be used in `Graph`, as you have. This code works:

```
Graph[Range[1000], {}, VertexShapeFunction -> "Circle", VertexSize -> 1/2]

```

The default size seems to be too small for the vertices to be visible.

As a workaround for your case, you can use `VertexShapeFunction -> (Disk[#1,#3]&)`.

* * *

This sort of styling will be much easier to do in the next version of the IGraph/M package, by chaining `IGVertexMap` functions. I plan to release a preview version on the weekend that you can play with. Until then, here’s a teaser:

 ![Screenshot2017-04-2817.19.43.png](https://global.discourse-cdn.com/wolfram/original/2X/9/94d8023e1c9f48614bc92f89b207e7c45dbcdf34.png)

---

<div class="post-metadata">

**Author:** ![lvveen](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/lvveen/32/4003_2.png) [@lvveen](https://community.wolfram.com/u/lvveen)\
**Post date:** [April 28, 2017, 3:47pm UTC](https://community.wolfram.com/t/use-vertexsize-with-more-than-999-vertices/10418/5 "2017-04-28T15:47:52Z")

</div>

Hi Scabolcs,  
It seems that VertexSize-\> Scaled[…] is causing trouble with higher vertex numbers. Will play a bit more 🙂

---

<div class="post-metadata">

**Author:** ![lvveen](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/lvveen/32/4003_2.png) [@lvveen](https://community.wolfram.com/u/lvveen)\
**Post date:** [April 28, 2017, 3:57pm UTC](https://community.wolfram.com/t/use-vertexsize-with-more-than-999-vertices/10418/6 "2017-04-28T15:57:07Z")

</div>

I only saw your post after I posted mine 🙂  
Looks great! Will definitely play with the package and will post my results.  
What I also see is that when I use the VertexSize → x with property[] it will show the Circle or Square etc on top of the Graph.  
This causes large VertexSizes to overlap with smaller vertices when they are close. I haven’t found an option yet to get the edges in sync with the space reserved for the VertexSize. When I look at your picture I also see that overlap. It seems that when you use  
Graph[…,VertexSize-\>x,…] it uses the x size for the rendering of the complete Graphs and afterwards it will put the Vertexes specifically defined with VertexSize on top of the space x. Thx for your help. Much appreciated!

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/szhorvat/32/3531_2.png) [@szhorvat](https://community.wolfram.com/u/szhorvat)\
**Post date:** [April 28, 2017, 4:25pm UTC](https://community.wolfram.com/t/use-vertexsize-with-more-than-999-vertices/10418/7 "2017-04-28T16:25:52Z")

</div>

Actually, this may not be a bug. `VertexSize -> Scaled[s]` is not a documented syntax. It does happen to work in some cases, but that is just a coincidence. The correct usage is `VertexSize -> {"Scaled", s}`.

This evaluates:

```
GraphElementData["Circle"][{0, 0}, name, {.5, .5}]

```

But this doesn’t:

```
GraphElementData["Circle"][{0, 0}, name, Scaled[{.5, .5}]]

```

The sizes passed to the vertex function are expected to be a pair of numbers, not a `Scaled` form. The `VertexSize -> {"Scaled", s}` specification still allows for scaled sizes, but translates these to plain numbers before passing them to the vertex shape function.

Another comment: with either `VertexShapeFunction -> "Circle"` or `VertexShapeFunction -> (Disk[#1, #3]&)`, you may want to add `EdgeForm[Black]` to the vertex style.

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/szhorvat/32/3531_2.png) [@szhorvat](https://community.wolfram.com/u/szhorvat)\
**Post date:** [April 28, 2017, 8:39pm UTC](https://community.wolfram.com/t/use-vertexsize-with-more-than-999-vertices/10418/8 "2017-04-28T20:39:39Z")

</div>

[You can try the prerelease if IGraph/M now.](https://wolfram.discourse.group/t/6621/10)
