22
33from pandas import Series
44
5+ from ..error .deprecation_warning import deprecation_warning
56from ..error .illegal_attr_checker import IllegalAttrChecker
67from ..server_version .compatible_with import compatible_with
78from ..server_version .server_version import ServerVersion
89from .graph_object import Graph
910from .graph_type_check import from_graph_type_check
1011
1112
12- class GraphSampleRunner (IllegalAttrChecker ):
13+ class GraphAlphaSampleRunner (IllegalAttrChecker ):
1314 @compatible_with ("construct" , min_inclusive = ServerVersion (2 , 2 , 0 ))
15+ @deprecation_warning ("gds.graph.sample.rwr" , ServerVersion (2 , 4 , 0 ))
1416 @from_graph_type_check
1517 def rwr (self , graph_name : str , from_G : Graph , ** config : Any ) -> Tuple [Graph , "Series[Any]" ]:
16- self ._namespace += ".rwr"
18+ runner = RWRRunner (self ._query_runner , self ._namespace + ".rwr" , self ._server_version )
19+ return runner (graph_name , from_G , ** config )
20+
21+
22+ class GraphSampleRunner (IllegalAttrChecker ):
23+ @property
24+ def rwr (self ) -> "RWRRunner" :
25+ return RWRRunner (self ._query_runner , self ._namespace + ".rwr" , self ._server_version )
26+
27+ @property
28+ def cnarw (self ) -> "CNARWRunner" :
29+ return CNARWRunner (self ._query_runner , self ._namespace + ".cnarw" , self ._server_version )
1730
31+
32+ class RWRRunner (IllegalAttrChecker ):
33+ @compatible_with ("construct" , min_inclusive = ServerVersion (2 , 2 , 0 ))
34+ @from_graph_type_check
35+ def __call__ (self , graph_name : str , from_G : Graph , ** config : Any ) -> Tuple [Graph , "Series[Any]" ]:
1836 query = f"CALL { self ._namespace } ($graph_name, $from_graph_name, $config)"
1937 params = {
2038 "graph_name" : graph_name ,
@@ -26,10 +44,6 @@ def rwr(self, graph_name: str, from_G: Graph, **config: Any) -> Tuple[Graph, "Se
2644
2745 return Graph (graph_name , self ._query_runner , self ._server_version ), result
2846
29- @property
30- def cnarw (self ) -> "CNARWRunner" :
31- return CNARWRunner (self ._query_runner , self ._namespace + ".cnarw" , self ._server_version )
32-
3347
3448class CNARWRunner (IllegalAttrChecker ):
3549 @compatible_with ("construct" , min_inclusive = ServerVersion (2 , 4 , 0 ))
0 commit comments