Comments (4)
it actually does have a timeout mechanism! Unfortunately I think in the current version the heuristic is off. In an update version it should be better able to predict timeout issues.
Sorry that you had to be hit with a case that bypassed the check. I will use this an example to make sure it appropriately errors on this as input.
Ideally for graphs like this, an exception will be raised, and if you wanted to backoff, you could catch this exception and switch to a different layout, or even write a custom decross operator that tried opt, and used twolayer if it times out.
from d3-dag.
This is really interesting, but I think out of scope. decrossOpt
just uses an ILP solver on the backend. Due to the nature of the problem it is easier to verify a good solution than to find one, so if the optimizers heuristics aren't problem invariant (I'm not sure this is possible, although maybe) this can and will happen. The solution is always to use decrossTwoLayer
for problems like this.
It does raise two potential types of solutions:
decrossTwoLayer
starts with an initial "good" ordering created bydecrossDfs
. This is still ultimately dependant on the order of nodes, becausedecrossDfs
uses edges in order without some total ordering to edge or node iteration, but runningdecrossDfs
beforedecrossOpt
might help. I tried combiningdecrossTwoLayer
beforedecrossOpt
and it didn't help, so the issue must be related more to edge order than node order.- This is a strange graph in that one layer is very difficult to optimize, but the rest are pretty easy. I imagine you don't really care about how that ugly layer looks, but want the number of crossings minimized on the rest of the graph (There's the one extra edge cross that this stuck in a local minima an so decrossTwoLayer will never remove it.). It potentially suggests a hybrid approach, where we first run
decrossTwoLayer
on the whole graph, then run a modifieddecrossAlmostOpt
that is identical todecrossOpt
but leaves complicated layers in order.
from d3-dag.
It's beyond my expertise to comment on your suggestions but I have a tangential suggestion: since it's so hard to predict when decrossOpt
might run into difficulties it really shouldn't be used without being wrapped in a timeout mechanism. I didn't really appreciate this as it was finishing very quickly on our other graphs of similar size/complexity. Perhaps a way to gracefully timeout and fall back to decrossTwoLayer
should be included in the lib.
from d3-dag.
The prerelease version updates this codes to check the actual number of variables, which should be better at catching this inconsistency:
d3-dag/src/sugiyama/decross/opt.ts
Lines 378 to 384 in f3f0f20
The downside is is creates the program which might be very large. It's possible to compute these sizes in advance, but the code was quite messy, so I opted for this simpler version.
Don't hesitate to reopen if it's not addressed.
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
- 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.