if __name__ == '__main__': class IdCounter(object): ids = set() @staticmethod def count(new_id): IdCounter.ids.add(new_id) return len(IdCounter.ids) counter = MAX_USER_NUM basemap = BSMAP movement = MOVEMENT_HIST print("Extracting motifs ...") motifrepo = Motif() for person in movement_reader(movement, BaseStationMap(basemap)): if IdCounter.count(person.id) > counter: break user_graph = seq2graph(person.locations, True) motifrepo.add_graph(user_graph) motifrepo.stat().to_csv('motifs_stat.csv', index=False) print("Plotting motifs ...") motif_filter = range(3, 11) # Global stat all_motifs = motifrepo.all_motifs(motif_filter, True, True) totmotif = motifrepo.number_of_motifs(motif_filter)
def graph_node_sim(g1, g2): """ Implementation of similarity measure proposed by Blondel et al., 2004 """ pass def graph_couple_sim(g1, g2): """ Implementation of node (edge) similarity measure of Zager et al., 2008 """ if __name__ == '__main__': class IdCounter(object): ids = set() @staticmethod def count(new_id): IdCounter.ids.add(new_id) return len(IdCounter.ids) roadnet = RoadNetwork(HZ_SHAPEFILE) for person in movement_reader(MOVEMENT_HIST, BaseStationMap(BSMAP)): if IdCounter.count(person.id) > MAX_USER_NUM: break user_graph = person.convert2graph(roadnet, True) print user_graph.edge