Ejemplo n.º 1
0
        public void a060_BreadthFirstTraversalTest()
        {
            Wire[] wires = PrepareWireArray(8);
            wires[0].transform.position = new Vector3(0.5f, 0, 1);
            wires[0]._direction         = Wire.Direction.XZ_X;
            wires[1].transform.position = new Vector3(1.5f, 0, 1);
            wires[1]._direction         = Wire.Direction.XZ_X;
            wires[2].transform.position = new Vector3(2.5f, 0, 1);
            wires[2]._direction         = Wire.Direction.XZ_X;
            wires[3].transform.position = new Vector3(5.5f, 0, 5);
            wires[3]._direction         = Wire.Direction.XZ_X;
            wires[4].transform.position = new Vector3(5, 0, 5.5f);
            wires[4]._direction         = Wire.Direction.XZ_Z;
            wires[5].transform.position = new Vector3(5, 0, 6.5f);
            wires[5]._direction         = Wire.Direction.XZ_Z;
            wires[6].transform.position = new Vector3(4.5f, 0, 6);
            wires[6]._direction         = Wire.Direction.XZ_X;
            wires[7].transform.position = new Vector3(5.5f, 0, 6);
            wires[7]._direction         = Wire.Direction.XZ_X;

            GraphPath graphPath = GraphPath.Build(wires);
            //          7
            //          |
            //        8-6-9
            //          |
            // 0-1-2-3, 4-5

            List <GraphPathNode> path = graphPath.BreadthFirstTraversal(graphPath.GetNodeById(0));

            Assert.AreEqual(4, path.Count);
            Assert.AreEqual(0, path[0]._id);
            Assert.AreEqual(1, path[1]._id);
            Assert.AreEqual(2, path[2]._id);
            Assert.AreEqual(3, path[3]._id);

            List <GraphPathNode> path2 = graphPath.BreadthFirstTraversal(graphPath.GetNodeById(4));

            Assert.AreEqual(6, path2.Count);
            Assert.AreEqual(4, path2[0]._id);
            Assert.AreEqual(5, path2[1]._id);
            Assert.AreEqual(6, path2[2]._id);
            Assert.AreEqual(7, path2[3]._id);
            Assert.AreEqual(8, path2[4]._id);
            Assert.AreEqual(9, path2[5]._id);
        }