cugraph.structure.graph_implementation.simpleGraphImpl.degree#
- simpleGraphImpl.degree(vertex_subset: Optional[Union[Series, Iterable]] = None) DataFrame [source]#
Compute vertex degree, which is the total number of edges incident to a vertex (both in and out edges). By default, this method computes degrees for the entire set of vertices. If vertex_subset is provided, then this method optionally filters out all but those listed in vertex_subset.
- Parameters:
- vertex_subsetcudf.Series or iterable container, optional
a container of vertices for displaying corresponding degree. If not set, degrees are computed for the entire set of vertices.
- Returns:
- dfcudf.DataFrame
GPU DataFrame of size N (the default) or the size of the given vertices (vertex_subset) containing the degree. The ordering is relative to the adjacency list, or that given by the specified vertex_subset.
- df[‘vertex’]cudf.Series
The vertex IDs (will be identical to vertex_subset if specified).
- df[‘degree’]cudf.Series
The computed degree of the corresponding vertex.
Examples
>>> M = cudf.read_csv(datasets_path / 'karate.csv', delimiter=' ', ... dtype=['int32', 'int32', 'float32'], header=None) >>> G = cugraph.Graph() >>> G.from_cudf_edgelist(M, '0', '1') >>> all_df = G.degree() >>> subset_df = G.degree([0,9,12])