コード例 #1
0
 public void ReturnsGraphEdgeCounterObject()
 {
     int[,] array = { { 0, 1 }, { 1, 0 } };
     Graph graph = new Graph(array);
     GraphEdgeCounter edgeCounter = new GraphEdgeCounter(graph);
     Assert.IsNotNull(edgeCounter);
 }
コード例 #2
0
 public void ThrowsExceptionWhenPassingGraphNullReference()
 {
     Graph graph = null;
     GraphEdgeCounter edgeCounter;
     Assert.Throws(typeof(ArgumentNullException), () =>
         {
             edgeCounter = new GraphEdgeCounter(graph);
         });
 }
コード例 #3
0
        public void CountsGraphEdgesConcurrentlyMoreThanOnce()
        {
            int[,] array = { { 0, 1 }, { 1, 0 } };
            Graph graph = new Graph(array);
            GraphEdgeCounter edgeCounter = new GraphEdgeCounter(graph);

            edgeCounter.CountConcurrently();
            Assert.DoesNotThrow(() => edgeCounter.CountConcurrently());
        }
コード例 #4
0
        public void CountsGraphEdgesConcurrently()
        {
            int[,] array = { { 0, 1 }, { 1, 0 } };
            Graph graph = new Graph(array);
            GraphEdgeCounter edgeCounter = new GraphEdgeCounter(graph);

            int numberOfEdges = edgeCounter.CountConcurrently();

            Assert.AreEqual(2, numberOfEdges);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: kejmil01/GraphEdgesCouting
        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();
        }