// go from the one end node to the next end node in the AOG graph // un-highlight the previous step // highlight the current step public void goOneStep() { currentAction.highLightNode(false); nextAction.highLightNodePath(false); SimpleTree.nextActionSecondHalf = ""; currentAction = nextAction; nextAction = SimpleTree.TravelToNextEndNode(nextAction, true); currentAction.highLightNode(true); if (nextAction == null) { SimpleTree.nextActionFirstHalf = "Sequence Finished!"; resetStepper(); } nextAction.highLightNodePath(true); Debug.Log(SimpleTree.nextActionFirstHalf); Debug.Log(SimpleTree.nextActionSecondHalf); statusText.text = SimpleTree.nextActionFirstHalf + "\n" + SimpleTree.nextActionSecondHalf; string currentActionName = currentAction.getActionName().ToLower(); udpManager.executeAction(currentActionName); stcPanelControl.loadNewImage(currentActionName); }
public void LoadNewTree(string profileName, int seed = -1, bool displayBranch = true, bool wind = true) { TreeProfile profile = Content.Load <TreeProfile>(profileName); if (seed == -1) { tree = profile.GenerateSimpleTree(); } else { Random rand = new Random(seed); tree = profile.GenerateSimpleTree(rand); } useTree = true; treeUseBranches = displayBranch; treeUseWind = wind; // Wind treeWind = new LTreesLibrary.Trees.Wind.WindStrengthSin(); treeAnimator = new LTreesLibrary.Trees.Wind.TreeWindAnimator(treeWind); // Scale ChangeCameraZoom(0); float BoundingSphereRadius = (float)(new Ray(Vector3.Zero, Vector3.Up)).Intersects(camera._frustum.Top); treeScale = BoundingSphereRadius / tree.TrunkMesh.BoundingSphere.Radius; treeMatrices = new Matrix[2]; treeMatrices[0] = Matrix.CreateScale(treeScale); treeMatrices[1] = Matrix.CreateTranslation(new Vector3(0, -BoundingSphereRadius / 2, 0)); }
private static IEnumerable <SimpleTree <string> > TraverseTerms(SimpleTree <string> root, TermSet set, int lcid, bool traverseAll) { var stack = new Queue <SimpleTree <string> >(); var termStack = new Queue <TermSetItem>(); stack.Enqueue(root); termStack.Enqueue(set); while (stack.Any()) { var next = stack.Dequeue(); var nextTerm = termStack.Dequeue(); yield return(next); int index = 1; foreach (var child in nextTerm.Terms) { if (child.IsAvailableForTagging || traverseAll) { termStack.Enqueue(child); stack.Enqueue(new SimpleTree <string>(string.Format("{0}{1}.", next.Key, index), child.Name, child.GetDescription(lcid)) { Parent = next }); index++; } } } }
public static void TestDeleteLeafFromTree() { var root = new SimpleTreeNode <int>(1, null); var tree = new SimpleTree <int>(root); var node2 = new SimpleTreeNode <int>(2, root); tree.AddChild(root, node2); var node3 = new SimpleTreeNode <int>(3, root); tree.AddChild(root, node3); var node4 = new SimpleTreeNode <int>(4, node3); tree.AddChild(node3, node4); var count = tree.Count(); var leafCount = tree.LeafCount(); Assert.AreEqual(4, count); Assert.AreEqual(2, leafCount); tree.DeleteNode(node4); count = tree.Count(); leafCount = tree.LeafCount(); Assert.AreEqual(3, count); Assert.AreEqual(2, leafCount); Assert.AreEqual(true, root.Children.Contains(node2)); Assert.AreEqual(true, root.Children.Contains(node3)); Assert.IsNull(node3.Children); }
protected override SimpleTree <string> ParseCsv(CsvReader csv) { SimpleTree <string> result = new SimpleTree <string>(); while (csv.ReadNextRecord()) { string unit = string.Empty; string[] arr = new string[Headers.Length]; csv.CopyCurrentRecordTo(arr); StringBuilder org = new StringBuilder(); for (int i = 0; i < Headers.Length - 2; i++) { if (string.IsNullOrEmpty(arr[i]) == false) { org.Append(arr[i]); org.Append('.'); unit = Headers[i]; } } string path = org.ToString(); string name = string.Format("{0} - {1}", path.TrimEnd('.').Substring(path.TrimEnd('.').LastIndexOf('.') + 1), arr[6]); string desc = arr[7]; AddToTree(result, path, name, desc, new Property(DEPARTMENT_PROP_NAME, unit)); } return(result); }
static void Main(string[] args) { DataManager dm; SimpleTree st; List <double> dl = new List <double>(); try { dm = new DataManager(@"config.txt"); st = new SimpleTree(); // KAA: ineffizient foreach (int currentInt in dm.GetIntNumbers()) { st.Add(currentInt); } foreach (double currentDouble in dm.GetDoubleNumbers()) { dl.Add(currentDouble); } } catch (Exception ex) { Console.WriteLine(ex.Message); } // AVG des Baumes fehlt Console.WriteLine(dl.Average()); }
public static List <List <SimpleTree> > ReturnPossibleTrees(SimpleTree tree, List <List <Rule> > divideList) { IEnumerable <IEnumerable <Rule> > cartesianProducts = CartesianProduct(divideList); var returnResult = new List <List <SimpleTree> >(); foreach (var particularConfig in cartesianProducts.ToList()) { IEnumerable <Rule> differenceList = ReturnDifferenceBetweenTables(divideList, particularConfig.ToList()).SelectMany(m => m); IEnumerable <SimpleTree> oneSolution = ReturnTreeEllementsWithoutDifferences(tree, differenceList.ToList()); SimpleTree[] treeToList = oneSolution.ToArray(); bool isDouble = RemoveDoubles(returnResult, treeToList); if (isDouble) { returnResult.Add(oneSolution.ToList()); } } return(returnResult); }
private List <TreeNode> NeedUpdateNodes(SimpleTree <Node> simpTree) { var nlist = new List <TreeNode>(); simpTree.TraverseTreeNode(simpNode => { if (simpNode.Data.IsCatalog) { var cataFromNode = simpNode.Tag as ShortcutCatalogEntity; var cataFromDb = _dbAccessor.ReadNodeByIdAndType(cataFromNode.EntityId, typeof(ShortcutCatalogEntity)) as ShortcutCatalogEntity; if (cataFromDb == null || IsCataNotEqualTo(cataFromNode, cataFromDb)) { nlist.Add(cataFromNode); } } else { var shortcut = simpNode.Tag as ShortcutEntity; var shortcutFromDb = _dbAccessor.ReadNodeByIdAndType(shortcut.EntityId, typeof(ShortcutEntity)) as ShortcutEntity; if (shortcutFromDb == null || IsShortcutNotEqualTo(shortcut, shortcutFromDb)) { nlist.Add(shortcut); } } }, false); return(nlist); }
protected override SimpleTree <string> ParseCsv(CsvReader csv) { SimpleTree <string> result = new SimpleTree <string>(); string temp = null; while (csv.ReadNextRecord()) { StringBuilder builder = new StringBuilder(); builder.Append(csv["WOJ"]); builder.Append('.'); if (string.IsNullOrEmpty((temp = csv["POW"])) == false) { builder.Append(temp); builder.Append('.'); } if (string.IsNullOrEmpty((temp = csv["GMI"])) == false) { builder.Append(temp); builder.Append(csv["RODZ"]); builder.Append('.'); } string path = builder.ToString(); string name = string.Format("{0} ({1})", csv["NAZWA"], csv["NAZDOD"]); AddToTree(result, path, name); } return(result); }
public void Max_FindBiggestElement_BiggestElement() { var bst = SimpleTree.Create(); var value = bst.Max(); Assert.Equal(SimpleTree.BiggestElement.Value, value); }
public void TestCountLeaf_3() { SimpleTreeNode <int> root = new SimpleTreeNode <int>(0, null); SimpleTree <int> tree = new SimpleTree <int>(root); Assert.AreEqual(1, tree.LeafCount()); }
public void TestGetAllNodes_3() { SimpleTreeNode <int> root = new SimpleTreeNode <int>(1, null); SimpleTreeNode <int> node1 = new SimpleTreeNode <int>(11, null); SimpleTreeNode <int> node2 = new SimpleTreeNode <int>(12, null); SimpleTreeNode <int> node3 = new SimpleTreeNode <int>(13, null); SimpleTreeNode <int>[] nodes = new SimpleTreeNode <int>[] { root, node1, node2, node3 }; SimpleTree <int> tree = new SimpleTree <int>(root); tree.AddChild(root, node1); tree.AddChild(root, node2); tree.AddChild(root, node3); List <SimpleTreeNode <int> > list = tree.GetAllNodes(); int index = 0; foreach (SimpleTreeNode <int> node in list) { Assert.AreEqual(nodes[index], node); index++; } }
public void TestCountLeaf_1() { SimpleTreeNode <int>[] nodes = GetNodesArray_1(); SimpleTree <int> tree = GetTree(nodes); Assert.AreEqual(10, tree.LeafCount()); }
public static bool MethodForContradiction (GatheredBases bases, Rule ruleForCheck, int count, List <List <Rule> > differenceList, out SimpleTree tree) { tree = new SimpleTree { rule = ruleForCheck }; IEnumerable <SimpleTree> parentWithoutChildren; int _number = 0; do { parentWithoutChildren = TreeOperations.TreeToEnumerable(tree).Where(p => p.Children.Count == 0). Where(p => p.Askable == false); foreach (SimpleTree parentWithoutChild in parentWithoutChildren) { TreeOperations.ExpandBrunchOrMakeAskable(bases, parentWithoutChild, differenceList); _number++; if (_number == count) { return(false); // method not finished tree after _number iterations } //TODO: ta pętla nie jest odporna na sprzeczność } } while (parentWithoutChildren.Count() != 0); return(true); // method finished tree and there is no contradiction }
public void TestDelete_A_2() { SimpleTreeNode <int>[] nodesArray = GetNodesArray_1(); SimpleTree <int> tree = GetTree(nodesArray); tree.DeleteNode(nodesArray[5]); tree.DeleteNode(nodesArray[11]); int indexA = 0; int indexB = 3; int count = 1; if (tree.Root.Children != null) { foreach (SimpleTreeNode <int> node in tree.Root.Children) { count += node.Children.Count + 1; indexA++; Assert.AreEqual(nodesArray[indexA], node); if (node.Children != null) { foreach (SimpleTreeNode <int> deepnode in node.Children) { indexB++; if (indexB == 5 || indexB == 11) { indexB++; } Assert.AreEqual(nodesArray[indexB], deepnode); } } } } Assert.AreEqual(12, count); }
protected override SimpleTree <string> ParseCsv(CsvReader csv) { SimpleTree <string> result = new SimpleTree <string>(); while (csv.ReadNextRecord()) { string pathValue = csv["Path"]; string path = pathValue.Split('-')[0].Trim() + "."; string name = string.Empty; if (pathValue.IndexOf('.') >= 0) { if (pathValue.LastIndexOf('.') < pathValue.IndexOf('-')) { name = pathValue.Substring(pathValue.LastIndexOf('.') + 1); } else { string temp = pathValue.Substring(0, pathValue.IndexOf('-')); name = temp.Substring(temp.LastIndexOf('.') + 1) + pathValue.Substring(pathValue.IndexOf('-')); } } else { name = pathValue; } AddToTree(result, path, name); } return(result); }
public void forest() { SimpleTreeNode <int> a1 = new SimpleTreeNode <int>(1, null); SimpleTreeNode <int> b1 = new SimpleTreeNode <int>(2, a1); SimpleTreeNode <int> b2 = new SimpleTreeNode <int>(3, a1); SimpleTreeNode <int> b3 = new SimpleTreeNode <int>(6, a1); SimpleTreeNode <int> c1 = new SimpleTreeNode <int>(5, b1); SimpleTreeNode <int> c2 = new SimpleTreeNode <int>(7, b1); SimpleTreeNode <int> c3 = new SimpleTreeNode <int>(4, b2); SimpleTreeNode <int> c4 = new SimpleTreeNode <int>(8, b3); SimpleTreeNode <int> d1 = new SimpleTreeNode <int>(9, c4); SimpleTreeNode <int> d2 = new SimpleTreeNode <int>(10, c4); SimpleTree <int> tree = new SimpleTree <int>(a1); tree.AddChild(a1, b1); tree.AddChild(a1, b2); tree.AddChild(a1, b3); tree.AddChild(b1, c1); tree.AddChild(b1, c2); tree.AddChild(b2, c3); tree.AddChild(b3, c4); tree.AddChild(c4, d1); tree.AddChild(c4, d2); List <int> list = tree.EvenTrees(); if (list[0] != 1 && list[1] != 3 && list[2] != 1 && list[3] != 6) { Assert.Fail(); } if (tree.LeafCount() != 2) { Assert.Fail(); } }
private void IfParentTrueWrite(SimpleTree simpleTree) { if (simpleTree.Askable) { _viewModel.MainWindowText1 += simpleTree.rule.Conclusion + " Fakt \n"; } int i = 0; if (simpleTree.Parent != null) { foreach (var simple in simpleTree.Parent.Children) { if (simple.ConclusionValue) { i++; } } if (i == simpleTree.Parent.Children.Count) { _viewModel.MainWindowText2 += simpleTree.Parent.rule.Conclusion + " Wynik \n"; IfParentTrueWrite(simpleTree.Parent); } } }
public override void PosDrawPhase(Microsoft.Xna.Framework.GameTime gt, SceneControl.IObject obj, SceneControl.RenderHelper render, Cameras.ICamera cam, IList <Light.ILight> lights) { SimpleTree tree = (obj.Modelo as TreeModel).Tree; tree.DrawLeaves(obj.WorldMatrix, cam.View, cam.Projection, false); render.ResyncStates(); }
public void FindAfterDelete() { var root = new SimpleTreeNode <int>(0, null); var node1 = new SimpleTreeNode <int>(1, null); var node2 = new SimpleTreeNode <int>(2, null); var node3 = new SimpleTreeNode <int>(3, null); var node4 = new SimpleTreeNode <int>(4, null); var node5 = new SimpleTreeNode <int>(5, null); var tree = new SimpleTree <int>(root); tree.AddChild(root, node1); tree.AddChild(root, node2); tree.AddChild(root, node3); tree.AddChild(node3, node4); tree.AddChild(node3, node5); Assert.True(tree.FindNodesByValue(5).Count == 1); tree.DeleteNode(node5); tree.DeleteNode(node2); Assert.True(tree.Count() == 4); Assert.True(tree.FindNodesByValue(5).Count == 0); Assert.True(tree.GetAllNodes().Count == 4); Assert.True(tree.LeafCount() == 2); }
public void TestSetLevel() { SimpleTreeNode <int>[] nodes = GetNodesArray_1(); SimpleTree <int> tree = GetTree(nodes); tree.SetLevel(); List <SimpleTreeNode <int> > list = tree.GetAllNodes(); int count = 1; foreach (SimpleTreeNode <int> node in list) { if (count == 1) { Assert.AreEqual(1, node.level); } if (count == 2 || count == 5 || count == 9) { Assert.AreEqual(2, node.level); } if (count > 2 && count < 5 || count > 5 && count < 9 || count > 9) { Assert.AreEqual(3, node.level); } count++; } }
public void Size_MeasureSizeOfTree_Size() { var bst = SimpleTree.Create(); var size = bst.Size(); Assert.Equal(SimpleTree.Size, size); }
private int siblingIndex; // starts from 1 public SimpleTree(Node data) { this.data = data; children = new LinkedList <SimpleTree>(); this.parent = null; childrenNumber = 0; int siblingIndex = 1; }
private SimpleTree(Node data, LinkedList <SimpleTree> children, SimpleTree parent) { this.data = data; this.children = children; this.parent = parent; this.siblingIndex = parent.childrenNumber + 1; childrenNumber = 0; }
public void Exists_CheckIfElementExists_ItExists() { var bst = SimpleTree.Create(); var exists = bst.Exists(SimpleTree.BiggestElement.Key); Assert.True(exists); }
/// <summary> /// Generates the dependency hirarchy of the include files /// </summary> /// <param name="document"></param> /// <param name="parentNode"></param> /// <returns></returns> /// <exception cref="DependencyTreeException" /> public List<ProjectItemCodeDocument> BuildHirarchy(Dictionary<ProjectItemCodeDocument, List<ProjectItemCodeDocument>> data, ProjectItemCodeDocument startDoc) { // init globals _codeDocuments = data; _treeRoot = new SimpleTree<ProjectItemCodeDocument>() { Value = startDoc }; return GenerateDependcyHirarchy(startDoc, _treeRoot); }
public void Exists_CheckIfElementExists_ItDoesntExist() { var bst = SimpleTree.Create(); var exists = bst.Exists(SimpleTree.NotExistingElement.Key); Assert.False(exists); }
public SimpleTree(Node data, SimpleTree parent) { this.data = data; children = new LinkedList <SimpleTree>(); this.parent = parent; this.siblingIndex = parent.childrenNumber + 1; childrenNumber = 0; }
public void AddChild(SimpleTree _child) { if (childs.Contains(_child)) { return; } childs.Add(_child); }
public void IndexedProperty_Get_TheRootElement() { var bst = SimpleTree.Create(); var value = bst[SimpleTree.RootElement.Key]; Assert.Equal(SimpleTree.RootElement.Value, value); }
public void Update(Microsoft.Xna.Framework.GameTime gametime, IObject obj, IList <ILight> lights) { shader.Update(gametime, obj, lights); wsource.Update(gametime); SimpleTree tree = (obj.Modelo as TreeModel).Tree; animator.Animate(tree.Skeleton, tree.AnimationState, gametime); }
public void UpdateTree(SimpleTree<Vector2> newTree) { treeToDraw = newTree; }
public void ShouldJoinObjectsWithPaths() { var nodes = new [] { new SimpleTreeNode() { Name="A" }, new SimpleTreeNode() { Name="B", Children = new [] { new SimpleTreeNode() { Name="C" } } }, new SimpleTreeNode() { Name="D", Children=new[] { new SimpleTreeNode() { Name="E", Children = new [] { new SimpleTreeNode() { Name = "F" }, new SimpleTreeNode() { Name = "G" } } } } }, new SimpleTreeNode() { Name="G", Children = new SimpleTreeNode[0] } }; var paths = new [] { new Tuple<string, int?>("A", 1), new Tuple<string, int?>("B.C", 2), new Tuple<string, int?>("D.E.F", 3), new Tuple<string, int?>("D.E.G", 4), new Tuple<string, int?>("D", 5) }; var result = new SimpleTree(nodes).Join(paths).ToList(); Assert.That(result, Is.Not.Null); var expected = new[] { new ProjectedTreeNode<int?>() { Name="A", Item=1, Children = new ProjectedTreeNode<int?>[0] }, new ProjectedTreeNode<int?>() { Name="B", Item=null, Children = new[] { new ProjectedTreeNode<int?>() { Name="C", Item=2, Children = new ProjectedTreeNode<int?>[0] }, } }, new ProjectedTreeNode<int?>() { Name="D", Item=5, Children = new [] { new ProjectedTreeNode<int?>() { Name="E", Item=null, Children = new[] { new ProjectedTreeNode<int?>() { Name="F", Item=3, Children = new ProjectedTreeNode<int?>[0] }, new ProjectedTreeNode<int?>() { Name="G", Item=4, Children = new ProjectedTreeNode<int?>[0] }, } }, } } }; Assert.That(result, new MemberwiseEqualConstraint(expected, MemberwiseEqualityComparer.ComparisonMode.CompareEverything, null)); }