Beispiel #1
0
def calc_cg_core_number(graph_file):
    M = utils.read_csv_file(graph_file)
    G = cugraph.Graph()
    G.from_cudf_edgelist(M, source="0", destination="1")

    cn = cugraph.core_number(G)
    return cn
Beispiel #2
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])
Beispiel #3
0
def test_core_number_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.core_number(Gnx)
    cc = cugraph.core_number(Gnx)

    assert nc == cc
Beispiel #4
0
def calc_core_number(graph_file):
    M = utils.read_csv_file(graph_file)
    G = cugraph.DiGraph()
    G.from_cudf_edgelist(M, source='0', target='1')

    cn = cugraph.core_number(G)

    NM = utils.read_csv_for_nx(graph_file)
    NM = NM.tocsr()
    Gnx = nx.Graph(NM)
    nc = nx.core_number(Gnx)
    pdf = pd.DataFrame(nc, index=[0]).T
    cn['nx_core_number'] = pdf[0]
    cn = cn.rename({'core_number': 'cu_core_number'})
    return cn
Beispiel #5
0
def calc_core_number(graph_file):
    M = utils.read_csv_file(graph_file)
    G = cugraph.DiGraph()
    G.from_cudf_edgelist(M, source='0', destination='1')

    cn = cugraph.core_number(G)

    NM = utils.read_csv_for_nx(graph_file)
    Gnx = nx.from_pandas_edgelist(NM, source='0', target='1',
                                  create_using=nx.Graph())
    nc = nx.core_number(Gnx)
    pdf = [nc[k] for k in sorted(nc.keys())]
    cn['nx_core_number'] = pdf
    cn = cn.rename({'core_number': 'cu_core_number'})
    return cn
Beispiel #6
0
def calc_core_number(graph_file):
    M = utils.read_csv_file(graph_file)
    G = cugraph.Graph()
    G.add_edge_list(M['0'], M['1'])

    cn = cugraph.core_number(G)

    NM = utils.read_csv_for_nx(graph_file)
    NM = NM.tocsr()
    Gnx = nx.Graph(NM)
    nc = nx.core_number(Gnx)
    pdf = pd.DataFrame(nc, index=[0]).T
    cn['nx_core_number'] = pdf[0]
    cn = cn.rename({'core_number': 'cu_core_number'})
    return cn
Beispiel #7
0
def calc_core_number(graph_file):
    M = utils.read_csv_file(graph_file)
    G = cugraph.DiGraph()
    G.from_cudf_edgelist(M, source="0", destination="1")

    cn = cugraph.core_number(G)
    cn = cn.sort_values("vertex").reset_index(drop=True)

    NM = utils.read_csv_for_nx(graph_file)
    Gnx = nx.from_pandas_edgelist(NM,
                                  source="0",
                                  target="1",
                                  create_using=nx.Graph())
    nc = nx.core_number(Gnx)
    pdf = [nc[k] for k in sorted(nc.keys())]
    cn["nx_core_number"] = pdf
    cn = cn.rename(columns={"core_number": "cu_core_number"}, copy=False)
    return cn