示例#1
0
def test_k_core_corenumber_multicolumn(graph_file):
    gc.collect()

    cu_M = utils.read_csv_file(graph_file)
    cu_M.rename(columns={'0': 'src_0', '1': 'dst_0'}, inplace=True)
    cu_M['src_1'] = cu_M['src_0'] + 1000
    cu_M['dst_1'] = cu_M['dst_0'] + 1000

    G1 = cugraph.Graph()
    G1.from_cudf_edgelist(cu_M,
                          source=["src_0", "src_1"],
                          destination=["dst_0", "dst_1"])

    corenumber_G1 = cugraph.core_number(G1)
    corenumber_G1.rename(columns={'core_number': 'values'}, inplace=True)
    corenumber_G1 = corenumber_G1[['0_vertex', '1_vertex', 'values']]

    ck_res = cugraph.k_core(G1, core_number=corenumber_G1)
    G2 = cugraph.Graph()
    G2.from_cudf_edgelist(cu_M, source="src_0", destination="dst_0")
    ck_exp = cugraph.k_core(G2)

    # FIXME: Replace with multi-column view_edge_list()
    edgelist_df = ck_res.edgelist.edgelist_df
    edgelist_df_res = ck_res.unrenumber(edgelist_df, "src")
    edgelist_df_res = ck_res.unrenumber(edgelist_df_res, "dst")
    for i in range(len(edgelist_df_res)):
        assert ck_exp.has_edge(edgelist_df_res["0_src"].iloc[i],
                               edgelist_df_res["0_dst"].iloc[i])
示例#2
0
def test_core_number_Graph_nx(graph_file):
    gc.collect()

    NM = utils.read_csv_for_nx(graph_file)
    Gnx = nx.from_pandas_edgelist(NM,
                                  source="0",
                                  target="1",
                                  create_using=nx.Graph())
    nc = nx.k_core(Gnx)
    cc = cugraph.k_core(Gnx)

    assert nx.is_isomorphic(nc, cc)
示例#3
0
def calc_k_cores(graph_file):
    cu_M = utils.read_csv_file(graph_file)
    G = cugraph.DiGraph()
    G.from_cudf_edgelist(cu_M, source='0', destination='1')
    ck = cugraph.k_core(G)
    NM = utils.read_csv_for_nx(graph_file)
    Gnx = nx.from_pandas_edgelist(NM,
                                  source='0',
                                  target='1',
                                  create_using=nx.DiGraph())
    nk = nx.k_core(Gnx)
    return ck, nk
示例#4
0
def calc_k_cores(graph_file):
    cu_M = utils.read_csv_file(graph_file)
    G = cugraph.DiGraph()
    G.from_cudf_edgelist(cu_M, source='0', target='1')

    ck = cugraph.k_core(G)

    NM = utils.read_csv_for_nx(graph_file)
    NM = NM.tocsr()
    Gnx = nx.DiGraph(NM)
    nk = nx.k_core(Gnx)
    return ck, nk
示例#5
0
def calc_k_cores(graph_file):
    M = utils.read_csv_file(graph_file)
    G = cugraph.Graph()
    G.add_edge_list(M['0'], M['1'])

    ck = cugraph.k_core(G)

    NM = utils.read_csv_for_nx(graph_file)
    NM = NM.tocsr()
    Gnx = nx.DiGraph(NM)
    nk = nx.k_core(Gnx)
    return ck, nk
示例#6
0
def calc_k_cores(graph_file, directed=True):
    # directed is used to create either a Graph or DiGraph so the returned
    # cugraph can be compared to nx graph of same type.
    cu_M = utils.read_csv_file(graph_file)
    NM = utils.read_csv_for_nx(graph_file)
    if directed:
        G = cugraph.DiGraph()
        Gnx = nx.from_pandas_edgelist(NM, source='0', target='1',
                                      create_using=nx.DiGraph())
    else:
        G = cugraph.Graph()
        Gnx = nx.from_pandas_edgelist(NM, source='0', target='1',
                                      create_using=nx.Graph())
    G.from_cudf_edgelist(cu_M, source='0', destination='1')
    ck = cugraph.k_core(G)
    nk = nx.k_core(Gnx)
    return ck, nk