def OS3EWeightedGraph():

    data = {}
    g = OS3EGraph()
    longit = {}
    lat = {}
    # Get locations
    if os.path.isfile(LATLONG_FILE):
        print "Using existing lat/long file"
        data = read_json_file(LATLONG_FILE)
    else:
        print "Generating new lat/long file"
        for n in g.nodes():
            data[n] = get_lat_long(n)
        write_json_file(LATLONG_FILE, data)

    for node in g.nodes():
        latit = float(data[node]["Latitude"])
        lon = float(data[node]["Longitude"])
        lat[node] = latit
        longit[node] = lon
    nx.set_node_attributes(g, "Latitude", lat)
    nx.set_node_attributes(g, "Longitude", longit)

    # Append weights
    for src, dst in g.edges():
        g[src][dst]["weight"] = dist_in_miles(data, src, dst)
        # print "%s to %s: %s" % (src, dst, g[src][dst]["weight"])

    return g
Exemple #2
0
def OS3EWeightedGraph():

    data = {}
    g = OS3EGraph()
    longit = {}
    lat = {}
    # Get locations
    if os.path.isfile(LATLONG_FILE):
        print "Using existing lat/long file"
        data = read_json_file(LATLONG_FILE)
    else:
        print "Generating new lat/long file"
        for n in g.nodes():
            data[n] = get_lat_long(n)
        write_json_file(LATLONG_FILE, data)

    for node in g.nodes():
	latit = float(data[node]["Latitude"])
	lon = float(data[node]["Longitude"])
	lat[node] = latit
	longit[node] = lon	
    nx.set_node_attributes(g,'Latitude',lat)
    nx.set_node_attributes(g,'Longitude',longit)	
	

    # Append weights
    for src, dst in g.edges():
        g[src][dst]["weight"] = dist_in_miles(data, src, dst)
        #print "%s to %s: %s" % (src, dst, g[src][dst]["weight"])

    return g
Exemple #3
0
def OS3EWeightedGraph():

    data = {}
    g = OS3EGraph()

    # Get locations
    if os.path.isfile(LATLONG_FILE):
        print "Using existing lat/long file"
        data = read_json_file(LATLONG_FILE)
    else:
        print "Generating new lat/long file"
        for n in g.nodes():
            data[n] = get_lat_long(n)
        write_json_file(LATLONG_FILE, data)

    # Append weights
    for src, dst in g.edges():
        g[src][dst]["weight"] = dist_in_miles(data, src, dst)
        #print "%s to %s: %s" % (src, dst, g[src][dst]["weight"])

    return g
Exemple #4
0
def OS3EWeightedGraph():

    data = {}
    g = OS3EGraph()

    # Get locations
    if os.path.isfile(LATLONG_FILE):
        print("Using existing lat/long file")
        data = read_json_file(LATLONG_FILE)
    else:
        print("Generating new lat/long file")
        for n in g.nodes():
            data[n] = get_lat_long(n)
        write_json_file(LATLONG_FILE, data)

    # Append weights
    for src, dst in g.edges():
        g[src][dst]["weight"] = dist_in_miles(data, src, dst)
        #print "%s to %s: %s" % (src, dst, g[src][dst]["weight"])

    return g