Code Monkey home page Code Monkey logo

Comments (4)

tgamblin avatar tgamblin commented on June 19, 2024

Hey @slabasan:

This is really a design question — we need both behaviors but the question is where they should happen

Since the nodes are the thing that ultimately goes in the DataFrame in the index, I think that id(self) == id(other) (aka self is other) should be the behavior we want there. Every DF should have nodes from only one graph, and in that scenario, comparing by node id makes sense. For trees that is effectively the same as comparing by callpath (only faster, since comparing ids is faster than comparing tuples). For graphs it’s not general enough -- you need to build the graph and compare nodes to determine which nodes are unique, since not every graph node has a unique callpath as in a CCT.

This last bit is key -- there shouldn’t be a callpath on the Node in the final version of this, specifically because comparing the callpath isn’t general enough for graphs. We have to build the graph and use node identity (is, or id(self) == id(other)) for graphs. So, before you can compare graph nodes in hatchet, you should unify the graphs, and you should traverse and compare frame values to do that.

There are probably other situations (besides unification) where comparing frame values between nodes from separate graphs makes sense, but i would stick to always unify for now.

from hatchet.

slabasan avatar slabasan commented on June 19, 2024

Thanks @tgamblin for clarifying. So if we have a unify in graphframe, let's say it returns two graphframes with updated graphs and dataframes. If we are trying to unify two graphframes (i.e., identical input data set), the unify should update the node ID's so they are consistent between both, correct? Then we should also save the mapping from the old nodes to the new nodes, which can be used to update the dataframe.

from hatchet.

tgamblin avatar tgamblin commented on June 19, 2024

@slabasan: I'd implement union on Graph first, and have it return two dicts:

def union(left, right):
    """Union two Graphs and return the resulting graph along with mappings
       from the old graphs' nodes to the new graph's nodes.

    Returns:
        (Graph, dict, dict): unioned Graph and mappings from left and right ids (respectively)
             to Graph's ids.
    """

then implement unify on GraphFrame and have it call union and use the mappings to translate. I think this is basically what you're suggesting, right?

from hatchet.

slabasan avatar slabasan commented on June 19, 2024

I think this issue has been resolved. The node equivalence check is correct behavior, and we are working on implementing the union operation on a graph.

from hatchet.

Related Issues (20)

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.