Code Monkey home page Code Monkey logo

Comments (2)

Dirkster99 avatar Dirkster99 commented on August 11, 2024

Hi, I've seen this problem in my unit tests before just never got around to actually fixing it :-( but the good new is that I think I fixed it now :-)

The fixed solution is in a seperate branch: Depthfirst.Traverse.PostOrder

  • Would you be able to test this for me and let me know if you see any issues with it?

I found that the old traversal structure was not too useful here because it had no direct readable states towards whether:

  • a node has been visited
  • a nodes children have been visited and so forth

So, I redesigned the algorithm using the private utility class:
TreeLib.Depthfirst.Traverse.VisitElement<T>

This class allows me tho keep the state in very simple way and yield each node in a simple while loop as you can see in the static IEnumerable<T>PostOrderIterator<T>(...) method in TreeLib.Depthfirst.Traverse.

The case you are reporting is this:
tree

This structure is tested in a unit test in TreeLibNugetUnitTests.CoreTests.TestMethod8() and does no longer return an error. I have added one or 2 more unit tests here for good measure but I think this is fine. Would you want to add more test patterns? If so, please let me know also...

Thanks for your detailed feedback.

from treelib.

panosonasis avatar panosonasis commented on August 11, 2024

First of all thanks for your quick response.So after a brief testing everything seems to work correctly.If i find something else i will keep you posted.Thanks!

from treelib.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.