example_synthetic_timing_netsize_nodes_ernos_renyi.py 文件源码

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

项目:mrqap-python 作者: lisette-espin 项目源码 文件源码
def generateGraph(nnodes, edgeprob, directed, pathtosave):
    if os.path.exists(pathtosave):
        matrix = np.loadtxt(pathtosave)
    else:
        shape = (nnodes,nnodes)
        G = nx.fast_gnp_random_graph(n=nnodes, p=edgeprob, directed=directed)
        matrix = nx.adjacency_matrix(G)

        if pathtosave is not None:
            np.savetxt(pathtosave, matrix.toarray(), fmt='%d',)

        print nx.info(G)
        matrix = matrix.toarray()

    return matrix

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


问题


面经


文章

微信
公众号

扫码关注公众号