Network_Generator.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:PhD 作者: wutaoadeny 项目源码 文件源码
def ER_Generateor(N=1000, M=3000):
    G = nx.gnm_random_graph(N, M)
    #component of the network
    if nx.is_connected(G) == False:
        # Get the Greatest Component of Networks #####
        components = sorted(nx.connected_components(G), key = len, reverse=True)
        print "Component Number of the Generated Network:", len(components)

        for i in range(1, len(components)):
            for node in components[i]:
                G.remove_node(node)
        #end for
        print nx.is_connected(G)
    #endif

    return G

#************************************************************************
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号