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

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

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
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard
Be respectful. Review our Community Guidelines to understand your role and responsibilities. Community Terms of Use