Comments (10)
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.
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.
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.
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.
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.
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.
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.
@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.
@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.
@erikbrinkman thanks for the heads up and the quick implementation !
from d3-dag.
Related Issues (20)
- Basic TypeScript type check error HOT 6
- Tips for writing my own layering HOT 2
- General question about node ordering HOT 2
- Specific key order appears to cause decrossOpt to hang HOT 4
- TS: Errors with typescript version 4.9.4 HOT 3
- example code not runable HOT 4
- How to plot a horizonal sugiyama graph HOT 1
- Guidance on Implementing Radial Drawing with d3-dag's Sugiyama Algorithm HOT 3
- Implement Brandes/Kรถpf Coordinate Assignment
- Expand d3-dag to handle multiple paths from parent->child HOT 4
- Dynamic nodeSize? HOT 1
- TS, export SugiNode<NodeDatum = unknown, LinkDatum = unknown> ? HOT 3
- TS Sugestion(?) HOT 4
- Possible linking bug in docs HOT 3
- elkjs, external layout algorithms? HOT 1
- is it possible to establish node order explicitly in grid? HOT 8
- Support for TypeScript <4.5
- How to extend DagNode in vanilla js? HOT 6
- Error: size of dag to decrossOpt is too large and will likely crash instead of complete, enable "large" grahps to run anyway HOT 9
- Layout direction HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-dag.