Closed sandfox closed 9 years ago
Thanks for the very detailed issue description! I'll take a look at your pull request tonight.
I've fixed this in a way that will always detect cycles even if there are several disconnected subgraphs (and one of the doesn't have a cycle) and include the correct cycle information in the error message.
I've pushed version 0.4.1 to npm
Cool, I'm glad you could make something of my rambling, I'm still pretty new to DAGs. Yeah, you're fix is a lot cleaner! Thanks for this.
example code speaks better than words
I think that should be enough but let me know if it's not clear or doesn't make any sense.
EDIT----
Think I have found the/a problem..
TL;DR
the
overallOrder
function checks every node to find one that is not a dependency of another node, and when that fails just checks the first node to find it's dependencies, even though the first node maybe a leaf (based upon onoutgoingEdges
)so, in
overallOrder
it tries to find a node to start from by checking for a node with 0incomingEdges
(things that are immediately dependent on that node). but every node in my example is a dependency (which means it's cyclic), so the code realises it can't find a starting point and so to find the cyclic dependency it just takes the first node and tries search through it'soutgoingEdges
(things it is immediately dependent on) and find the cycle that way. This is all groovy and everything unless your first node isn't in the middle of the cycle and is just a leaf node.I think I can add a small fix to make sure that at least an error gets thrown when trying to render overall order.