        lon1 = nodes['Longitude'].iloc[links["From_Node"].iloc[i]]
        lat1 = nodes['Latitude'].iloc[links["From_Node"].iloc[i]]
        lon2 = nodes['Longitude'].iloc[links["To_Node"].iloc[i]]
        lat2 = nodes['Latitude'].iloc[links["To_Node"].iloc[i]]
        
        
        # convert decimal degrees to radians
        lon1, lat1, lon2, lat2 = map(math.radians, [lon1, lat1, lon2, lat2])
    
        # haversine distance formula
        dlon = lon2 - lon1
        dlat = lat2 - lat1
        a = math.sin(dlat / 2) ** 2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon / 2) ** 2
        c = 2 * math.asin(math.sqrt(a))
        r = 3956  # Radius of earth in miles
