'Auto color with cMAP

I have a graph that I am trying to implement community detection on (so each node is in a specific community). I want to visualize the nodes and edges with each color being a different community. In order to do this, I need to implement a color mapping per community.

Is there a way to automate what colors are selected (for example, if I need 400 colors how do I get a list of 400 colors to distinguish the different communities)?

Example of what I'm doing for a mapping with 15 colors:

cmap = {
    0 : 'maroon',
    1 : 'teal',
    2 : 'limegreen', 
    3 : 'orange',
    4 : 'green',
    5 : 'yellow',
    6 : 'blue',
    7 : 'purple',
    8 : 'gold',
    9 : 'darkturquoise',
    10: 'pink',
    11: 'white',
    12: 'grey',
    13: 'beige',
    14: 'brown',
    15: 'black'
}

G = nx.Graph() #graph of nodes and edges earlier in the data 

comms = community_louvain.best_partition(G)


node_cmap = [cmap[v] for _,v in comms.items()]

pos = nx.spring_layout(G)
nx.draw(G, pos, node_size = 10, alpha = 0.8, node_color=node_cmap)
plt.show()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source