3
$\begingroup$

How to prevent a behavior on a picture below? Why vertices overlap with vertex labels?

 n = 20;
 SeedRandom[1]
 Show@Graph[
 RandomGraph[{n, 5 n}],
 VertexLabels -> Thread[Range[n] -> Hash /@ Range[n]],
 VertexSize -> 0.5,
 GraphLayout -> "SpringElectricalEmbedding",
 ImageSize -> 700
 ]

minimal example

I drawing graphs of friends and it's connections from vk social network and often vertices overlap vertex labels. Very hard to read something on the right side of image:

ego-net example

Any ideas? It look like VertexRenderingFunction can not help in it case.

{$VersionNumber,$System}
(* {10.3, "Linux x86 (64-bit)"} *)
$\endgroup$
2
  • $\begingroup$ This is my first question, I worry a little bit $\endgroup$
    – mynameis
    Commented Nov 16, 2015 at 20:10
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – Michael E2
    Commented Nov 16, 2015 at 21:09

1 Answer 1

1
$\begingroup$

A simple workaround for this problem is to render the vertex labels separately.

n = 20;
SeedRandom[1]
g = Graph[
   RandomGraph[{n, 5 n}, GraphLayout -> "SpringElectricalEmbedding"],
   VertexSize -> 0.5, ImageSize -> 700];

Show[
 g,
 MapThread[Graphics@Text[#1, #2 + {0.4, 0.1}] &, 
   {Hash /@ Range[n], GraphEmbedding[g, "SpringElectricalEmbedding"]}]
 ]

enter image description here

$\endgroup$
1
  • $\begingroup$ sorry for late response, it works well! Thank you! $\endgroup$
    – mynameis
    Commented Nov 24, 2015 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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