public void FindLowestCoseNode_ReturnsNull_WhenAllItemsAreInProcessedList()
        {
            var testNode1 = new Node <string>("A");
            var testNode2 = new Node <string>("B");
            var testNode3 = new Node <string>("C");
            var testNode4 = new Node <string>("D");
            var testNode5 = new Node <string>("E");

            var testDictionary = new Dictionary <Node, (uint, Node)>();

            testDictionary.Add(testNode1, (99, null));
            testDictionary.Add(testNode2, (99, null));
            testDictionary.Add(testNode3, (99, null));
            testDictionary.Add(testNode4, (99, null));
            testDictionary.Add(testNode5, (99, null));

            var testProcessedList = new List <Node>()
            {
                testNode1, testNode2, testNode3, testNode4, testNode5
            };

            var result = GraphFunctions.FindLowestCostNode(testDictionary, testProcessedList);

            Assert.AreEqual(null, result);
        }
        public void GetNeighbours_ReturnsEmptyQueue_WhenGraphIsEmptyAndValidSearchItem()
        {
            Graph testGraph = new Graph(new List <Edge>(), new List <Node>());

            var result = GraphFunctions.GetNeighbours <string>(testGraph, "");

            Assert.AreEqual(0, result.Count);
        }
        public void BreadthFirstSearch_ReturnsFalse_WhenGraphDoesNotContainSearchItem(string searchItem)
        {
            Graph testGraph = CreateWeightFreeTestGraph();

            var result = GraphFunctions.BreadthFirstSearch <string>(testGraph, searchItem);

            Assert.IsFalse(result);
        }
        public void GetNeighbours_ReturnsCorrectQueue_WhenGraphAndSearchItemAreValid(string searchItem, string[] expectedResult)
        {
            Graph testGraph = CreateWeightFreeTestGraph();

            var result = GraphFunctions.GetNeighbours <string>(testGraph, searchItem);

            Assert.AreEqual(expectedResult, result.ToArray());
        }
        public void GetNextLowestCostNeighbour_ReturnsNull_WhenStartItemNotFound(Node <string> startNode)
        {
            var testGraph = CreateWeightedTestGraph();

            var result = GraphFunctions.GetNextLowestCostNeighbour(testGraph, startNode);

            Assert.AreEqual(new ValueTuple <Node, int?>(null, null), result);
        }
        public void FindLowestCostNode_ThrowsNullArgumentException_WhenDictionaryIsNull()
        {
            Dictionary <Node, ValueTuple <uint, Node> > testDictionary = null;
            var testProcessedList = new List <Node>()
            {
            };

            Assert.That(() => GraphFunctions.FindLowestCostNode(testDictionary, testProcessedList), Throws.ArgumentNullException);
        }
        public void Dijkstra_ReturnsNull_WhenSearchItemIsNotFound()
        {
            var testGraph      = CreateWeightedTestGraph();
            var expectedResult = new ValueTuple <List <string>, uint>(null, 0);

            var result = GraphFunctions.Dijkstra <string>(testGraph, "NotValid");

            Assert.AreEqual(expectedResult, result);
        }
        public void FindLowestCostNode_ThrowsNullArgumentException_WhenProcessedListIsNull()
        {
            var testDictionary = new Dictionary <Node, (uint, Node)>();

            testDictionary.Add(new Node <string>("B"), (99, null));
            List <Node> testProcessedList = null;

            Assert.That(() => GraphFunctions.FindLowestCostNode(testDictionary, testProcessedList), Throws.ArgumentNullException);
        }
        public void FindLowestCostNode_ThrowsArgumentException_WhenDictionaryIsEmpty()
        {
            var testDictionary = new Dictionary <Node, (uint, Node)>()
            {
            };
            var testProcessedList = new List <Node>()
            {
            };

            Assert.That(() => GraphFunctions.FindLowestCostNode(testDictionary, testProcessedList), Throws.ArgumentException);
        }
Example #10
0
    private void Update()
    {
        float          time = Time.time;
        GraphFunctions f    = functions[(int)functionName];

        for (int i = 0, z = 0; z < numPoints; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < numPoints; x++, i++)
            {
                float u = (x + 0.5f) * step - 1f;
                temp[i].localPosition = f(u, v, time);
            }
        }
    }
Example #11
0
        public void GetNextLowestCostNeighbour_ReturnsLowestNode_WhenStartNodeFound(int startNodeIndex, int[] searchedNodeIndexes, int expectedResultNodeIndex, int expectedResultWeight)
        {
            var testGraph = CreateWeightedTestGraph();
            ValueTuple <Node, int> expectedResult = new ValueTuple <Node, int>(testGraph.Nodes[expectedResultNodeIndex], expectedResultWeight);
            List <Node>            searchedNodes  = new List <Node>();

            foreach (var index in searchedNodeIndexes)
            {
                searchedNodes.Add(testGraph.Nodes[index]);
            }

            var result = GraphFunctions.GetNextLowestCostNeighbour(testGraph, testGraph.Nodes[startNodeIndex], searchedNodes);

            Assert.AreEqual(expectedResult, result);
        }
    private void Update()
    {
        float          t    = Time.time;
        GraphFunctions f    = functions[(int)function];
        float          step = 2f / _resolution;

        for (int i = 0, z = 0; z < _resolution; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < _resolution; x++, i++)
            {
                float u = (x + 0.5f) * step - 1f;
                points[i].localPosition = f(u, v, t);
            }
        }
    }
