Giter Site home page Giter Site logo

bdi-ed's People

Contributors

chgarth avatar flowetzels avatar

Forkers

colinstephen

bdi-ed's Issues

Surprising Output on Interval-Based Merge Tree

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:

image

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.