コード例 #1
0
    - lng
    - category
    - pcategor
    
    And edge attribute:
    - trsn_cnt
    - duration
'''
g = GH.load_graph(graph_path, graph_name)
n = g.GetNodes()
print g.GetNodes(), g.GetEdges()

edge_weight = get_edge_weight(g)
node_weight = get_node_weight(g)

undirected_g = GH.convert_undirected_graph(g)
m = get_m(node_weight)
B = get_B(undirected_g, node_weight, m)
save_list(B, community_path, 'B_matrix')

num_community = 0

mod_list = []
while num_community < 10:
    edge = get_edge_to_remove(undirected_g, edge_weight)
    undirected_g.DelEdge(edge[0], edge[1])
    communities = snap.TCnComV()
    snap.GetWccs(undirected_g, communities)
    if num_community != communities.Len():
        num_community = communities.Len()
        modularity, s = get_modularity(communities, n, m, B)