Ejemplo n.º 1
0
 public void Update()
 {
     Statistics.Clear();
     if (Ready)
     {
         Traversal.Run();
         if (TilesetOptions.DebugDrawBounds)
         {
             Traversal.DrawDebug();
         }
     }
 }
        public void CheckTraversalStop()
        {
            List <int> vertices = new List <int>();
            var        tInDepth = new Traversal(g);

            tInDepth.NewVertex += (sender, e) =>
            {
                if (e == 3)
                {
                    // Stop traverse graph
                    tInDepth.Stop();
                    return;
                }
                vertices.Add(e);
            };
            tInDepth.Run();
            CollectionAssert.AreEqual(vertices, new List <int> {
                0, 1, 7
            });
        }
        public void CheckTraversalRun()
        {
            List <int> vertices = new List <int>();
            // Traversal(g) is equvalent to the  Traversal<DFS>(g)
            var tInDepth = new Traversal(g);

            // Subscribe to the NewVertex event to get the path to the graph
            tInDepth.NewVertex += (sender, e) => vertices.Add(e);
            tInDepth.Run();
            CollectionAssert.AreEqual(vertices, new List <int> {
                0, 1, 7, 3, 2, 4, 5, 6
            });

            vertices.Clear();

            var tInBreadth = new Traversal <BFS>(g);

            tInBreadth.NewVertex += (sender, e) => vertices.Add(e);
            tInBreadth.Run();
            CollectionAssert.AreEqual(vertices, new List <int> {
                0, 1, 7, 3, 2, 6, 4, 5
            });
        }