@@ -239,26 +239,36 @@ def is_island(self):
239
239
"""
240
240
return bool (not self .children .exists () and not self .parents .exists ())
241
241
242
- def is_descendant_of (self , target ):
243
- # ToDo: Implement
244
- pass
242
+ def is_ancestor_of (self , ending_node , ** kwargs ):
243
+ try :
244
+ return len (self .path_raw (ending_node , ** kwargs )) >= 1
245
+ except NodeNotReachableException :
246
+ return False
247
+
248
+ def is_descendant_of (self , ending_node , ** kwargs ):
249
+ return (
250
+ not self .is_ancestor_of (ending_node , ** kwargs )
251
+ and len (self .path_raw (ending_node , directional = False , ** kwargs )) >= 1
252
+ )
245
253
246
- def is_ancestor_of (self , target ):
247
- # ToDo: Implement
248
- pass
254
+ def is_sibling_of (self , ending_node ):
255
+ return ending_node in self .siblings ()
249
256
250
- def is_sibling_of (self , target ):
251
- # ToDo: Implement
252
- pass
257
+ def is_partner_of (self , ending_node ):
258
+ return ending_node in self .partners ()
253
259
254
260
def node_depth (self ):
255
261
# Depth from furthest root
256
262
# ToDo: Implement
257
263
pass
258
264
259
- def entire_graph (self ):
265
+ def connected_graph_raw (self , ** kwargs ):
260
266
# Gets all nodes connected in any way to this node
261
- pass
267
+ return ConnectedGraphQuery (instance = self , ** kwargs ).raw_queryset ()
268
+
269
+ def connected_graph (self , ** kwargs ):
270
+ pks = [item .pk for item in self .connected_graph_raw (** kwargs )]
271
+ return self .ordered_queryset_from_pks (pks )
262
272
263
273
def descendants_tree (self ):
264
274
"""
@@ -364,6 +374,7 @@ def circular_checker(parent, child):
364
374
return Node
365
375
366
376
377
+
367
378
class EdgeManager (models .Manager ):
368
379
def from_nodes_queryset (self , nodes_queryset ):
369
380
"""Provided a queryset of nodes, returns all edges where a parent and child
0 commit comments