egocentric_network_1_5.py 文件源码

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

项目:Visualization-of-popular-algorithms-in-Python 作者: MUSoC 项目源码 文件源码
def CreateGraph():
    G = nx.Graph()
    f = open('input.txt')
    n = int(f.readline())
    for i in range(n):
        G.add_node(i+1)
    no_of_edges = int(f.readline())
    for i in range(no_of_edges):
        graph_edge_list = f.readline().split()
        G.add_edge(int(graph_edge_list[0]), int(graph_edge_list[1])) 
    vert = int(f.readline())
    return G, vert



#draws the graph and displays the weights on the edges
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号