I am using CommunityGraphPlot on a network with 500ish nodes. I am defining the graph using a variable adjmatrix which is the adjacency matrix of the network. Right now the nodes are just named by number. I have a list vertexnames where the index of each entry is that number node. How do I use CommunityGraphPlot so that each vertex is labelled with the corresponding name in vertexnames?

  • $\begingroup$ What do you get from Options[CommunityGraphPlot]? $\endgroup$
    – Jason B.
    Jan 25 '17 at 2:36
  • $\begingroup$ The relevant Option seems to be VertexLabels although I don't know how to assign them to the list entries. $\endgroup$
    – tharvey
    Jan 25 '17 at 2:43
  • $\begingroup$ Neither do I, but I'd start with smaller examples to figure out the syntax, or look at the help page to see if it gives examples on VertexLabels $\endgroup$
    – Jason B.
    Jan 25 '17 at 2:46
  • $\begingroup$ Is this not practically the same question you posted yesterday, but with fewer details? $\endgroup$
    – MarcoB
    Jan 25 '17 at 4:28
  • $\begingroup$ I intended this one to be about how to label the vertices and the one yesterday to be about the display size. I cannot figure out the syntax for labelling vertices, even after looking through the documentation on Wolframs site. $\endgroup$
    – tharvey
    Jan 25 '17 at 4:38

Read up on VertexLabels and Thread.

Here's an example—first we create an example graph with no human readable vertex names and a list of names:

g = ExampleData[{"NetworkGraph", "DolphinSocialNetwork"}];
names = VertexList[g];
g = IndexGraph[g];

Then label the nodes:

CommunityGraphPlot[g, VertexLabels -> Thread[VertexList[g] -> names]]

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.