Constructs a new node
Checks this node has been visited
Performs the linearization
Marks this node as visited
Tests out using the visitation tree
VisitationTree!(string) root = new VisitationTree!(string)("root"); VisitationTree!(string) thing = new VisitationTree!(string)("subtree"); root.appendNode(thing); thing.appendNode(root); string[] linearized = root.linearize(); writeln(linearized); assert(linearized[0] == "subtree"); assert(linearized[1] == "root");
A kind-of a graph which has the ability to linearize all of its nodes which results in performing a depth first search resulting in the collection of all nodes into a single array with elements on the left hand side being the most leafiest (and left-to-right on the same depth are in said order).
It also marks a node as visited on entry to it via the dfs call to it.
When dfs is performed, a child node is only recursed upon if it has not yet been visited.
With all this, it means a graph of relations can be flattened into an array.