Replies: 1 comment
|
Yes I think this is a place where improvements can be made. The current walks are built quite naively with traversal, but analyzing shape could yield better results. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I've been thinking about it since I've heard about the Solid's approach that uses
nextSiblingandfirstChild.Becase sometimes it's not efficient to go top -> bottom, you wanna go bottom -> top.
The diagram below shows paths that all these four properties create
lastChild.firstChild.nextSib.prevSibLet's say we want to get from 0 to 5, using only nextSibling would cost us 5, when with the route 0-5-1 only 2.
In the example below it's better to use
lastChildproperty on the parent rather than creating a bunch ofnextSiblingreferences.What about this bad boy?
Well, in this case we can say, yo mama, I don't care, I'm gonna do
div.lastChild.previousSibling.And the algorithm is quite simple compare top bottom nodes choose the shortest path and that's it. Of course, we can go deeper to math using Dijkstra's multiple path algorightms with the power of Graphs it's quite simple, but it's really worth it.
All reactions