Skip to content

Commit

Permalink
Implemented/added several more graph methods
Browse files Browse the repository at this point in the history
  • Loading branch information
JackAtOmenApps committed Nov 22, 2020
1 parent bbf12ca commit c18ca54
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions django_postgresql_dag/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,26 +239,36 @@ def is_island(self):
"""
return bool(not self.children.exists() and not self.parents.exists())

def is_descendant_of(self, target):
# ToDo: Implement
pass
def is_ancestor_of(self, ending_node, **kwargs):
try:
return len(self.path_raw(ending_node, **kwargs)) >= 1
except NodeNotReachableException:
return False

def is_descendant_of(self, ending_node, **kwargs):
return (
not self.is_ancestor_of(ending_node, **kwargs)
and len(self.path_raw(ending_node, directional=False, **kwargs)) >= 1
)

def is_ancestor_of(self, target):
# ToDo: Implement
pass
def is_sibling_of(self, ending_node):
return ending_node in self.siblings()

def is_sibling_of(self, target):
# ToDo: Implement
pass
def is_partner_of(self, ending_node):
return ending_node in self.partners()

def node_depth(self):
# Depth from furthest root
# ToDo: Implement
pass

def entire_graph(self):
def connected_graph_raw(self, **kwargs):
# Gets all nodes connected in any way to this node
pass
return ConnectedGraphQuery(instance=self, **kwargs).raw_queryset()

def connected_graph(self, **kwargs):
pks = [item.pk for item in self.connected_graph_raw(**kwargs)]
return self.ordered_queryset_from_pks(pks)

def descendants_tree(self):
"""
Expand Down Expand Up @@ -364,6 +374,7 @@ def circular_checker(parent, child):
return Node



class EdgeManager(models.Manager):
def from_nodes_queryset(self, nodes_queryset):
"""Provided a queryset of nodes, returns all edges where a parent and child
Expand Down

0 comments on commit c18ca54

Please sign in to comment.