Add compact Ancestry trees using Buchheim/Walker algorithm

This enhancement adds a new 'compact' field to the Narrated
Web Report. A compact tree is one that is not a simple binary
layout but uses the algorithm of Buchheim/Walker to create a
layout that is sensible but also compact.

Creating a compact layout is slower than a simple binary
tree but the results are significantly improved and do not leave
large areas of whitespace where there are no nodes to be shown.
This commit is contained in:
Paul D.Smith
2018-02-16 13:40:16 +00:00
committed by Nick Hall
parent acfbb0a763
commit 03a89c73e3
7 changed files with 583 additions and 134 deletions

@@ -166,15 +166,36 @@ class MediaPages(BasePage):
gc.collect() # Reduce memory usage when many images.
if index == media_count:
next_ = None
elif index < total:
next_ = sorted_media_handles[index]
elif len(self.unused_media_handles) > 0:
next_ = self.unused_media_handles[0]
else:
next_ = self.unused_media_handles[idx]
next_ = None
self.mediapage(self.report, title,
media_handle,
(prev, next_, index, media_count))
prev = media_handle
handle, (prev, next_, index, media_count))
prev = handle
step()
index += 1
idx += 1
total = len(self.unused_media_handles)
idx = 1
prev = sorted_media_handles[len(sorted_media_handles)-1]
if total > 0:
for media_handle in self.unused_media_handles:
media = self.r_db.get_media_from_handle(media_handle)
gc.collect() # Reduce memory usage when many images.
if index == media_count:
next_ = None
else:
next_ = self.unused_media_handles[idx]
self.mediapage(self.report, title,
media_handle,
(prev, next_, index, media_count))
prev = media_handle
step()
index += 1
idx += 1
self.medialistpage(self.report, title, sorted_media_handles)