public void Generate_ReturnsTwoDimensionalArrayWithSpecifiedSize()
 {
     int size = 3;
     GraphArrayGenerator generator = new GraphArrayGenerator();
     var graphArray = generator.Generate(size);
     Assert.NotNull(graphArray);
     Assert.AreEqual(graphArray.Rank, 2);
 }
 public void Generate_ReturnedArrayIsFilledWithZeroOneValues()
 {
     int size = 1;
     GraphArrayGenerator generator = new GraphArrayGenerator();
     var graphArray = generator.Generate(size);
     Assert.GreaterOrEqual(graphArray[0, 0], 0);
     Assert.LessOrEqual(graphArray[0, 0], 1);
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            int numberOfVertices;
            Console.WriteLine("Enter the number of vertices: ");
            numberOfVertices = int.Parse(Console.ReadLine());

            GraphArrayGenerator generator = new GraphArrayGenerator();
            Graph graph = new Graph(generator.GenerateConcurrently(numberOfVertices));
            if (numberOfVertices < 16)
                Console.WriteLine("Graph\n{0}\n", graph.ToString());

            GraphEdgeCounter counter = new GraphEdgeCounter(graph);
            Stopwatch watch = new Stopwatch();
            watch.Start();
            int numberOfEdges = counter.Count();
            watch.Stop();
            Console.WriteLine("Number of edges: {0}\nTime(ms): {1}\n\n", numberOfEdges, watch.ElapsedMilliseconds);

            watch.Restart();
            numberOfEdges = counter.CountConcurrently();
            watch.Stop();
            Console.WriteLine("Multi-threaded\nNumber of edges: {0}\nTime(ms): {1}", numberOfEdges, watch.ElapsedMilliseconds);
            Console.Read();
        }