Esempio n. 1
0
        public void GraphTests_ShowGive25Records()
        {
            var vertices = new int[] { 'A', 'B', 'C', 'D', 'E' };
            var graph    = new AdjacencyMatrix <int>(vertices);

            for (int i = 0; i < vertices.Length; i++)
            {
                for (int j = 0; j < vertices.Length; j++)
                {
                    graph.AddEdge(vertices[i], vertices[j]);
                }
            }

            Assert.AreEqual(25, graph.GetEdges().Count);

            var matrix = graph.GetAdjacencyMatrix();
            var length = matrix.GetUpperBound(0);

            for (int i = 0; i <= length; i++)
            {
                for (int j = 0; j <= length; j++)
                {
                    Trace.Write($"{matrix[i, j]} ");
                }
                Trace.WriteLine(string.Empty);
            }
        }
Esempio n. 2
0
        public void GraphTests_ShowGive2Record()
        {
            var vertices = new int[] { 'A', 'B', 'C', 'D', 'E' };
            var graph    = new AdjacencyMatrix <int>(vertices);

            graph.AddEdge('A', 'B');

            Assert.AreEqual(2, graph.GetEdges().Count);
        }