Giter Club home page Giter Club logo

Comments (10)

erikbrinkman avatar erikbrinkman commented on May 22, 2024 1

As of v0.4.3 the simplex layering support constraint rank. It's only tested very simply, so let me know if you encounter anything strange. In principle this could be added to the other layerings (with some caveats on topological), but especially adding the equality constraint makes things quite difficult, so I've deferred from implementing anything else.

Note, there are a lot of changes to API in 0.4, so see the upgrading guide if you see errors.

I'm going to close this for now as I think it's not required to add it to other layerings, but if you find a compelling reason as to why it should be, this can be reopened.

from d3-dag.

erikbrinkman avatar erikbrinkman commented on May 22, 2024

It's an interesting idea. Currently none of the methods support it, but you could always write your own "layering" operator that respected some notion like this. In principle though some of the methods could support something (especially simplex, as that constraint could just be added).

Do you have some idea as to what the api might look like? e.g. how you would specify a "rank" and what the contract might specify.

from d3-dag.

gempain avatar gempain commented on May 22, 2024

This would apply in time constrained graphs. Take this graph for example:

I'd like to have the ability to constraint node 2 and 8 to have the same rank as 21, for example. In DOT, you can specify the rank of a node by doing something like a [rank=1] and the algorithm lays out nodes with the same rank at the same depth.

API wise, I would just add a rank or depth (as rank may be confusing with the graph level property) property at the node level, just like you specify width and height. The rank would be a number which the user has to assign manually. In my case, I already know the exact rank of each of my nodes. My real problem is to optimize the layout horizontally to minimize edge crossings.

Does that make sense to you ?

from d3-dag.

erikbrinkman avatar erikbrinkman commented on May 22, 2024

Yeah, that seems reasonable. Given the current api, what I'm thinking is having something like a "rankAccessor" that returns a number or undefined. Any nodes that define rank as the same, must be put on the same level. Given the different layering operators, not all will support this, but it also seems reasonable to have them default to node.datum.rank.

In practice, since we're just looking for equality, these could really be anything, strings, booleans etc. In some sense, strings make more sense to me because of the equality and floating pointness of js numbers, but maybe number is more in line with dot. Thoughts?

from d3-dag.

gempain avatar gempain commented on May 22, 2024

rankAccessor is a good idea. I'm not sure what node.datum.rank is as I'm not aware of your entire API, but I'm assuming that any user defined properties are set into node.datum.

I think we shouldn't limit to equality checking. One day someone may want to say "I want node A to be one rank above node B". Numbers would be best, forget about floating points, people should use integers for this case as ranks are discrete, not continuous.

What do you think ?

from d3-dag.

sebitokazu avatar sebitokazu commented on May 22, 2024

This is what I've been looking for a while! Having a rankAccesor sounds great.
In the meantime, I was wondering how should my own "layering" operator look like? Are there any variables I must assign a value? Thanks in advance!

from d3-dag.

erikbrinkman avatar erikbrinkman commented on May 22, 2024

Sorry, I've been slow to actually implement this because I'm working (slowly) on the next major version that changes some conventions and adds typescript support. The actual change to implement this yourself shouldn't be too hard. You could mostly copy the simplex layering operator, and then modify it slightly to enforce the constraints imposed by rank accessor. I find my comments non-existent, and the framing of javascript-lp-solver unusual enough, that I can't give direct recommendation, but hopefully I'll have something in it soon.

from d3-dag.

gempain avatar gempain commented on May 22, 2024

@erikbrinkman please don't be sorry, none of us expects you to spend your time for free developing feature requests and we fully understand the perks of Open Source. I don't have the time to work on a PR as other priorities await, but I'll keep an eye on this issue.

from d3-dag.

sebitokazu avatar sebitokazu commented on May 22, 2024

@erikbrinkman it's fine. Just like @gempain said, nobody expects you to attend every feature request. Thanks for the advice! I'll try modifying the simplex layering operator.

from d3-dag.

gempain avatar gempain commented on May 22, 2024

@erikbrinkman thanks for the heads up and the quick implementation !

from d3-dag.

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.