示例#1
0
 def do_load_dblp(self,
                  filename,
                  start_year=2000,
                  end_year=2004,
                  conf_file='data/dblp/confs.txt',
                  coms='components'):
     """
     Load dblp dataset between years given
     :param filename:
     :param start_year:
     :param end_year:
     :param coms: ground truth communities or conferences 'confs' or 'components'
     :return:
     """
     if not filename:
         filename = "data/dblp/my_dblp_data.json"
     dblp = dblp_loader(filename,
                        start_year=start_year,
                        end_year=end_year,
                        conf_file=conf_file,
                        coms=coms)
     self.graphs = dblp.graphs
     self.comms = dblp.communities
     self.timeFrames = dblp.timeFrames
     print "DBLP data have been successfully loaded!"
     return
    pprint.pprint(mutu2.dynamic_coms, stream=f, width=150)
    f.write("NEXT CONNECTION\n")
    pprint.pprint(mutu3.dynamic_coms, stream=f, width=150)
    f.close()
    return all_res


if __name__ == "__main__":
    from os.path import expanduser
    home = expanduser("~")
    path_full = home + "/Dropbox/Msc/thesis/data/dblp/1"
    results_file = "results_dblp_" + path_full.split("/")[-1] + ".txt"
    print results_file
    dblp = dblp_loader(path_full + "/my_dblp_data.json",
                       conf_file=path_full + "/confs.txt",
                       start_year=2006,
                       end_year=2010,
                       coms='comp')
    f = open(results_file, 'a')
    for item in dblp.conf_list:
        f.write("%s\n" % item)
    f.close()
    # for t in dblp.graphs.keys():
    #     print nx.number_of_nodes(dblp.graphs[t]),
    #     new_edges = []
    #     for conf, graph in dblp.conf_graphs[t].iteritems():
    #         new_edges.extend(graph.edges())
    #     print nx.number_of_nodes(nx.Graph(new_edges))
    # print(len(set(item for sublist in [g.nodes() for _, g in dblp.graphs.items()] for item in sublist)))
    for tf, year in enumerate(dblp.communities.keys()):
        print len(dblp.all_nodes[tf]), len(