Replies: 5 comments
-
By "methods of stratify", I assume you mean methods on the DAG object that it returns? They were removed because the underlying data structure is now an arbitrary graph, which muddies the definitions of those concepts. Roots is pretty easy to compute by just filtering all nodes by ones that don't have parents, e.g. I think both are potentially reasonable to add these methods back in, probably in a more robust way, I'm just curious if they're absolutely necessary. Can you go into a bit of detail on how you used them? |
Beta Was this translation helpful? Give feedback.
-
Yes, you are correct, sorry I wasn't clear on that. As far as usage goes, we are building a pedigree product and using a combination of We could probably accomplish this in other ways, but it was super nice to have those built-in iterative methods 🙂 I've attached a video of a prototype that we've built (using React and d3-dag), which hopefully illustrates what we're trying to do. pedigree-prototype.mov |
Beta Was this translation helpful? Give feedback.
-
That's really cool! In the really short term, you should be able to get by with these two methods: function* descendants<N, L>(init: GraphNode<N, L>): IterableIterator<GraphNode<N, L>> {
const seen = new Set<GraphNode<N, L>>();
const queue = [init]
let node;
while (node = queue.pop()) {
if (seen.has(node)) continue;
yield node;
seen.add(node);
queue.push(...node.children());
}
}
function* roots<N, L>(init: GraphNode<N, L>): IterableIterator<GraphNode<N, L>> {
for (const node of init.nodes()) {
if (!node.nparents()) {
yield node;
}
}
} and either calling them repeatedly (roots will be slow), or ideally caching roots. In the slightly longer term, it seems reasonable to build these in and cache them, so I'll work on a 1.1 cut that has both of these methods (as well as ancestors and leaves) In the long term, I would check out this example for how I built a dynamic graph without those methods. It may prove helpful. |
Beta Was this translation helpful? Give feedback.
-
That sounds great! Additionally – thank you for all your work maintaining this package, it's been super helpful! |
Beta Was this translation helpful? Give feedback.
-
Okay, v1.1 is out and it has I want to point out two caveats that I don't think will be relevant to your use case given that you're migrating from an old version, but better to call out:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Looking to update our usage to 1.0, and maybe I've just missed something obvious here.... we use the
.descendants
and.roots
methods off ofstratify
quite a bit.... are there equivalents for those in the 1.0 release?Beta Was this translation helpful? Give feedback.
All reactions