def cugraph_strong_call(cu_M): # cugraph Pagerank Call G = cugraph.DiGraph() G.from_cudf_edgelist(cu_M, source="0", destination="1") t1 = time.time() df = cugraph.strongly_connected_components(G) t2 = time.time() - t1 print("Time : " + str(t2)) label_vertex_dict = defaultdict(list) for i in range(len(df)): label_vertex_dict[df["labels"][i]].append(df["vertices"][i]) return label_vertex_dict
def cugraph_strong_call(cu_M): # cugraph Pagerank Call G = cugraph.DiGraph() G.from_cudf_edgelist(cu_M, source='0', target='1') t1 = time.time() df = cugraph.strongly_connected_components(G) t2 = time.time() - t1 print('Time : ' + str(t2)) result = df['labels'].to_array() labels = sorted(result) return labels
def cugraph_strong_call(cu_M): # Device data sources = cu_M['0'] destinations = cu_M['1'] # cugraph Pagerank Call G = cugraph.Graph() G.add_edge_list(sources, destinations, None) t1 = time.time() df = cugraph.strongly_connected_components(G) t2 = time.time() - t1 print('Time : ' + str(t2)) result = df['labels'].to_array() labels = sorted(result) return labels
def test_strong_cc_nx(graph_file): gc.collect() M = utils.read_csv_for_nx(graph_file) Gnx = nx.from_pandas_edgelist( M, source="0", target="1", create_using=nx.DiGraph() ) nx_scc = nx.strongly_connected_components(Gnx) nx_result = sorted(nx_scc) cu_scc = cugraph.strongly_connected_components(Gnx) pdf = pd.DataFrame.from_dict(cu_scc, orient='index').reset_index() pdf.columns = ["vertex", "labels"] cu_result = pdf["labels"].nunique() assert len(nx_result) == cu_result
def strongly_connected_components(graph: CuGraph) -> CuDFNodeMap: series = cugraph.strongly_connected_components( graph.value).set_index("vertices")["labels"] return CuDFNodeMap(series)