@@ -13,6 +13,10 @@ class Graph:
1313 def __init__ (self , name , redis_con = None , host = 'localhost' , port = 6379 , password = None ):
1414 """
1515 Create a new graph.
16+
17+ Args:
18+ name: string that represents the name of the graph
19+ redis_con: connection to Redis
1620 """
1721 self .name = name # Graph key
1822 if redis_con is not None :
@@ -63,6 +67,12 @@ def _refresh_attributes(self):
6367 self ._properties [i ] = p [0 ]
6468
6569 def get_label (self , idx ):
70+ """
71+ Returns a label by it's index
72+
73+ Args:
74+ idx: The index of the label
75+ """
6676 try :
6777 label = self ._labels [idx ]
6878 except IndexError :
@@ -72,6 +82,12 @@ def get_label(self, idx):
7282 return label
7383
7484 def get_relation (self , idx ):
85+ """
86+ Returns a relationship type by it's index
87+
88+ Args:
89+ idx: The index of the relation
90+ """
7591 try :
7692 relationshipType = self ._relationshipTypes [idx ]
7793 except IndexError :
@@ -81,6 +97,12 @@ def get_relation(self, idx):
8197 return relationshipType
8298
8399 def get_property (self , idx ):
100+ """
101+ Returns a property by it's index
102+
103+ Args:
104+ idx: The index of the property
105+ """
84106 try :
85107 propertie = self ._properties [idx ]
86108 except IndexError :
@@ -134,7 +156,7 @@ def flush(self):
134156 self .nodes = {}
135157 self .edges = []
136158
137- def build_params_header (self , params ):
159+ def _build_params_header (self , params ):
138160 if not isinstance (params , dict ):
139161 raise TypeError ("'params' must be a dict" )
140162 # Header starts with "CYPHER"
@@ -152,14 +174,20 @@ def build_params_header(self, params):
152174 def query (self , q , params = None , timeout = None , read_only = False ):
153175 """
154176 Executes a query against the graph.
177+
178+ Args:
179+ q: the query
180+ params: query parameters
181+ timeout: maximum runtime for read queries in milliseconds
182+ read_only: executes a readonly query if set to True
155183 """
156184
157185 # maintain original 'q'
158186 query = q
159187
160188 # handle query parameters
161189 if params is not None :
162- query = self .build_params_header (params ) + query
190+ query = self ._build_params_header (params ) + query
163191
164192 # construct query command
165193 # ask for compact result-set format
@@ -200,9 +228,13 @@ def execution_plan(self, query, params=None):
200228 """
201229 Get the execution plan for given query,
202230 GRAPH.EXPLAIN returns an array of operations.
231+
232+ Args:
233+ query: the query that will be executed
234+ params: query parameters
203235 """
204236 if params is not None :
205- query = self .build_params_header (params ) + query
237+ query = self ._build_params_header (params ) + query
206238
207239 plan = self .redis_con .execute_command ("GRAPH.EXPLAIN" , self .name , query , query )
208240 return self ._execution_plan_to_string (plan )
0 commit comments