public void testRootNode() { Node node1 = new Node("state1"); Assert.IsTrue(node1.isRootNode()); Node node2 = new Node("state2", node1, null, 1.0); Assert.IsTrue(node1.isRootNode()); Assert.IsFalse(node2.isRootNode()); Assert.AreEqual(node1, node2.getParent()); }
public List <Node> getPathFromRoot() { List <Node> path = new List <Node>(); Node current = this; while (!current.isRootNode()) { path.Insert(0, current); current = current.getParent(); } // ensure the root node is added path.Insert(0, current); return(path); }