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
评论列表
文章目录