Created
May 23, 2020 18:31
-
-
Save manekgarg/e4d373febbab1717a17b0646d84ed48d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import the packages | |
import community | |
from importlib import reload | |
# reload(community) | |
# or use Girvan-Newman algorithm | |
# Assgin the community function to c_values | |
communities = community.best_partition(G.to_undirected(), resolution = .75) | |
c_values = [communities.get(node) for node in G.nodes()] | |
# Plot the the graph again with community using c_values as color | |
plt.figure(figsize=(22,16)) | |
nx.draw(G, edge_color = '#ced7d9',width = 4, arrowsize = 30, node_color = c_values, with_labels= True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment