meng.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:KDDCUP2016 作者: hugochan 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号