diff --git a/CHANGELOG.md b/CHANGELOG.md index 777db64324f..0b0e6049948 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,10 +12,12 @@ - PR #67 RMM Integration with rmm as as submodule - PR #82 Spectral Clustering bindings - PR #82 Clustering metrics binding +- PR #85 Helper functions on python Graph object ## Improvements - PR #50 Reorganize directory structure to match cuDF +- PR #85 Deleted setup.py and setup.cfg which had been replaced ## Bug Fixes diff --git a/cpp/src/cugraph.cu b/cpp/src/cugraph.cu index c680df554b8..47f9ddf527f 100644 --- a/cpp/src/cugraph.cu +++ b/cpp/src/cugraph.cu @@ -320,7 +320,6 @@ gdf_error gdf_add_transpose(gdf_graph *graph) gdf_error gdf_delete_adj_list(gdf_graph *graph) { if (graph->adjList) { - graph->adjList->ownership = 1; delete graph->adjList; } graph->adjList = nullptr; @@ -328,7 +327,6 @@ gdf_error gdf_delete_adj_list(gdf_graph *graph) { } gdf_error gdf_delete_edge_list(gdf_graph *graph) { if (graph->edgeList) { - graph->edgeList->ownership = 1; delete graph->edgeList; } graph->edgeList = nullptr; @@ -336,7 +334,6 @@ gdf_error gdf_delete_edge_list(gdf_graph *graph) { } gdf_error gdf_delete_transpose(gdf_graph *graph) { if (graph->transposedAdjList) { - graph->transposedAdjList->ownership = 1; delete graph->transposedAdjList; } graph->transposedAdjList = nullptr; diff --git a/python/cugraph/graph/c_graph.pyx b/python/cugraph/graph/c_graph.pyx index b6f48d3d64f..ff5d97b396d 100755 --- a/python/cugraph/graph/c_graph.pyx +++ b/python/cugraph/graph/c_graph.pyx @@ -41,7 +41,7 @@ cdef create_column(col): class Graph: """ - cuGraph graph class containing basic graph creation and transformation operations. + cuGraph graph class containing basic graph creation and transformation operations. """ def __init__(self): """ @@ -139,30 +139,6 @@ class Graph: return cudf.Series(src_data), cudf.Series(dest_data) - def to_edge_list(self): - """ - Compute the edge list from adjacency list and return sources and destinations as cudf Series. - """ - cdef uintptr_t graph = self.graph_ptr - err = gdf_add_edge_list(< gdf_graph *> graph) - cudf.bindings.cudf_cpp.check_gdf_error(err) - - cdef gdf_graph * g = < gdf_graph *> graph - col_size = g.edgeList.src_indices.size - cdef uintptr_t src_col_data = < uintptr_t > g.edgeList.src_indices.data - cdef uintptr_t dest_col_data = < uintptr_t > g.edgeList.dest_indices.data - - src_data = rmm.device_array_from_ptr(src_col_data, - nelem=col_size, - dtype=np.int32) # , - # finalizer=rmm._make_finalizer(src_col_data, 0)) - dest_data = rmm.device_array_from_ptr(dest_col_data, - nelem=col_size, - dtype=np.int32) # , - # finalizer=rmm._make_finalizer(dest_col_data, 0)) - - return cudf.Series(src_data), cudf.Series(dest_data) - def delete_edge_list(self): """ Delete the edge list. diff --git a/python/cugraph/graph/test_graph.py b/python/cugraph/graph/test_graph.py index 368aa8c8bd7..4e32f9db545 100755 --- a/python/cugraph/graph/test_graph.py +++ b/python/cugraph/graph/test_graph.py @@ -15,12 +15,8 @@ import cudf import pytest import numpy as np -import networkx as nx from scipy.io import mmread -print ('Networkx version : {} '.format(nx.__version__)) - - def ReadMtxFile(mmFile): print('Reading '+ str(mmFile) + '...') return mmread(mmFile).asfptype() @@ -45,7 +41,8 @@ def compareOffsets(cu, np): return False return True -datasets = ['/datasets/networks/karate.mtx', '/datasets/golden_data/graphs/dblp.mtx'] +datasets = ['/datasets/networks/karate.mtx', '/datasets/networks/dolphins.mtx', '/datasets/networks/polbooks.mtx'] +#datasets = ['/datasets/networks/karate.mtx', '/datasets/golden_data/graphs/dblp.mtx'] @pytest.mark.parametrize('graph_file', datasets) def test_add_edge_list_to_adj_list(graph_file): @@ -89,7 +86,7 @@ def test_add_adj_list_to_edge_list(graph_file): # cugraph add_adj_list to_edge_list call G = cugraph.Graph() G.add_adj_list(offsets, indices, None) - sources, destinations = G.to_edge_list() + sources, destinations = G.view_edge_list() sources_cu = np.array(sources) destinations_cu = np.array(destinations) assert compare_series(sources_cu, sources_exp) @@ -124,21 +121,12 @@ def test_view_edge_list_from_adj_list(graph_file): assert compare_series(src1, src2) assert compare_series(dst1, dst2) -''' @pytest.mark.parametrize('graph_file', datasets) - def test_delete_edge_list_delete_adj_list(graph_file): - M = ReadMtxFile(graph_file) sources = cudf.Series(M.row) destinations = cudf.Series(M.col) - nnz_per_row = {r : 0 for r in range(M.get_shape()[0])} - for nnz in range(M.getnnz()): - nnz_per_row[M.row[nnz]] = 1 + nnz_per_row[M.row[nnz]] - for nnz in range(M.getnnz()): - M.data[nnz] = 1.0/float(nnz_per_row[M.row[nnz]]) - M = M.tocsr() if M is None : raise TypeError('Could not read the input graph') @@ -147,20 +135,19 @@ def test_delete_edge_list_delete_adj_list(graph_file): offsets = cudf.Series(M.indptr) indices = cudf.Series(M.indices) - #values = cudf.Series(np.ones(len(sources), dtype = np.float64)) # cugraph delete_adj_list delete_edge_list call G = cugraph.Graph() G.add_edge_list(sources, destinations, None) G.delete_edge_list() with pytest.raises(cudf.bindings.GDFError.GDFError) as excinfo: - G.to_adj_list() + G.view_adj_list() assert excinfo.value.errcode.decode() == 'GDF_INVALID_API_CALL' G.add_adj_list(offsets, indices, None) G.delete_adj_list() with pytest.raises(cudf.bindings.GDFError.GDFError) as excinfo: - G.to_edge_list() + G.view_edge_list() assert excinfo.value.errcode.decode() == 'GDF_INVALID_API_CALL' -''' + diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 4adefa346cd..00000000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -exclude = img,notebooks,thirdparty,__init__.py,libgdf,build \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index ee0abf99dc9..00000000000 --- a/setup.py +++ /dev/null @@ -1,107 +0,0 @@ -from os.path import join as pjoin -from setuptools import setup -from setuptools.extension import Extension -from Cython.Build import cythonize -import numpy -import os -import sys - -from distutils.sysconfig import get_python_lib - -install_requires = [ - 'numpy', - 'cython' -] - -def find_in_path(name, path): - "Find a file in a search path" - #adapted fom http://code.activestate.com/recipes/52224-find-a-file-given-a-search-path/ - for dir in path.split(os.pathsep): - binpath = pjoin(dir, name) - if os.path.exists(binpath): - return os.path.abspath(binpath) - return None - -def locate_cuda(): - """Locate the CUDA environment on the system - Returns a dict with keys 'home', 'nvcc', 'include', and 'lib64' - and values giving the absolute path to each directory. - Starts by looking for the CUDAHOME env variable. If not found, everything - is based on finding 'nvcc' in the PATH. - """ - - # first check if the CUDAHOME env variable is in use - if 'CUDAHOME' in os.environ: - home = os.environ['CUDAHOME'] - nvcc = pjoin(home, 'bin', 'nvcc') - else: - # otherwise, search the PATH for NVCC - nvcc = find_in_path('nvcc', os.environ['PATH']) - if nvcc is None: - raise EnvironmentError('The nvcc binary could not be ' - 'located in your $PATH. Either add it to your path, or set $CUDAHOME') - home = os.path.dirname(os.path.dirname(nvcc)) - - cudaconfig = {'home':home, 'nvcc':nvcc, - 'include': pjoin(home, 'include'), - 'lib64': pjoin(home, 'lib64')} - for k, v in iter(cudaconfig.items()): - if not os.path.exists(v): - raise EnvironmentError('The CUDA %s path could not be located in %s' % (k, v)) - - return cudaconfig - -def locate_nvgraph(): - if 'CONDA_PREFIX' in os.environ: - nvgraph_found = find_in_path('lib/libnvgraph_st.so', os.environ['CONDA_PREFIX']) - if nvgraph_found is None: - nvgraph_found = find_in_path('libnvgraph_st.so', os.environ['LD_LIBRARY_PATH']) - if nvgraph_found is None: - raise EnvironmentError('The nvgraph library could not be located') - nvgraph_config = {'include':pjoin(os.path.dirname(os.path.dirname(nvgraph_found)), 'include', 'nvgraph'), - 'lib':os.path.dirname(nvgraph_found)} - return nvgraph_config - -CUDA = locate_cuda() -NVGRAPH = locate_nvgraph() - -# Obtain the numpy include directory. This logic works across numpy versions. -try: - numpy_include = numpy.get_include() -except AttributeError: - numpy_include = numpy.get_numpy_include() - -# temporary fix. cudf 0.5 will have a cudf.get_include() -cudf_include = os.path.normpath(sys.prefix) + '/include' -cython_files = ['python/cugraph.pyx'] - -extensions = [ - Extension("cugraph", - sources=cython_files, - include_dirs=[numpy_include, - cudf_include, - NVGRAPH['include'], - CUDA['include'], - 'cpp/src', - 'cpp/include', - '../gunrock', - '../gunrock/externals/moderngpu/include', - '../gunrock/externals/cub'], - library_dirs=[get_python_lib(), NVGRAPH['lib']], - libraries=['nvgraph_st', 'cugraph', 'cudf'], - language='c++', - extra_compile_args=['-std=c++11']) -] - -setup(name='cugraph', - description='cuGraph - RAPIDS Graph Analytic Algorithms', - author='NVIDIA Corporation', - # todo: Add support for versioneer - version='0.1', - ext_modules=cythonize(extensions), - install_requires=install_requires, - license="Apache", - zip_safe=False) - - -