lanl_routes.py 文件源码

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

项目:analyse_website_dns 作者: mrcheng0910 项目源码 文件源码
def lanl_graph():
    """ Return the lanl internet view graph from lanl.edges
    """
    import networkx as nx
    try:
        fh = open('lanl_routes.edgelist' , 'r')
    except IOError:
        print("lanl.edges not found")
        raise

    G = nx.Graph()

    time = {}
    time[0] = 0 # assign 0 to center node
    for line in fh.readlines():
        (head, tail, rtt) = line.split()
        G.add_edge(int(head), int(tail))
        time[int(head)] = float(rtt)

    # get largest component and assign ping times to G0time dictionary
    G0 = sorted(nx.connected_component_subgraphs(G), key = len, reverse=True)[0]
    G0.rtt = {}
    for n in G0:
        G0.rtt[n] = time[n]

    return G0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号