Skip to content

Instantly share code, notes, and snippets.

@prateekjoshi565
Created April 5, 2020 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prateekjoshi565/fc26925cf60be008c51bc6d47d9c410e to your computer and use it in GitHub Desktop.
Save prateekjoshi565/fc26925cf60be008c51bc6d47d9c410e to your computer and use it in GitHub Desktop.
def girvan_newman(graph):
# find number of connected components
sg = nx.connected_components(graph)
sg_count = nx.number_connected_components(graph)
while(sg_count == 1):
graph.remove_edge(edge_to_remove(graph)[0], edge_to_remove(graph)[1])
sg = nx.connected_components(graph)
sg_count = nx.number_connected_components(graph)
return sg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment