Skip to content

Commit ffdfbe6

Browse files
committed
fix style
1 parent 32bb15c commit ffdfbe6

File tree

7 files changed

+80
-78
lines changed

7 files changed

+80
-78
lines changed

cpp/src/c_api/extract_vertex_list.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ struct extract_vertex_list_functor : public cugraph::c_api::abstract_functor {
4141
cugraph::c_api::cugraph_type_erased_device_array_t* result_{};
4242

4343
extract_vertex_list_functor(cugraph_resource_handle_t const* handle,
44-
cugraph_graph_t* graph,
45-
bool do_expensive_check)
44+
cugraph_graph_t* graph,
45+
bool do_expensive_check)
4646
: abstract_functor(),
4747
handle_(*reinterpret_cast<cugraph::c_api::cugraph_resource_handle_t const*>(handle)->handle_),
4848
graph_(reinterpret_cast<cugraph::c_api::cugraph_graph_t*>(graph)),
@@ -77,23 +77,19 @@ struct extract_vertex_list_functor : public cugraph::c_api::abstract_functor {
7777
auto number_map = reinterpret_cast<rmm::device_uvector<vertex_t>*>(graph_->number_map_);
7878

7979
rmm::device_uvector<vertex_t> vertex_list(number_map->size(), handle_.get_stream());
80-
81-
raft::copy(vertex_list.data(),
82-
number_map->data(),
83-
number_map->size(),
84-
handle_.get_stream());
85-
80+
81+
raft::copy(vertex_list.data(), number_map->data(), number_map->size(), handle_.get_stream());
82+
8683
cugraph::unrenumber_int_vertices<vertex_t, multi_gpu>(
8784
handle_,
8885
vertex_list.data(),
8986
vertex_list.size(),
9087
number_map->data(),
9188
graph_view.vertex_partition_range_lasts(),
9289
do_expensive_check_);
93-
94-
result_ = new cugraph::c_api::cugraph_type_erased_device_array_t(vertex_list,
95-
graph_->vertex_type_);
96-
90+
91+
result_ =
92+
new cugraph::c_api::cugraph_type_erased_device_array_t(vertex_list, graph_->vertex_type_);
9793
}
9894
}
9995
};

cpp/src/c_api/similarity.cpp

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ struct similarity_functor : public cugraph::c_api::abstract_functor {
133133
use_weight_ ? std::make_optional(edge_weights->view()) : std::nullopt,
134134
std::make_tuple(raft::device_span<vertex_t const>{v1.data(), v1.size()},
135135
raft::device_span<vertex_t const>{v2.data(), v2.size()}),
136-
do_expensive_check_
137-
);
136+
do_expensive_check_);
138137

139138
result_ = new cugraph::c_api::cugraph_similarity_result_t{
140139
new cugraph::c_api::cugraph_type_erased_device_array_t(similarity_coefficients,
@@ -205,42 +204,40 @@ struct all_pairs_similarity_functor : public cugraph::c_api::abstract_functor {
205204
auto number_map = reinterpret_cast<rmm::device_uvector<vertex_t>*>(graph_->number_map_);
206205

207206
std::optional<rmm::device_uvector<vertex_t>> vertices{std::nullopt};
208-
207+
209208
if (vertices_ != nullptr) {
210-
vertices =
211-
rmm::device_uvector<vertex_t>{vertices_->size_, handle_.get_stream()};
212-
213-
raft::copy(vertices->data(),
214-
vertices_->as_type<vertex_t>(),
215-
vertices_->size_,
216-
handle_.get_stream());
217-
218-
if constexpr (multi_gpu) {vertices = cugraph::shuffle_ext_vertices(handle_, std::move(*vertices)); }
219-
209+
vertices = rmm::device_uvector<vertex_t>{vertices_->size_, handle_.get_stream()};
210+
211+
raft::copy(
212+
vertices->data(), vertices_->as_type<vertex_t>(), vertices_->size_, handle_.get_stream());
213+
214+
if constexpr (multi_gpu) {
215+
vertices = cugraph::shuffle_ext_vertices(handle_, std::move(*vertices));
216+
}
217+
220218
//
221219
// Need to renumber vertices
222220
//
223221
cugraph::renumber_ext_vertices<vertex_t, multi_gpu>(
224-
handle_,
225-
vertices->data(),
226-
vertices->size(),
227-
number_map->data(),
228-
graph_view.local_vertex_partition_range_first(),
229-
graph_view.local_vertex_partition_range_last(),
230-
do_expensive_check_);
231-
}
232-
233-
auto [v1, v2, similarity_coefficients] =
234-
call_similarity_(handle_,
235-
graph_view,
236-
use_weight_ ? std::make_optional(edge_weights->view()) : std::nullopt,
237-
vertices_ != nullptr ? std::make_optional(raft::device_span<vertex_t const>{
238-
vertices->data(), vertices->size()})
239-
: std::nullopt,
240-
topk_ != SIZE_MAX ? std::make_optional(topk_) : std::nullopt,
241-
do_expensive_check_
242-
);
243-
222+
handle_,
223+
vertices->data(),
224+
vertices->size(),
225+
number_map->data(),
226+
graph_view.local_vertex_partition_range_first(),
227+
graph_view.local_vertex_partition_range_last(),
228+
do_expensive_check_);
229+
}
230+
231+
auto [v1, v2, similarity_coefficients] = call_similarity_(
232+
handle_,
233+
graph_view,
234+
use_weight_ ? std::make_optional(edge_weights->view()) : std::nullopt,
235+
vertices_ != nullptr ? std::make_optional(raft::device_span<vertex_t const>{
236+
vertices->data(), vertices->size()})
237+
: std::nullopt,
238+
topk_ != SIZE_MAX ? std::make_optional(topk_) : std::nullopt,
239+
do_expensive_check_);
240+
244241
cugraph::unrenumber_int_vertices<vertex_t, multi_gpu>(
245242
handle_,
246243
v1.data(),
@@ -276,7 +273,8 @@ struct jaccard_functor {
276273
std::tuple<raft::device_span<vertex_t const>, raft::device_span<vertex_t const>> vertex_pairs,
277274
bool do_expensive_check)
278275
{
279-
return cugraph::jaccard_coefficients(handle, graph_view, edge_weight_view, vertex_pairs, do_expensive_check);
276+
return cugraph::jaccard_coefficients(
277+
handle, graph_view, edge_weight_view, vertex_pairs, do_expensive_check);
280278
}
281279

282280
template <typename vertex_t, typename edge_t, typename weight_t, bool multi_gpu>
@@ -304,7 +302,8 @@ struct sorensen_functor {
304302
std::tuple<raft::device_span<vertex_t const>, raft::device_span<vertex_t const>> vertex_pairs,
305303
bool do_expensive_check)
306304
{
307-
return cugraph::sorensen_coefficients(handle, graph_view, edge_weight_view, vertex_pairs, do_expensive_check);
305+
return cugraph::sorensen_coefficients(
306+
handle, graph_view, edge_weight_view, vertex_pairs, do_expensive_check);
308307
}
309308

310309
template <typename vertex_t, typename edge_t, typename weight_t, bool multi_gpu>
@@ -361,7 +360,8 @@ struct overlap_functor {
361360
std::tuple<raft::device_span<vertex_t const>, raft::device_span<vertex_t const>> vertex_pairs,
362361
bool do_expensive_check)
363362
{
364-
return cugraph::overlap_coefficients(handle, graph_view, edge_weight_view, vertex_pairs, do_expensive_check);
363+
return cugraph::overlap_coefficients(
364+
handle, graph_view, edge_weight_view, vertex_pairs, do_expensive_check);
365365
}
366366

367367
template <typename vertex_t, typename edge_t, typename weight_t, bool multi_gpu>

python/cugraph/cugraph/structure/graph_classes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ def from_cudf_edgelist(
182182
If the incoming edgelist is intended for an undirected graph and it is
183183
known to be symmetric, this flag can be set to False to skip the
184184
symmetrization step for better performance.
185-
185+
186186
vertices : cudf.Series or List, optional (default=None)
187187
An containing all vertices of the graph. This array is
188188
optional, but must be used if the graph contains isolated vertices
189-
which cannot be represented in the source and destination arrays.
189+
which cannot be represented in the source and destination arrays.
190190
If specified, this array must contain every vertex identifier,
191191
including vertex identifiers that are already included in the
192192
source and destination arrays.

python/cugraph/cugraph/structure/graph_implementation/simpleGraph.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def __from_edgelist(
136136
renumber=True,
137137
store_transposed=False,
138138
symmetrize=None,
139-
vertices=None
139+
vertices=None,
140140
):
141141

142142
if self.properties.directed and symmetrize:
@@ -311,14 +311,16 @@ def __from_edgelist(
311311

312312
if self.batch_enabled:
313313
self._replicate_edgelist()
314-
314+
315315
if vertices is not None:
316316
if self.properties.renumbered is True:
317317
if isinstance(vertices, cudf.Series):
318-
vertices = self.lookup_internal_vertex_id(vertices, vertices.columns)
318+
vertices = self.lookup_internal_vertex_id(
319+
vertices, vertices.columns
320+
)
319321
else:
320322
vertices = self.lookup_internal_vertex_id(cudf.Series(vertices))
321-
323+
322324
if not isinstance(vertices, cudf.Series):
323325
vertex_dtype = self.edgelist.edgelist_df[simpleGraphImpl.srcCol].dtype
324326
vertices = cudf.Series(vertices, dtype=vertex_dtype)
@@ -329,7 +331,7 @@ def __from_edgelist(
329331
renumber=renumber,
330332
drop_multi_edges=not self.properties.multi_edge,
331333
symmetrize=symmetrize,
332-
vertices=vertices
334+
vertices=vertices,
333335
)
334336

335337
def to_pandas_edgelist(
@@ -892,7 +894,7 @@ def decompress_to_edgelist(
892894
df, _ = self.renumber_map.unrenumber(df, "dst", get_column_names=True)
893895

894896
return df
895-
897+
896898
def extract_vertex_list(
897899
self, return_unrenumbered_vertices: bool = True
898900
) -> cudf.DataFrame:
@@ -923,14 +925,14 @@ def extract_vertex_list(
923925

924926
do_expensive_check = False
925927
vertices = pylibcugraph_extract_vertex_list(
926-
resource_handle=ResourceHandle(),
927-
graph=self._plc_graph,
928-
do_expensive_check=do_expensive_check)
928+
resource_handle=ResourceHandle(),
929+
graph=self._plc_graph,
930+
do_expensive_check=do_expensive_check,
931+
)
929932

930933
vertices = cudf.Series(
931-
vertices,
932-
dtype=self.edgelist.edgelist_df[simpleGraphImpl.srcCol].dtype)
933-
934+
vertices, dtype=self.edgelist.edgelist_df[simpleGraphImpl.srcCol].dtype
935+
)
934936

935937
if self.properties.renumbered and return_unrenumbered_vertices:
936938
df_ = cudf.DataFrame()
@@ -1313,9 +1315,9 @@ def _make_plc_graph(
13131315
renumber: bool = True,
13141316
drop_multi_edges: bool = False,
13151317
symmetrize: bool = False,
1316-
vertices: cudf.Series = None
1318+
vertices: cudf.Series = None,
13171319
):
1318-
1320+
13191321
"""
13201322
Parameters
13211323
----------
@@ -1547,7 +1549,7 @@ def nodes(self):
15471549
if self.edgelist is not None:
15481550
# Retrieve the vertex list
15491551
return self.extract_vertex_list(return_unrenumbered_vertices=False)
1550-
1552+
15511553
if self.adjlist is not None:
15521554
return cudf.Series(np.arange(0, self.number_of_nodes()))
15531555

python/cugraph/cugraph/tests/structure/test_graph.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -649,16 +649,20 @@ def test_number_of_edges():
649649

650650
@pytest.mark.sg
651651
def test_vertex_list():
652-
A = np.array([[0., 0., 0., 0., 0., 0., 0., 1., 0., 0.],
653-
[0., 0., 0., 0., 0., 1., 0., 0., 1., 0.],
654-
[0., 0., 0., 0., 0., 0., 0., 1., 0., 0.],
655-
[0., 0., 0., 0., 0., 0., 0., 1., 0., 0.],
656-
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
657-
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
658-
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
659-
[0., 0., 0., 0., 0., 0., 0., 1., 0., 0.],
660-
[0., 0., 0., 0., 0., 0., 0., 1., 0., 0.],
661-
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
652+
A = np.array(
653+
[
654+
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0],
655+
[0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0],
656+
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0],
657+
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0],
658+
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
659+
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
660+
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
661+
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0],
662+
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0],
663+
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
664+
]
665+
)
662666

663667
G = nx.from_numpy_array(A)
664668
cG = cugraph.from_numpy_array(nx.to_numpy_array(G))

python/pylibcugraph/pylibcugraph/_cugraph_c/graph_functions.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ cdef extern from "cugraph_c/graph_functions.h":
320320
bool_t do_expensive_check,
321321
cugraph_type_erased_device_array_t** result,
322322
cugraph_error_t** error)
323-
323+
324324
###########################################################################
325325
# extract vertex list
326326
cdef cugraph_error_code_t \

python/pylibcugraph/pylibcugraph/extract_vertex_list.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023-2024, NVIDIA CORPORATION.
1+
# Copyright (c) 2025, NVIDIA CORPORATION.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -37,7 +37,7 @@ from pylibcugraph._cugraph_c.graph cimport (
3737
from pylibcugraph._cugraph_c.graph_functions cimport (
3838
cugraph_edgelist_t,
3939
cugraph_extract_vertex_list,
40-
40+
4141
)
4242

4343
from pylibcugraph.resource_handle cimport (

0 commit comments

Comments
 (0)