GithubHelp home page GithubHelp logo

Comments (5)

aaronkw avatar aaronkw commented on August 19, 2024

Did your message get clipped?

from d3-network.

dongbohu avatar dongbohu commented on August 19, 2024

Sorry, I submitted the issue by accident before I finished it. I have updated it.

from d3-network.

aaronkw avatar aaronkw commented on August 19, 2024

I see your point! So actually I did this to follow the d3 convention. According to the documentation, the values of 'source' and 'target' may be initialized with the index of the node in the node array (and in fact our backend remaps the ids to accommodate this):

Note: the values of the source and target attributes may be initially specified as indexes into the nodes array; these will be replaced by references after the call to start. Link objects may have additional fields that you specify; this data can be used to compute link strength and distance on a per-link basis using an accessor function.

Reference

The d3 force layout code actually does this exact binding:

      for (i = 0; i < m; ++i) {
        o = links[i];
        if (typeof o.source == "number") o.source = nodes[o.source];
        if (typeof o.target == "number") o.target = nodes[o.target];
        ++o.source.weight;
        ++o.target.weight;
      }

I bind the nodes explicitly because I need it before the force layout.

from d3-network.

aaronkw avatar aaronkw commented on August 19, 2024

Also, note that the only thing you would have to change is this:

genes_in = [ { id: 123, name: "foo" }, { id: 456, name: "bar" } ];
edges_in = [ { source: 0, target: 1, weight: 3.14} ];

from d3-network.

dongbohu avatar dongbohu commented on August 19, 2024

I got it. Thank you very much for the clarification.

from d3-network.

Related Issues (10)

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.