Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 14, Issue 81 #85

Merged
merged 5 commits into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions cpp/src/cugraph.cu
Original file line number Diff line number Diff line change
Expand Up @@ -320,23 +320,20 @@ 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;
return GDF_SUCCESS;
}
gdf_error gdf_delete_edge_list(gdf_graph *graph) {
if (graph->edgeList) {
graph->edgeList->ownership = 1;
delete graph->edgeList;
}
graph->edgeList = nullptr;
return GDF_SUCCESS;
}
gdf_error gdf_delete_transpose(gdf_graph *graph) {
if (graph->transposedAdjList) {
graph->transposedAdjList->ownership = 1;
delete graph->transposedAdjList;
}
graph->transposedAdjList = nullptr;
Expand Down
26 changes: 1 addition & 25 deletions python/cugraph/graph/c_graph.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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.
Expand Down
25 changes: 6 additions & 19 deletions python/cugraph/graph/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand All @@ -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'

'''

2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

107 changes: 0 additions & 107 deletions setup.py

This file was deleted.