dfsTree does not preserve contexts of the original graph
jhrcek opened this issue · comments
I've got an issue with dfsTree
: The tree it outputs does not preserve contexts of the original graph.
Please check this minimalistic example from elm repl:
The example creates graph with 2 nodes and 1 directed edge from 1 to 2.
Then calls dfsTree
starting from node 1.
Expected: the context.incoming
of node 2 should contain node 1.
Actual: the context.incoming
of node 2 is empty (underlined).
Is this expected / correct behavior? In my use case I have to work around this, by looking up the missing info in the original graph, It would be nice if the tree itself contained the same contexts as the original graph.
I don't think this is unique to dfsTree
, e.g. all traversals have this wart. At the time of writing the code, I think I didn't want to do unnecessary graph lookups in the original graph. But I'd be happy to accept a PR that changes this, I guess.
See this:
Line 994 in c66f59a
It would basically take an explicit set of visited nodes or a lookup in the original graph before every visit.
Just made you a collaborator. I'm not actually using this library, so you are probably in a much better position to (co-)maintain this library.
Ok. I'll look into this in some more details hopefully this week.