Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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