def METHOD_NAME(config):
    if not os.path.exists(config.graph_work_path):
        os.makedirs(config.graph_work_path)
    str2id = dict()
    term_file = io.open(os.path.join(config.graph_work_path, "terms.txt"), "w", encoding=config.encoding)
    terms = []
    item_distribution = []
    edges = load_graph(config, str2id, term_file, terms, item_distribution)
    if config.task == "link_prediction":
        load_link_prediction_train_data(config, str2id, term_file, terms, item_distribution)
    else:
        raise ValueError
    term_file.close()
    num_nodes = len(str2id)
    str2id.clear()
    log.info("Building graph...")
    graph = pgl.graph.Graph(num_nodes=num_nodes, edges=edges)
    # indegree = graph.indegree()
    graph.indegree()
    graph.outdegree()
    graph.dump(config.graph_work_path)
    # dump alias sample table
    item_distribution = np.array(item_distribution)
    item_distribution = np.sqrt(item_distribution)
    distribution = 1.0 * item_distribution / item_distribution.sum()
    alias, events = alias_sample_build_table(distribution)
    np.save(os.path.join(config.graph_work_path, "alias.npy"), alias)
    np.save(os.path.join(config.graph_work_path, "events.npy"), events)
    log.info("End Build Graph")