public void BidirectionalDisconnectTest()
        {
            SpaceGraph basic = new SpaceGraph();

            basic.CreateNode(0);
            basic.CreateNode(1);
            //0->1
            basic.Connect(0, 1);
            basic.Connect(1, 0);
            Assert.IsTrue(basic.Node(0).IsConnected(basic.Node(1)));
            Assert.IsTrue(basic.Node(1).IsConnected(basic.Node(0)));


            basic.Disconnect(0, 1);

            Assert.AreEqual(0, basic.Node(0).Edges.Count);
            Assert.AreEqual(0, basic.Node(1).Edges.Count);

            //1->0
            basic.Connect(0, 1);
            basic.Connect(1, 0);
            Assert.IsTrue(basic.Node(0).IsConnected(basic.Node(1)));
            Assert.IsTrue(basic.Node(1).IsConnected(basic.Node(0)));

            basic.Disconnect(1, 0);

            Assert.AreEqual(0, basic.Node(0).Edges.Count);
            Assert.AreEqual(0, basic.Node(1).Edges.Count);
        }
        public void DisconnectTest()
        {
            SpaceGraph basic = new SpaceGraph();

            basic.CreateNode(0);
            basic.CreateNode(1);
            basic.Connect(0, 1);
            Assert.IsTrue(basic.Node(0).IsConnected(basic.Node(1)));
            Assert.IsTrue(basic.Node(1).IsConnected(basic.Node(0)));

            basic.Disconnect(0, 1);
            Assert.IsFalse(basic.Node(0).IsConnected(basic.Node(1)));
            Assert.IsFalse(basic.Node(1).IsConnected(basic.Node(0)));
        }
        public void ConnectTest()
        {
            SpaceGraph basic = new SpaceGraph();

            basic.CreateNode(0);
            basic.CreateNode(1);
            basic.CreateNode(2);
            basic.Connect(0, 1);
            Assert.IsTrue(basic.Node(0).IsConnected(basic.Node(1)));
            Assert.IsTrue(basic.Node(1).IsConnected(basic.Node(0)));
            Assert.IsFalse(basic.Node(0).IsConnected(basic.Node(2)));

            Assert.AreEqual(basic.Node(0).Edges.Count, 1);
            Assert.AreEqual(basic.Node(1).Edges.Count, 1);
        }
        public void ReducePotentialValuesTest()
        {
            SpaceGraph valueGraph = new SpaceGraph();

            for (int i = 0; i < 6; i++)
            {
                valueGraph.CreateNode(i);
            }

            List <(int, int, int)> roomParams = new List <(int, int, int)>()
            {
                (0, 0, 1), (0, 1, 4), (2, 3, 1), (1, 2, 1), (1, 2, 1), (0, 2, 1)
            };

            valueGraph.AllNodes.ForEach(node =>
            {
                node.CPDistance    = roomParams[node.Id].Item1;
                node.Depth         = roomParams[node.Id].Item2;
                node.MaxNeighbours = roomParams[node.Id].Item3;
            });

            //map CP
            valueGraph.Connect(0, 1);
            valueGraph.Connect(1, 5);

            valueGraph.ReducePotentialValues();

            List <int> actual = valueGraph.AllNodes.SelectMany(x => x.Values.SelectMany(y => y.Select(z => z.Id))).ToList();

            valueGraph.AllNodes.ForEach(node => Trace.WriteLine(node.PrintConnections()));
            Trace.WriteLine(string.Join(", ", actual));
            ///////////////////////////////////  [0][                 1                ][    2       ][     3       ][       4     ][5]
            CollectionAssert.AreEqual(new int[] { 1, 0, 2, 3, 5, 0, 2, 4, 5, 0, 3, 4, 5, 0, 1, 3, 4, 5, 0, 1, 2, 4, 5, 0, 1, 2, 3, 5, 1 }.ToList(), actual);
        }
        public void TestInitialize()
        {
            testGraph = new SpaceGraph();

            for (int i = 0; i < 5; i++)
            {
                testGraph.CreateNode(i);

                int cpd   = (i < 3) ? 0 : i;
                int depth = (i == 0) ? 0 : i;
                int maxN  = (i == 0 || i == 4) ? 1 : 2;

                testGraph.Node(i).CPDistance    = cpd;
                testGraph.Node(i).Depth         = depth;
                testGraph.Node(i).MaxNeighbours = maxN;
            }
            //node: neighbours
            // 1 : 1
            // 2 : 2
            // 3 : 2
            // 4 : 1

            testGraph.Connect(0, 1);
            testGraph.Connect(1, 2);
            testGraph.Connect(2, 3);
            testGraph.Connect(3, 4);
        }
        public void IsCompletedTest()
        {
            SpaceGraph incomplete = new SpaceGraph();

            Trace.WriteLine(testGraph.ToString());
            Assert.IsTrue(testGraph.isComplete);

            incomplete.CreateNode(0);
            incomplete.CreateNode(1);
            incomplete.CreateNode(2);
            incomplete.CreateNode(3);

            incomplete.Connect(0, 3);
            incomplete.Connect(1, 2);

            Trace.WriteLine(incomplete.ToString());

            Assert.IsFalse(incomplete.isComplete);
        }
        public void TestInitialize()
        {
            testGraph = new SpaceGraph();

            for (int i = 0; i < rooms; i++)
            {
                testGraph.CreateNode(i);
            }

            generator = new BayesianSpaceGenerator();
            testGraph = generator.CriticalPathMapper(testGraph, cpl);
        }
        public void PathToTest()
        {
            SpaceGraph validGraph = new SpaceGraph();

            for (int i = 0; i < 6; i++)
            {
                validGraph.CreateNode(i);
            }

            validGraph.Connect(0, 2);
            validGraph.Connect(0, 5);
            validGraph.Connect(1, 4);
            validGraph.Connect(3, 5);
            validGraph.Connect(4, 5);

            Trace.WriteLine(validGraph.ToString());

            Assert.AreEqual(4, validGraph.PathTo(0, 1).Count);
            CollectionAssert.AreEqual(new int[] { 0, 5, 4, 1 }.ToList(), validGraph.PathTo(0, 1));
        }