3 ms·
It shouldn't take you hours to code these new features. And 1000 nodes isn't enough that you need fancy performance from a library. I suspect you want to extra
by BorisTheBrave 6y ago
It shouldn't take you hours to code these new features. And 1000 nodes isn't enough that you need fancy performance from a library.
I suspect you want to extract a few basic functions from what you've already written, and then combine them for new features. The posibilities are not endless, there's only so many things you are likely to want to do on a graph, and the vast majority (like TFA) are not useful to you
Here are some common operations:
* list everythign reachable from a given node, depth first order
* list everythign reachable from a given node, breadth first order
* make the reverse graph (edges point the other way)
* find the strongly connected component a node is in (a more general way of identifying loops)
Then you can build more complex queries out of those, rather than coding them every time. e.g.
> show only the part of the graph that leads to this category of nodes
get the reverse graph, for each node in the category, find everything reachable in the reverse graph, and union them together in one set
> display the graph while hiding everything downstream of node X
get the set of everything downstream, then list everything depth first, skipping stuff in the set.
It's not super efficient, but I don't think you care.