Example #13
0
    private void Update()
    {
        var t = 2f * Time.time;

        _graphFunction = GraphFunctions.Set(functionName);

        var step = 2f / resolution;

        for (int i = 0, z = 0; z < resolution; z++)
        {
            var v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < resolution; x++, i++)
            {
                var u = (x + 0.5f) * step - 1f;
                _points[i].localPosition = _graphFunction(u, v, t);
            }
        }
    }
Example #14
0
        public void FindLowestCoseNode_ReturnsFirstNode_WhenAllWeightsAreEqual()
        {
            var testNode       = new Node <string>("A");
            var testDictionary = new Dictionary <Node, (uint, Node)>();

            testDictionary.Add(testNode, (99, null));
            testDictionary.Add(new Node <string>("B"), (99, null));
            testDictionary.Add(new Node <string>("C"), (99, null));
            testDictionary.Add(new Node <string>("D"), (99, null));
            testDictionary.Add(new Node <string>("E"), (99, null));
            var testProcessedList = new List <Node>()
            {
            };

            var result = GraphFunctions.FindLowestCostNode(testDictionary, testProcessedList);

            Assert.AreEqual(testNode, result);
        }
    private void Update()
    {
        float t = Time.time;

        GraphFunctions[] functions = { SineFunction, Sine2dFunction, SineWave, MultiSineFunction, MultiSine2DFunction, Ripple, Cylinder, Sphere, Torus, Eggbasket };

        GraphFunctions f    = functions[(int)function];
        float          step = 2f / resolution;

        for (int i = 0, z = 0; z < resolution; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < resolution; x++, i++)
            {
                float u = (x + 0.5f) * step - 1f;
                points[i].localPosition = f(u, v, t);
            }
        }
    }
Example #16
0
        private void Action_btn_Click(object sender, EventArgs e)
        {
            GraphFunctions g = new GraphFunctions();

            if (g.CheckGuard(GList, Convert.ToInt32(end_textBox.Text)))
            {
                result_label.Text = "ДА";
                BadAreas_textbox.Clear();
                BadAreas_textbox.Visible = false;
            }
            else
            {
                BadAreas_textbox.Clear();
                result_label.Text        = "НЕТ";
                BadAreas_textbox.Visible = true;
                BadAreas_textbox.Lines   = g.DictionaryToStringArray(g.CheckBadGuardAreas
                                                                         (GList, Convert.ToInt32(end_textBox.Text))).ToArray();
            }
        }
Example #17
0
        public void BreadthFirstSearch_ThrowsArgumentNullException_WhenSearchItemIsNull()
        {
            Graph testGraph = new Graph(new List <Edge>(), new List <Node>());

            Assert.That(() => GraphFunctions.BreadthFirstSearch <string>(testGraph, null), Throws.ArgumentNullException);
        }
Example #18
0
        public void BreadthFirstSearch_ThrowsArgumentNullException_WhenGraphIsNull()
        {
            Graph testGraph = null;

            Assert.That(() => GraphFunctions.BreadthFirstSearch <string>(testGraph, ""), Throws.ArgumentNullException);
        }
Example #19
0
        public void GetNeighbours_ThrowsArgumentNullException_WhenGraphIsNull()
        {
            Graph testGraph = null;

            Assert.That(() => GraphFunctions.GetNeighbours <string>(testGraph, ""), Throws.ArgumentNullException);
        }
Example #20
0
        public void Dijkstra_ThrowsArgumentNullException_WhenGraphIsNull()
        {
            Graph testGraph = null;

            Assert.That(() => GraphFunctions.Dijkstra <string>(testGraph, ""), Throws.ArgumentNullException);
        }
Example #21
0
        public void Dijkstra_ReturnsShortestPath_WhenVariablesAreValid(Graph testGraph, string searchItem, ValueTuple <List <string>, uint> expectedResult)
        {
            var result = GraphFunctions.Dijkstra <string>(testGraph, searchItem);

            Assert.AreEqual(expectedResult, result);
        }
Example #22
0
        public void GetNextLowestCostNeighbour_ThrowsNullArgumentException_WhenGraphIsNull()
        {
            Graph testGraph = null;

            Assert.That(() => GraphFunctions.GetNextLowestCostNeighbour(testGraph, new Node <string>("Payload")), Throws.ArgumentNullException);
        }
Example #23
0
        public void GetNextLowestCostNeighbour_ThrowsNullArgumentException_WhenSearchItemIsNull()
        {
            Graph testGraph = new Graph(new List <Edge>(), new List <Node>());

            Assert.That(() => GraphFunctions.GetNextLowestCostNeighbour(testGraph, null), Throws.ArgumentNullException);
        }