for nid, vid in enumerate(node_set): node_hash[vid] = nid trsn_g = snap.TNEANet.New() #node_id: 0 to n-1 for vid, nid in node_hash.iteritems(): trsn_g.AddNode(nid) trsn_g.AddStrAttrDatN(nid, vid, 'vid') #freq: frequncy(cnt) of edge print trsn_g.GetNodes() for idx, trsn in enumerate(trsn_list): src_nid = node_hash[trsn[0]] dst_nid = node_hash[trsn[1]] print src_nid, dst_nid #TODO: add timestamp filter if not trsn_g.IsEdge(src_nid, dst_nid): GH.add_edge_attrs(trsn_g, src_nid, dst_nid, time_list[idx]) GH.add_node_attrs(trsn_g, src_nid, dst_nid, time_list[idx]) print "add a new edge, hoho~" else: GH.update_edge_attrs(trsn_g, src_nid, dst_nid, time_list[idx]) GH.update_node_attrs(trsn_g, src_nid, dst_nid, time_list[idx]) print "update node info, haha~" print idx, trsn print len(trsn_list) GH.save_graph(trsn_g, graph_path, 'sf_trsn_graph') print "succesfully build the graph!"