Message Boards Message Boards

Individual vertex styling in CommunityGraphPlot

Posted 10 years ago

Hey,

Is there a way to asign a specific colour to vertices, which are part of one community in CommunityGraphPlot.

CommunityGraphPlot[RandomGraph[{30, 300}, DirectedEdges -> True]]

Best,

POSTED BY: Peanut Butter

Hi,

the problem is that CommunityGraphPlot does not appear to do that automatically. But you can change it a bit to make it work:

g = RandomGraph[{30, 300}]; color = 
 Table[RandomColor[], {i, 1, 
   Length[FindGraphCommunities[g]]}]; CommunityGraphPlot[g, 
 DirectedEdges -> True, 
 VertexStyle -> 
  Join[Flatten[
    Table[# -> color[[i]] & /@ FindGraphCommunities[g][[i]], {i, 1, 
      Length[FindGraphCommunities[g]]}]], {5 -> Black}]]

In this case I colour 5th vertex in black.

enter image description here

I do admit that this is not very elegant....

Cheers,

M.

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

Group Abstract Group Abstract