multi_edge.py 文件源码

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

项目:graynet 作者: raamana 项目源码 文件源码
def save_summary_graph(graph, out_dir, subject,
                       str_suffix=None,
                       summary_descr='summary'):
    "Saves the features to disk."

    if out_dir is not None:
        # get outpath returned from hiwenet, based on dist name and all other parameters
        # choose out_dir name  based on dist name and all other parameters
        out_subject_dir = pjoin(out_dir, subject)
        if not pexists(out_subject_dir):
            os.mkdir(out_subject_dir)

        if str_suffix is not None:
            out_file_name = '{}_{}_multigraph_graynet.graphml'.format(str_suffix,summary_descr)
        else:
            out_file_name = '_{}_multigraph_graynet.graphml'.format(summary_descr)

        out_weights_path = pjoin(out_subject_dir, out_file_name)

        try:
            nx.info(graph)
            nx.write_graphml(graph, out_weights_path, encoding='utf-8')
            print('\nSaved the summary multi-graph to \n{}'.format(out_weights_path))
        except:
            print('\nUnable to save summary multi-graph to \n{}'.format(out_weights_path))
            traceback.print_exc()

    return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号