Comments (2)
Thanks this is great!
I will use the depthLayering method you provided, I have the height stored. (I don't think the first one will work, as I will not draw every edge of the tree, only a section of the tree. But I do want to keep the tree's layering. I also don't think it is compact).
And fortunately not a multigraph.
from d3-dag.
@kelemeno sorry for the late response!
- If your tree is compact, e.g. all children are one height below their parents, then simplex should just do the right thing, and so should
longestPath
(the later being a little faster). - If it's not compact, you should be able to get away with just specifying ranks. It's still more computationally expensive than necessary, but it's the next easiest for your effort.
- The fastest for large trees will be writing it yourself. If you look at the documentation for
LayeringOperator
s it has a pretty simple requirementAfter calling a layering operator on a dag, every node's value should be set to a non-negative integer layer, starting at 0. Additionally children should have a strictly larger layer than their parents, and if a node has multiple links to the same child, it's layer should be at least two greater than its parent.
If you had the depth stored in the node data you could use that with something like:However, if you don't have the height stored, and want it purely in graph terms, then you should also be able to usefunction depthLayering(dag: Dag<{ myDepth: number }, unknown>): void { for (const node of dag) { node.value = node.data.myDepth; } }
height
because that does exactly what you want.Do note, that both of these implementation assume that you don't have a muultigraph, e.g. you can't have two edges between the same two nodes. Due to the way we layout multi-edges, we have to insert dummy layers, and these implementations don't do that.function depthLayering(dag: Dag<unknown, unknown>): void { dag.height(); }
from d3-dag.
Related Issues (20)
- Basic TypeScript type check error HOT 6
- 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.