2
$\begingroup$

I have a problem with Graph plot scaling of vertex sizes when I go from 999 vertices to 1000 vertices. The following code scales the vertex size properly when the numNodes = 999; but not numNodes = 1000. Very strange like something goes haywire in plotting graphs 1000 nodes or larger.

ClearAll["Global`*"];
(* Define some utility functions *)
addVertices[G_, numVertices_] := (
  GN = G;
  vc = VertexCount[GN];
  (* Preferential Attachment Part A *)
  For[i = 1, i <= numVertices, i++,
   (* Preferential Attachment Part A Barabasi / Albert Method *)
   (* The rich get richer... *)
   GN = EdgeAdd[
     GN, (vc + i) \[UndirectedEdge] RandomChoice[GraphCenter[GN]]];
   (* Preferential Attachment Experiment 1 *)
   GN = EdgeAdd[
     GN, (vc + i) \[UndirectedEdge] RandomChoice[GraphPriphery[GN]]];
   ];
  Return[Graph[GN, VertexLabels -> Automatic, 
    PlotLabel -> "New G with additional vertices"]]
  )
If[$KernelCount < 1, LaunchKernels[]];
Framed[Style[
  StringJoin["Running [", ToString[$KernelCount], "] kernels"]], 
 Background -> LightBlue]
numNodes = 1000;
m = 2; (* Parameter of attachment *)
G = Graph[RandomGraph[BarabasiAlbertGraphDistribution[numNodes, m]], 
  VertexStyle -> White];
vcount = VertexCount[G];
heatIndex = Table[VertexDegree[G, i], {i, 1, vcount}] ;
Length[Range[Max[heatIndex]]];
tempRange = Table[ColorData["TemperatureMap"][r], {r, 0., 1., 1/%}];
tempDegree = Table[tempRange[[heatIndex[[i]]]], {i, 1, vcount}];
vs = Table[i -> tempDegree[[i]], {i, 1, vcount}];
vh = Table[
   i -> (Log[numNodes]*m*heatIndex[[i]])/(Max[heatIndex]), {i, 1, 
    vcount}];
pl = Style[
   StringJoin[
    "Heat/Size Map of Random Barabasi/Albert Graph\nO(V) = ", 
    ToString[numNodes], ", Diameter G = ", ToString[GraphDiameter[G]],
     ", m = ", ToString[m]], Bold, FontFamily -> "Comic Sans MS"];
G = Graph[G, VertexStyle -> vs, VertexSize -> vh, PlotLabel -> pl];
vd = Thread[VertexList@G -> Normalize[VertexDegree@G, Total]]*
    Log[VertexDegree@G] // N;
G2 = SetProperty[G, VertexSize -> vd]`

See the following for additional backup material. Vertex sizes scaled by vertex degree?

$\endgroup$

1 Answer 1

2
$\begingroup$

You could set up VertexShapeFunction -> "Circle".

SetProperty[G, {VertexSize -> vd, VertexShapeFunction -> "Circle"}]
$\endgroup$
2
  • $\begingroup$ That worked. I am not sure why, perhaps you could explain it. Is there a way to add a black border to the circle? $\endgroup$ Jun 22 at 17:35
  • $\begingroup$ @PhillipD.Neumiller It's caused by automatic large plot theme. You could add EdgeForm to vertex styles : vs = Table[ i -> Directive[EdgeForm[Black], tempDegree[[i]]], {i, 1, vcount}] $\endgroup$
    – halmir
    Jun 23 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.