Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.1K Views
|
7 Replies
|
1 Total Like
View groups...
Share
Share this post:

Use VertexSize with more than 999 Vertices?

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: http://community.wolfram.com/groups/-/m/t/45871 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}]

enter image description here

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

enter image description here

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

enter image description here

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

enter image description here

Attachments:
POSTED BY: l van Veen
7 Replies

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.

POSTED BY: Szabolcs Horvát

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!

POSTED BY: l van Veen

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

POSTED BY: l van Veen

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: enter image description here

POSTED BY: Szabolcs Horvát

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!

POSTED BY: l van Veen

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.

POSTED BY: Szabolcs Horvát
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard