def __init__(self, **params) :
self.params = params
if not os.path.exists(config.MENG_GRAPH_PATH) :
log.debug("Meng graph file not found. Building one at '%s'" % config.MENG_GRAPH_PATH)
mb = MengModelBuilder()
self.graph = mb.build()
del mb
log.debug("Meng graph built. %d nodes and %d edges."
% (self.graph.number_of_nodes(), self.graph.number_of_edges()))
utils.ensure_folder(os.path.dirname(config.MENG_GRAPH_PATH))
nx.write_gexf(self.graph, config.MENG_GRAPH_PATH)
log.debug("Meng graph saved.")
else:
log.debug("Reading Meng graph file at '%s'" % config.MENG_GRAPH_PATH)
self.graph = nx.read_gexf(config.MENG_GRAPH_PATH, node_type=int)
评论列表
文章目录