scivislab / bdi-ed Goto Github PK
View Code? Open in Web Editor NEWBranch Decomposition-Independent Edit Distances
License: MIT License
Branch Decomposition-Independent Edit Distances
License: MIT License
Hello,
This code seems really neat, but I either stumbled across a bug or I'm not understanding how to use it properly.
I setup a very simple experiment for two merge trees on the interval, one which is exactly the same but a leaf node was moved up by 1. Everything else is exactly the same, including the topology of the trees. I would expect the distance to be proportional to 1, but I'm seeing only a distance of 0. Picture of the two trees is shown below:
Here is the code I ran to create this example. Am I making a mistake on how I ran this? I would have expected the distance to be greater than 0.
Thank you for your help!
Sincerely,
Chris Tralie
import numpy as np
import matplotlib.pyplot as plt
from baseMetrics import *
from mergeTreeEdit_branch import *
def plot_tree(idx, nodeScalars, children, x=0, rg=2):
y = nodeScalars[idx]
plt.scatter(x, y)
plt.text(x+0.03, y-0.01, "{}".format(idx))
N = len(children[idx])
for i, c in enumerate(children[idx]):
x2 = x-rg/2+i*rg/(N-1)
xs = [x, x2]
ys = [y, nodeScalars[c]]
plt.plot(xs, ys, 'k')
plot_tree(c, nodeScalars, children, x2, rg/2)
nodeScalars1 = [0, 5, 3, 4, 2]
children1 = [[], [0, 3], [], [2, 4], []]
rootID1 = 1
nodeScalars2 = [0, 5, 2, 4, 1]
children2 = [[], [0, 3], [], [2, 4], []]
rootID2 = 1
plt.figure(figsize=(8, 3))
plt.subplot(121)
plot_tree(rootID1, nodeScalars1, children1)
plt.title("Tree 1")
plt.subplot(122)
plot_tree(rootID2, nodeScalars2, children2)
plt.title("Tree 2")
plt.show()
dist = branchMappingDistance(nodeScalars1,children1,rootID1,nodeScalars2,children2,rootID2,cost_wasserstein_branch)
print(dist)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.