Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
645ea76
rename 'triangle_count' to 'triangles' in the init file to match the …
jnke2016 Sep 8, 2022
dd254e2
promote 'triangle_count' and remove experimental prefix
jnke2016 Sep 8, 2022
2415fc9
remove experimental prefix
jnke2016 Sep 8, 2022
0b55d28
replace legacy implementation by the new one, lift restriction on 'in…
jnke2016 Sep 8, 2022
e0cb1a1
update docstrings
jnke2016 Sep 8, 2022
c0632d2
rename 'triangle_count' to 'triangles' to match legacy and sg impleme…
jnke2016 Sep 8, 2022
2dd096c
remove legacy implementation from the tests, enable tests with the pa…
jnke2016 Sep 8, 2022
6d2e905
update MG tests according to the changes made to SG
jnke2016 Sep 8, 2022
18eb061
remove triangle_count legacy implementation
jnke2016 Sep 8, 2022
165d4a2
remove the new implementation of 'triangle_count' from experimental a…
jnke2016 Sep 8, 2022
a1bd709
update CMakelist
jnke2016 Sep 8, 2022
bedf5e4
fix style
jnke2016 Sep 8, 2022
95cf3e6
add support for the parameter 'start_list'
jnke2016 Sep 8, 2022
241ed65
enable tests for the parameter 'start_list'
jnke2016 Sep 8, 2022
8cc1173
remove outdated FIXME
jnke2016 Sep 8, 2022
18b9854
remove 'promoted_experimental_warning_wrapper' from stable API
jnke2016 Sep 8, 2022
7d5cc0d
remove 'promoted_experimental_warning_wrapper' from stable API
jnke2016 Sep 8, 2022
b10c51d
wrap experimental.triangle_count with 'promoted_experimental_warning_…
jnke2016 Sep 8, 2022
ec32648
add a test ensuring that a warning is raised when calling experimenta…
jnke2016 Sep 8, 2022
5f950bf
remove pylibcugraph 'triangle_count' from experimental as it is stable
jnke2016 Sep 8, 2022
fa91570
revert the change on the name
jnke2016 Sep 8, 2022
3b715ea
update notebook to use the stable version of triangle_count
jnke2016 Sep 8, 2022
d03b752
update docstring example
jnke2016 Sep 8, 2022
3ca9472
fix style
jnke2016 Sep 8, 2022
37d3edd
clear output from the notebook
jnke2016 Sep 8, 2022
99543e5
Merge remote-tracking branch 'upstream/branch-22.10' into branch-22.1…
jnke2016 Sep 8, 2022
8fa6f11
remove unnecassary sorting and renaming of column
jnke2016 Sep 8, 2022
d97c34f
fix copyright
jnke2016 Sep 8, 2022
38a2702
update triangle_count import
jnke2016 Sep 9, 2022
c092d95
update algo's name
jnke2016 Sep 9, 2022
15ce41c
remove outdated FIXME
jnke2016 Sep 9, 2022
125c306
fix indent
jnke2016 Sep 9, 2022
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
4 changes: 1 addition & 3 deletions benchmarks/python_e2e/cugraph_dask_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,9 @@ def uniform_neighbor_sample(G, start_list=None, fanout_vals=None):
G, start_list=start_list, fanout_vals=fanout_vals)

def triangle_count(G):
# FIXME: Update this calls once triangle_count is promoted
return cugraph.dask.triangle_count(G)
return cugraph.dask.triangles(G)

def eigenvector_centrality(G):
# FIXME: Update this calls once triangle_count is promoted
return cugraph.dask.eigenvector_centrality(G)

################################################################################
Expand Down
4 changes: 1 addition & 3 deletions benchmarks/python_e2e/cugraph_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,9 @@ def uniform_neighbor_sample(G, start_list=None, fanout_vals=None):
G, start_list=start_list, fanout_vals=fanout_vals)

def triangle_count(G):
# FIXME: Update this calls once triangle_count is promoted
return cugraph.experimental.triangle_count(G)
return cugraph.triangles(G)

def eigenvector_centrality(G):
# FIXME: Update this calls once triangle_count is promoted
return cugraph.eigenvector_centrality(G)

################################################################################
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/python_pytest_based/bench_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ def bench_overlap(gpubenchmark, anyGraphWithAdjListComputed):
gpubenchmark(cugraph.overlap, anyGraphWithAdjListComputed)


def bench_triangles(gpubenchmark, graphWithAdjListComputed):
gpubenchmark(cugraph.triangles, graphWithAdjListComputed)
def bench_triangle_count(gpubenchmark, graphWithAdjListComputed):
gpubenchmark(cugraph.triangle_count, graphWithAdjListComputed)


def bench_spectralBalancedCutClustering(gpubenchmark,
Expand Down
19 changes: 7 additions & 12 deletions notebooks/algorithms/community/Triangle-Counting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"import cugraph\n",
"import cudf\n",
"from collections import OrderedDict\n",
"from cugraph.experimental import triangle_count as experimental_triangles\n",
"\n",
"# Import a built-in dataset\n",
"from cugraph.experimental.datasets import karate"
Expand Down Expand Up @@ -230,19 +229,15 @@
"outputs": [],
"source": [
"# Call cugraph triangles to get the triangles that each vertex is included in.\n",
"triangles_per_vertex = experimental_triangles(G)"
"triangles_per_vertex = cugraph.triangle_count(G)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"triangles_per_vertex.sort_values(\n",
" \"vertex\").reset_index(drop=True).rename(columns={\n",
" \"counts\": \"exp_cugraph_counts\"})"
]
"source": []
},
{
"cell_type": "markdown",
Expand All @@ -257,9 +252,9 @@
"metadata": {},
"outputs": [],
"source": [
"cugraph_exp_triangle_results = \\\n",
"cugraph_triangle_results = \\\n",
" triangles_per_vertex[\"counts\"].sum()\n",
"cugraph_exp_triangle_results\n"
"cugraph_triangle_results\n"
]
},
{
Expand Down Expand Up @@ -287,7 +282,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.6.9 64-bit",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -301,7 +296,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.9.13-final"
},
"vscode": {
"interpreter": {
Expand All @@ -311,4 +306,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
2 changes: 1 addition & 1 deletion python/cugraph/cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
analyzeClustering_edge_cut,
analyzeClustering_ratio_cut,
subgraph,
triangles,
triangle_count,
ego_graph,
batched_ego_graphs,
)
Expand Down
1 change: 0 additions & 1 deletion python/cugraph/cugraph/community/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ set(cython_sources
louvain_wrapper.pyx
spectral_clustering_wrapper.pyx
subgraph_extraction_wrapper.pyx
triangle_count_wrapper.pyx
)

set(linked_libraries cugraph::cugraph)
Expand Down
4 changes: 2 additions & 2 deletions python/cugraph/cugraph/community/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Copyright (c) 2019-2022, 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
Expand All @@ -22,7 +22,7 @@
analyzeClustering_ratio_cut,
)
from cugraph.community.subgraph_extraction import subgraph
from cugraph.community.triangle_count import triangles
from cugraph.community.triangle_count import triangle_count
from cugraph.community.ktruss_subgraph import ktruss_subgraph
from cugraph.community.ktruss_subgraph import k_truss
from cugraph.community.egonet import ego_graph
Expand Down
26 changes: 0 additions & 26 deletions python/cugraph/cugraph/community/triangle_count.pxd

This file was deleted.

77 changes: 59 additions & 18 deletions python/cugraph/cugraph/community/triangle_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,89 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from cugraph.community import triangle_count_wrapper
from cugraph.utilities import ensure_cugraph_obj_for_nx
import warnings
import cudf

from pylibcugraph import triangle_count as pylibcugraph_triangle_count

def triangles(G):
from pylibcugraph import ResourceHandle


def triangle_count(G, start_list=None):
"""
Compute the number of triangles (cycles of length three) in the
input graph.

Unlike NetworkX, this algorithm simply returns the total number of
triangle and not the number per vertex.

Parameters
----------
G : cugraph.graph or networkx.Graph
cuGraph graph descriptor, should contain the connectivity information,
(edge weights are not used in this algorithm).
The current implementation only supports undirected graphs.

start_list : list or cudf.Series
list of vertices for triangle count. if None the entire set of vertices
in the graph is processed

Returns
-------
count : int64
A 64 bit integer whose value gives the number of triangles in the
graph.
result : cudf.DataFrame
GPU data frame containing 2 cudf.Series

ddf['vertex']: cudf.Series
Contains the triangle counting vertices
ddf['counts']: cudf.Series
Contains the triangle counting counts

Examples
--------
>>> from cugraph.experimental.datasets import karate
>>> G = karate.get_graph(fetch=True)
>>> count = cugraph.triangles(G)
>>> gdf = cudf.read_csv(datasets_path / 'karate.csv',
... delimiter = ' ',
... dtype=['int32', 'int32', 'float32'],
... header=None)
>>> G = cugraph.Graph()
>>> G.from_cudf_edgelist(gdf, source='0', destination='1', edge_attr='2')
>>> count = cugraph.triangle_count(G)

"""
warning_msg = ("This call is deprecated and will be refactored "
"in the next release")
warnings.warn(warning_msg, PendingDeprecationWarning)

G, _ = ensure_cugraph_obj_for_nx(G)

if G.is_directed():
raise ValueError("input graph must be undirected")

result = triangle_count_wrapper.triangles(G)
if start_list is not None:
if isinstance(start_list, int):
start_list = [start_list]
if isinstance(start_list, list):
start_list = cudf.Series(start_list)

if not isinstance(start_list, cudf.Series):
raise TypeError(
f"'start_list' must be either a list or a cudf.Series,"
f"got: {start_list.dtype}")

if G.renumbered is True:
if isinstance(start_list, cudf.DataFrame):
start_list = G.lookup_internal_vertex_id(
start_list, start_list.columns)
else:
start_list = G.lookup_internal_vertex_id(start_list)

do_expensive_check = False

vertex, counts = \
pylibcugraph_triangle_count(
resource_handle=ResourceHandle(),
graph=G._plc_graph,
start_list=start_list,
do_expensive_check=do_expensive_check
)

df = cudf.DataFrame()
df["vertex"] = vertex
df["counts"] = counts

if G.renumbered:
df = G.unrenumber(df, "vertex")

return result
return df
51 changes: 0 additions & 51 deletions python/cugraph/cugraph/community/triangle_count_wrapper.pyx

This file was deleted.

18 changes: 5 additions & 13 deletions python/cugraph/cugraph/dask/community/triangle_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import dask_cudf
import cudf

from pylibcugraph.experimental import triangle_count as \
pylibcugraph_triangle_count
from pylibcugraph import triangle_count as pylibcugraph_triangle_count

from pylibcugraph import (ResourceHandle,
GraphProperties,
Expand Down Expand Up @@ -77,8 +76,7 @@ def convert_to_cudf(cp_arrays):
return df


def triangle_count(input_graph,
start_list=None):
def triangle_count(input_graph, start_list=None):
"""
Computes the number of triangles (cycles of length three) and the number
per vertex in the input graph.
Expand All @@ -90,7 +88,7 @@ def triangle_count(input_graph,
(edge weights are not used in this algorithm).
The current implementation only supports undirected graphs.

start_list : not supported
start_list : list or cudf.Series
list of vertices for triangle count. if None the entire set of vertices
in the graph is processed

Expand All @@ -105,8 +103,6 @@ def triangle_count(input_graph,
ddf['counts']: dask_cudf.Series
Contains the triangle counting counts
"""
# FIXME: start_list is disabled
start_list = None
if input_graph.is_directed():
raise ValueError("input graph must be undirected")
# Initialize dask client
Expand All @@ -122,9 +118,6 @@ def triangle_count(input_graph,
start_list = [start_list]
if isinstance(start_list, list):
start_list = cudf.Series(start_list)
if start_list.dtype != 'int32':
raise ValueError(f"'start_list' must have int32 values, "
f"got: {start_list.dtype}")
if not isinstance(start_list, cudf.Series):
raise TypeError(
f"'start_list' must be either a list or a cudf.Series,"
Expand All @@ -138,9 +131,8 @@ def triangle_count(input_graph,

ddf = input_graph.edgelist.edgelist_df

# FIXME: The parameter is_multigraph, store_transposed and
# do_expensive_check must be derived from the input_graph.
# For now, they are hardcoded.
# FIXME: The parameter is_multigraph and store_transposed must be derived
# from the input_graph. For now, they are hardcoded.
graph_properties = GraphProperties(
is_symmetric=True, is_multigraph=False)
store_transposed = False
Expand Down
Loading