VisitationTree

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.

Constructors

this
this(T value)

Constructs a new node

Members

Functions

isVisited
bool isVisited()

Checks this node has been visited

linearize
T[] linearize()

Performs the linearization

mark
void mark()

Marks this node as visited

Examples

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");

Meta