Unverified Commit 0ac9bf34 authored by Hongzhi (Steve), Chen's avatar Hongzhi (Steve), Chen Committed by GitHub
Browse files

Rename number_of_nodes, number_of_edges to num_nodes, num_edges. (#5486)



* Add num_nodes/num_edges

* additional

* Update python/dgl/graph_index.py
Co-authored-by: default avatarMufei Li <mufeili1996@gmail.com>

* Apply suggestions from code review
Co-authored-by: default avatarMufei Li <mufeili1996@gmail.com>

---------
Co-authored-by: default avatarUbuntu <ubuntu@ip-172-31-28-63.ap-northeast-1.compute.internal>
Co-authored-by: default avatarMufei Li <mufeili1996@gmail.com>
parent 097fd6db
......@@ -161,6 +161,27 @@ class GraphIndex(ObjectBase):
state = (n_nodes, readonly_state, src, dst)
self.__setstate__(state)
def num_nodes(self):
"""Return the number of nodes.
Returns
-------
int
The number of nodes.
"""
return _CAPI_DGLGraphNumVertices(self)
def num_edges(self):
"""Return the number of edges.
Returns
-------
int
The number of edges.
"""
return _CAPI_DGLGraphNumEdges(self)
# TODO(#5485): remove this method.
def number_of_nodes(self):
"""Return the number of nodes.
......@@ -171,6 +192,7 @@ class GraphIndex(ObjectBase):
"""
return _CAPI_DGLGraphNumVertices(self)
# TODO(#5485): remove this method.
def number_of_edges(self):
"""Return the number of edges.
......
......@@ -359,6 +359,37 @@ class HeteroGraphIndex(ObjectBase):
"""
return bool(_CAPI_DGLHeteroIsReadonly(self))
def num_nodes(self, ntype):
"""Return the number of nodes.
Parameters
----------
ntype : int
Node type.
Returns
-------
int
The number of nodes.
"""
return _CAPI_DGLHeteroNumVertices(self, int(ntype))
def num_edges(self, etype):
"""Return the number of edges.
Parameters
----------
etype : int
Edge type.
Returns
-------
int
The number of edges.
"""
return _CAPI_DGLHeteroNumEdges(self, int(etype))
# TODO(#5485): remove this method.
def number_of_nodes(self, ntype):
"""Return the number of nodes.
......@@ -374,6 +405,7 @@ class HeteroGraphIndex(ObjectBase):
"""
return _CAPI_DGLHeteroNumVertices(self, int(ntype))
# TODO(#5485): remove this method.
def number_of_edges(self, etype):
"""Return the number of edges.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment