Example #1
0
        public void AllVerticesDiscovered(IGraph <int> graph)
        {
            var visitor = new BasicVisitor <int>();

            DFSTraversal.Traverse(graph, 0, visitor);

            Assert.That(visitor.DiscoveredVertices, Is.EquivalentTo(graph.Vertices));
        }
Example #2
0
        public static async Task TranslateAsync(string name, Stream input, Stream output)
        {
            BasicVisitor program = new BasicVisitor(name);

            foreach (BasicLine line in await BasicStream.ReadAsync(input))
            {
                line.Accept(program);
            }

            string outputCode = program.ToString();

            byte[] rawOutput = Encoding.UTF8.GetBytes(outputCode.ToString());
            await output.WriteAsync(rawOutput, 0, rawOutput.Length);
        }