CS代考 CS7280 Community-Detection-Assignment

CS7280 Community-Detection-Assignment

Copyright By PowCoder代写 加微信 powcoder

import community as community_louvain
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import networkx as nx
from networkx.algorithms.community import k_clique_communities
from networkx.algorithms.community import greedy_modularity_communities
import numpy as np
from sklearn.metrics.cluster import adjusted_rand_score

Part 2 – Community Detection¶
Part A : Zachary’s Karate Club¶

# This ground truth is different from on ones in the book and lectures, but for this problem please treat it as the actual ground truth.
G = nx.karate_club_graph()
ground_truth = [0, 0, 0, 0, 0,
0, 0, 0, 1, 1,
0, 0, 0, 0, 1,
1, 0, 0, 1, 0,
1, 0, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1]
# Write the code for part A

# Generating the LFR Benchmark Network
def generate_network(mu):
tau1 = 2.5
G = nx.LFR_benchmark_graph(n, tau1, tau2, mu, average_degree=5, min_community=40, seed=10)
communities = {frozenset(G.nodes[v][‘community’]) for v in G}
return G, communities

def normalized_mutual_information(a,b):
# Fill this portion with the code for NMI, Do not use any library for directly computing NMI,
# You are free to use math functions from the math library
return # the score

Part B: LFR synthetic network¶

# Plot the graphs in this cell

Part C: the real-world datasets¶

# Part C starts here

Part 3 – Knowledge Question¶
Tip: Markdown natively supports latex if you prefer to write your solution that way. https://katex.org/docs/support_table.html
Just enclose the Tex commands between double or single \$’s .

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com