Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
b4b07b83
Commit
b4b07b83
authored
May 11, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
bf388552
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+22
-1
wcfs/internal/xbtree_test.py
wcfs/internal/xbtree_test.py
+3
-0
No files found.
wcfs/internal/xbtree.py
View file @
b4b07b83
...
...
@@ -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
)
...
...
wcfs/internal/xbtree_test.py
View file @
b4b07b83
...
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment