Skip to content

Commit

Permalink
all-connected optimization
Browse files Browse the repository at this point in the history
  - check for processed person
  - remove excess method (add_spouses_connected)
  • Loading branch information
vantu5z committed Mar 19, 2021
1 parent 8eb3252 commit 18658a5
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions GraphView/graphview.py
Original file line number Diff line number Diff line change
Expand Up @@ -2548,6 +2548,8 @@ def add_connected(self, person, num_desc, num_anc, person_handles):
if num_desc > 0: # generation restriction
# add every child recursively
for child_ref in family.get_child_ref_list():
if child_ref.ref in person_handles:
continue
self.add_connected(
self.database.get_person_from_handle(child_ref.ref),
num_desc-1, num_anc+1, person_handles)
Expand All @@ -2569,28 +2571,10 @@ def add_connected(self, person, num_desc, num_anc, person_handles):
for sp_handle in (family.get_father_handle(),
family.get_mother_handle()):
if sp_handle and sp_handle not in person_handles:
self.add_spouses_connected(
self.add_connected(
self.database.get_person_from_handle(sp_handle),
num_desc+1, num_anc-1, person_handles)

def add_spouses_connected(self, person, num_desc, num_anc,
person_handles):
"""
Add spouses to the list for all connected variant.
"""
if not person:
return

for family_handle in person.get_family_handle_list():
sp_family = self.database.get_family_from_handle(family_handle)

for sp_handle in (sp_family.get_father_handle(),
sp_family.get_mother_handle()):
if sp_handle and sp_handle not in person_handles:
self.add_connected(
self.database.get_person_from_handle(sp_handle),
num_desc, num_anc, person_handles)

def find_descendants(self, active_person):
"""
Spider the database from the active person.
Expand Down

0 comments on commit 18658a5

Please sign in to comment.