public void TestSingle() { List <GraphNode> graphNodes = new List <GraphNode>(); List <GraphNode> result = new List <GraphNode>(); graphNodes.Add(new GraphNode("aaa", new Point(10, 10))); RangeTree2D rangeTree2D = new RangeTree2D(graphNodes); TreeNode <GraphNode> root = rangeTree2D.Root; result = rangeTree2D.GetAllInRange(new Point(5, 5), new Point(15, 15)); }
public void TestGetting() { List <GraphNode> graphNodes = new List <GraphNode>(); graphNodes.Add(new GraphNode("aa", new Point(2, 5))); graphNodes.Add(new GraphNode("bb", new Point(3, 1))); graphNodes.Add(new GraphNode("cc", new Point(4, 8))); graphNodes.Add(new GraphNode("dd", new Point(3, 6))); graphNodes.Add(new GraphNode("ee", new Point(9, 11))); graphNodes.Add(new GraphNode("ff", new Point(5, 88))); graphNodes.Add(new GraphNode("gg", new Point(40, 2))); graphNodes.Add(new GraphNode("hh", new Point(52, 5))); RangeTree2D rangeTree2D = new RangeTree2D(graphNodes); TreeNode <GraphNode> root = rangeTree2D.Root; Assert.IsNotNull(rangeTree2D); Assert.IsNotNull(root); List <GraphNode> selected = rangeTree2D.GetAllInRange(new Point(2, 4), new Point(10, 10)); Assert.IsNotNull(rangeTree2D); Assert.AreEqual(3, selected.Count); List <GraphNode> err = null; try { Console.WriteLine("Trying to make an error"); err = rangeTree2D.GetAllInRange(new Point(), new Point()); } catch (Exception e) { Console.WriteLine("OK: " + e.Message); Assert.IsNull(err); } }
private void DisableNodes(Point first, Point second) { List <GraphNode> result = new List <GraphNode>(); rangeTree = new RangeTree2D(graphNodes); if (second.X <= first.X && second.Y <= first.Y) { result = rangeTree.GetAllInRange(second, first); // pokud je druhej mensi nez prvni, prohodit } else { result = rangeTree.GetAllInRange(first, second); } foreach (var graphNode in result) // projit vsechny vysledne vrcholy { INode n = g.FindNode(graphNode.Key); foreach (var follower in n.GetFollowers()) // a zakazat vsechny jejich hrany { follower.DisableEdge(); } } }