Commit b4b07b83 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent bf388552
......@@ -192,7 +192,28 @@ def Restructure(ztree, newStructure):
_bcheck(ztree) # verify ztree before our tweaks
# XXX ...
# walk original and new strucutres level by level.
# for each level we have A1...An "old" nodes, and B1...Bm "new" nodes.
# XXX buckets - push till end
# if n == m - map A-B 1-to-1
# if n < m - we have to "insert" (m-n) new nodes
# if n > m - we have to "forget" (n-m) old nodes.
# The process of insert/forget is organized as follows:
# every node from B set will in the end be to a node from A set.
# to make this association we:
# - compute D(Ai,Bj) where D is wighted distance
# - if we need to insert, we order Bj by δA(Bj) = min_i D(Ai,Bj)
# and note Bj with max(δA(Bj)) to be associated with newly created nodes.
# - if we need to forget, we order Ai by δB(Ai) = min_j D(Ai,Bj)
# and note Ai with max(δB(Ai)) to be forgotten.
# - after As are forgotten or some Bs are associated with new, we associate
# 1-1 the rest of A with the rest of B since all those nodes come in key↑ order.
#
# sum min d(a,b) sum min d(a,b)
# a∈A b∈B b∈B a∈A
# D(A,B) = ────────────── + ──────────────
# N(A) N(B)
#
_bcheck(ztree) # verify ztree after our tweaks
tstruct = StructureOf(ztree)
......
......@@ -328,6 +328,9 @@ def test_restructure():
newStructure = xbtree.TopoDecode(newtopo)
xbtree.Restructure(ztree, newStructure)
# XXX verify iteration producess the same [] of (key, v)
# XXX verify [k] gives the same v (for all k)
# Z0 creates new empty tree
def Z0():
z = Z()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment