Пример #1
0
def cugraph_call(M, edgevals=False):
    M = M.tocoo()
    rows = cudf.Series(M.row)
    cols = cudf.Series(M.col)
    if edgevals is False:
        values = None
    else:
        values = cudf.Series(M.data)
    G = cugraph.Graph()
    G.add_edge_list(rows, cols, values)
    return cugraph.triangles(G)
Пример #2
0
def cugraph_call(M, edgevals=False):
    G = cugraph.Graph()
    cu_M = cudf.DataFrame()
    cu_M['src'] = cudf.Series(M['0'])
    cu_M['dst'] = cudf.Series(M['1'])
    if edgevals is True:
        cu_M['weights'] = cudf.Series(M['weight'])
        G.from_cudf_edgelist(cu_M, source='src', destination='dst',
                             edge_attr='weights')
    else:
        G.from_cudf_edgelist(cu_M, source='src', destination='dst')
    return cugraph.triangles(G)
Пример #3
0
def cugraph_call(M, edgevals=False):
    G = cugraph.Graph()
    cu_M = cudf.DataFrame()
    cu_M["src"] = cudf.Series(M["0"])
    cu_M["dst"] = cudf.Series(M["1"])
    if edgevals is True:
        cu_M["weights"] = cudf.Series(M["weight"])
        G.from_cudf_edgelist(
            cu_M, source="src", destination="dst", edge_attr="weights"
        )
    else:
        G.from_cudf_edgelist(cu_M, source="src", destination="dst")
    return cugraph.triangles(G)
Пример #4
0
def test_triangles_nx(graph_file):
    gc.collect()

    M = utils.read_csv_for_nx(graph_file)
    G = nx.from_pandas_edgelist(
        M, source="0", target="1", create_using=nx.Graph()
    )

    cu_count = cugraph.triangles(G)
    dic = nx.triangles(G)
    nx_count = 0
    for i in dic.keys():
        nx_count += dic[i]

    assert cu_count == nx_count
Пример #5
0
def cugraph_call(M, edgevals=False):
    M = M.tocoo()
    G = cugraph.DiGraph()
    cu_M = cudf.DataFrame()
    cu_M['src'] = cudf.Series(M.row)
    cu_M['dst'] = cudf.Series(M.col)
    if edgevals is True:
        cu_M['weights'] = cudf.Series(M.data)
        G.from_cudf_edgelist(cu_M,
                             source='src',
                             target='dst',
                             edge_attr='weights')
    else:
        G.from_cudf_edgelist(cu_M, source='src', target='dst')
    return cugraph.triangles(G)
Пример #6
0
 def cugraph_triangle_count(graph: CuGraph) -> int:
     return cugraph.triangles(graph.value) // 3