diff --git a/python/cugraph/cugraph/community/ktruss_subgraph_wrapper.pyx b/python/cugraph/cugraph/community/ktruss_subgraph_wrapper.pyx index d3b7a38ba41..8b705e8a7b4 100644 --- a/python/cugraph/cugraph/community/ktruss_subgraph_wrapper.pyx +++ b/python/cugraph/cugraph/community/ktruss_subgraph_wrapper.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2021, NVIDIA CORPORATION. +# Copyright (c) 2019-2023, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -23,12 +23,12 @@ import numpy as np def ktruss_subgraph_float(input_graph, k, use_weights): - cdef GraphCOOViewFloat in_graph = get_graph_view[GraphCOOViewFloat](input_graph, use_weights) + cdef GraphCOOViewFloat in_graph = get_coo_float_graph_view(input_graph, use_weights) return coo_to_df(move(k_truss_subgraph[int,int,float](in_graph, k))) def ktruss_subgraph_double(input_graph, k, use_weights): - cdef GraphCOOViewDouble in_graph = get_graph_view[GraphCOOViewDouble](input_graph, use_weights) + cdef GraphCOOViewDouble in_graph = get_coo_double_graph_view(input_graph, use_weights) return coo_to_df(move(k_truss_subgraph[int,int,double](in_graph, k))) diff --git a/python/cugraph/cugraph/structure/graph_primtypes.pxd b/python/cugraph/cugraph/structure/graph_primtypes.pxd index 4e5a380f798..eaf552195da 100644 --- a/python/cugraph/cugraph/structure/graph_primtypes.pxd +++ b/python/cugraph/cugraph/structure/graph_primtypes.pxd @@ -154,22 +154,9 @@ ctypedef GraphCOOView[int,int,double] GraphCOOViewDouble ctypedef GraphCSRView[int,int,float] GraphCSRViewFloat ctypedef GraphCSRView[int,int,double] GraphCSRViewDouble -ctypedef fused GraphCOOViewType: - GraphCOOViewFloat - GraphCOOViewDouble - -ctypedef fused GraphCSRViewType: - GraphCSRViewFloat - GraphCSRViewDouble - -ctypedef fused GraphViewType: - GraphCOOViewFloat - GraphCOOViewDouble - GraphCSRViewFloat - GraphCSRViewDouble - cdef move_device_buffer_to_column(unique_ptr[device_buffer] device_buffer_unique_ptr, dtype) cdef move_device_buffer_to_series(unique_ptr[device_buffer] device_buffer_unique_ptr, dtype, series_name) cdef coo_to_df(GraphCOOPtrType graph) cdef csr_to_series(GraphCSRPtrType graph) -cdef GraphViewType get_graph_view(input_graph, bool weightless=*, GraphViewType* dummy=*) +cdef GraphCOOViewFloat get_coo_float_graph_view(input_graph, bool weighted=*) +cdef GraphCOOViewDouble get_coo_double_graph_view(input_graph, bool weighted=*) diff --git a/python/cugraph/cugraph/structure/graph_primtypes.pyx b/python/cugraph/cugraph/structure/graph_primtypes.pyx index fadd0f73a08..10f3871e157 100644 --- a/python/cugraph/cugraph/structure/graph_primtypes.pyx +++ b/python/cugraph/cugraph/structure/graph_primtypes.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2022, NVIDIA CORPORATION. +# Copyright (c) 2020-2023, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -101,28 +101,27 @@ cdef csr_to_series(GraphCSRPtrType graph): return (csr_offsets, csr_indices, csr_weights) -cdef GraphCSRViewType get_csr_graph_view(input_graph, bool weighted=True, GraphCSRViewType* dummy=NULL): - if not input_graph.adjlist: - input_graph.view_adj_list() +cdef GraphCOOViewFloat get_coo_float_graph_view(input_graph, bool weighted=True): + # FIXME: this function assumes columns named "src" and "dst" and can only + # be used for SG graphs due to that assumption. + if not input_graph.edgelist: + input_graph.view_edge_list() + + num_edges = input_graph.number_of_edges(directed_edges=True) + num_verts = input_graph.number_of_vertices() - cdef uintptr_t c_off = input_graph.adjlist.offsets.__cuda_array_interface__['data'][0] - cdef uintptr_t c_ind = input_graph.adjlist.indices.__cuda_array_interface__['data'][0] + cdef uintptr_t c_src = input_graph.edgelist.edgelist_df['src'].__cuda_array_interface__['data'][0] + cdef uintptr_t c_dst = input_graph.edgelist.edgelist_df['dst'].__cuda_array_interface__['data'][0] cdef uintptr_t c_weights = NULL - if input_graph.adjlist.weights is not None and weighted: - c_weights = input_graph.adjlist.weights.__cuda_array_interface__['data'][0] + # FIXME explicit check for None fails, different behavior than get_csr_graph_view + if input_graph.edgelist.weights and weighted: + c_weights = input_graph.edgelist.edgelist_df['weights'].__cuda_array_interface__['data'][0] - num_verts = input_graph.number_of_vertices() - num_edges = input_graph.number_of_edges(directed_edges=True) - cdef GraphCSRViewType in_graph - if GraphCSRViewType is GraphCSRViewFloat: - in_graph = GraphCSRViewFloat(c_off, c_ind, c_weights, num_verts, num_edges) - elif GraphCSRViewType is GraphCSRViewDouble: - in_graph = GraphCSRViewDouble(c_off, c_ind, c_weights, num_verts, num_edges) - return in_graph + return GraphCOOViewFloat(c_src, c_dst, c_weights, num_verts, num_edges) -cdef GraphCOOViewType get_coo_graph_view(input_graph, bool weighted=True, GraphCOOViewType* dummy=NULL): +cdef GraphCOOViewDouble get_coo_double_graph_view(input_graph, bool weighted=True): # FIXME: this function assumes columns named "src" and "dst" and can only # be used for SG graphs due to that assumption. if not input_graph.edgelist: @@ -139,20 +138,4 @@ cdef GraphCOOViewType get_coo_graph_view(input_graph, bool weighted=True, GraphC if input_graph.edgelist.weights and weighted: c_weights = input_graph.edgelist.edgelist_df['weights'].__cuda_array_interface__['data'][0] - cdef GraphCOOViewType in_graph - if GraphCOOViewType is GraphCOOViewFloat: - in_graph = GraphCOOViewFloat(c_src, c_dst, c_weights, num_verts, num_edges) - elif GraphCOOViewType is GraphCOOViewDouble: - in_graph = GraphCOOViewDouble(c_src, c_dst, c_weights, num_verts, num_edges) - return in_graph - - -cdef GraphViewType get_graph_view(input_graph, bool weighted = True, GraphViewType* dummy=NULL): - if GraphViewType is GraphCOOViewFloat: - return get_coo_graph_view[GraphCOOViewFloat](input_graph, weighted, dummy) - elif GraphViewType is GraphCOOViewDouble: - return get_coo_graph_view[GraphCOOViewDouble](input_graph, weighted, dummy) - elif GraphViewType is GraphCSRViewFloat: - return get_csr_graph_view[GraphCSRViewFloat](input_graph, weighted, dummy) - elif GraphViewType is GraphCSRViewDouble: - return get_csr_graph_view[GraphCSRViewDouble](input_graph, weighted, dummy) + return GraphCOOViewDouble(c_src, c_dst, c_weights, num_verts, num_edges)