if abs(lat-c_lat) <= radius and abs(lng-c_lng) <= radius:
        return True
    else:
        print "catch a false"
        return False
    

data_path = '../DataSet/'
graph_path = '../DataSet/GraphData/'
venue_path = '../DataSet/VenueData/'

trsn_list = VH.load_pickle_file(data_path, 'sf_trsn')
time_list = VH.load_pickle_file(data_path, 'sf_time')

full_venue_dict = VH.GetFullVenueDict(venue_path, 'venues-CA-new.json')
category_dict = VH.load_json(venue_path, 'category_map.json')
pcategory_dict = VH.load_json(venue_path, 'pcategory_map.json')
lng_list = [GH.get_lat_lng(full_venue_dict, trsn[1]) for trsn in trsn_list]
lng_list.sort(key=lambda t:t[1], reverse=True)
print lng_list[0]
'''
vid_map = create_vid_map(trsn_list)

venue_g = snap.TNEANet.New()
lngs = []
for trsn_idx, trsn in enumerate(trsn_list):
    # only need check one vid
    lat, lng = GH.get_lat_lng(full_venue_dict, trsn[0])
    if within_geo_range(center, radius, lat, lng):
        lngs.append(lng)
        src_nid = vid_map[trsn[0]]
    curr_ts = int(curr_ts)
    ets = sts + 3600 * 24 * 30  # hardcode 30 days
    if curr_ts >= sts and curr_ts < ets:
        return True
    else:
        return False


data_path = "../DataSet/Transition/"
graph_path = "../DataSet/GraphData/"
venue_path = "../DataSet/VenueData/"

trsn_list = VH.load_pickle_file(data_path, "sf_trsn_small_new")
time_list = VH.load_pickle_file(data_path, "sf_time_small_new")
full_venue_dict = VH.GetFullVenueDict(venue_path, "venues-CA-new.json")
category_dict = VH.load_json(venue_path, "category_map.json")
pcategory_dict = VH.load_json(venue_path, "pcategory_map.json")

vid_map = create_vid_map(trsn_list)
ts_list = TH.gen_ts_list("201201010000", "201301010000", 30)

venue_g = snap.TNEANet.New()
for ts_idx, ts in enumerate(ts_list):
    for trsn_idx, trsn in enumerate(trsn_list):
        src_ts = time_list[trsn_idx][0]  # only need check one ts
        dst_ts = time_list[trsn_idx][1]
        if within_ts_range(ts, src_ts):
            src_nid = vid_map[trsn[0]]
            dst_nid = vid_map[trsn[1]]
            GH.add_node(venue_g, src_nid, trsn[0], src_ts)
            GH.add_node(venue_g, dst_nid, trsn[1], dst_ts)
    venue_dict[data['id']] = data
  fin.close()
  return venue_dict

# add attributes for graph nodes
def AddNodeAttr(graph, full_venue_dict):
  ''' for each node in the graph, add two attributes
      1. two float values: latitude, longitute
      2. category
      3. parent-category
  '''
  for NI in graph.Nodes():
    vid = graph.GetStrAttrDatN(NI.GetId(), 'vid')
    if vid in full_venue_dict:
      graph.AddFltAttrDatN(NI.GetId(), float(full_venue_dict[vid]['lat']), 'lat') 
      graph.AddFltAttrDatN(NI.GetId(), float(full_venue_dict[vid]['lng']), 'lng') 
      graph.AddStrAttrDatN(NI.GetId(), full_venue_dict[vid]['category'], 'category') 
      graph.AddStrAttrDatN(NI.GetId(), full_venue_dict[vid]['parentcategory'], 'pcategory') 
  #GH.save_graph(graph, result_path, result_filename)
  #return None

trsn_g = GH.load_graph(graph_data_path, graph_filename)
full_venue_dict = VH.GetFullVenueDict(venue_graph_data_path, venue_filename)
category_dict = VH.load_json(venue_graph_data_path, 'category_map.json')
pcategory_dict = VH.load_json(venue_graph_data_path, 'pcategory_map.json')

GH.add_category(trsn_g, full_venue_dict, category_dict, pcategory_dict)
GH.save_graph(trsn_g, graph_data_path, 'sf_venue_graph')
print 'successfully build venue_graph!'