The vertices remain ordered in layout , graph and VertexCluster , so you can do something like this:
Find the number of communities in the community structure:
>>> max(community.membership) 10
Then create a list / dictionary with max + 1 unique colors (maybe not as shown below):
>>> color_list = [ ... 'red', ... 'blue', ... 'green', ... 'cyan', ... 'pink', ... 'orange', ... 'grey', ... 'yellow', ... 'white', ... 'black', ... 'purple' ... ]
Then, using list comprehension, create a list containing the colors for each vertex, based on the group membership of that vertex, and assign this vertex_color :
plot(g, "graph.png", layout=layout, vertex_color=[color_list[x] for x in community.membership])
The result (it is so beautiful!)

source share