Ejemplo n.º 1
0
        public void TestAddingIsolatedVertex()
        {
            var graph = FactoryGraph <string> .GetGraph("A");

            var graph2 = FactoryGraph <string> .GetGraph();

            graph2.AddVertex("A");
            Assert.AreEqual(graph, graph2);
        }
Ejemplo n.º 2
0
        public void TestCountHashSet()
        {
            var graph = FactoryGraph <string> .GetGraph("A");

            graph.AddVertex("B", new HashSet <string>(new[] { "A" }));
            graph.AddVertex("C", new HashSet <string>(new[] { "A" }));
            graph.AddVertex("D", new HashSet <string>(new[] { "C" }));
            Assert.AreEqual(graph.Count, graph.SetVertex.Count);
        }
Ejemplo n.º 3
0
        public void TestViewInDepth()
        {
            var graph = FactoryGraph <string> .GetGraph("A");

            graph.AddVertex("B", new HashSet <string>(new[] { "A" }));
            var count = 0;

            graph.ViewDepth("A", (s => count++));
            Assert.AreEqual(count, graph.Count);
        }
Ejemplo n.º 4
0
        public void TestRemoveAdding()
        {
            var graph = FactoryGraph <int> .GetGraph(1);

            var graph2 = FactoryGraph <int> .GetGraph(1);

            graph.AddVertex(2, new HashSet <int>(new[] { 1 }));
            graph.RemoveVertex(2);
            Assert.AreEqual(graph, graph2);
        }
Ejemplo n.º 5
0
        public void TestCountEquals()
        {
            var graph = FactoryGraph <int> .GetGraph(1);

            graph.AddVertex(2, new HashSet <int>(new[] { 1 }));
            graph.RemoveVertex(2);
            var graph2 = FactoryGraph <int> .GetGraph(1);

            Assert.AreEqual(graph.Count, graph2.Count);
        }
Ejemplo n.º 6
0
        public void TestViewUnconnectedGraph()
        {
            var graph = FactoryGraph <string> .GetGraph("A");

            graph.AddVertex("B", new HashSet <string>(new[] { "A" }));
            graph.AddVertex("C");
            var countForViewWidth = 0;
            var countForViewDepth = 0;

            graph.ViewWidth("A", (s => countForViewWidth++));
            graph.ViewWidth("A", (s => countForViewDepth++));
            Assert.AreEqual(countForViewWidth, countForViewDepth, graph.Count);
        }
Ejemplo n.º 7
0
        public void TestMatrixEquals()
        {
            var graph = FactoryGraph <string> .GetGraph("A");

            graph.AddVertex("B", new HashSet <string>(new[] { "A" }));
            var matrixGraph = graph.ToAdjacencyMatrix();

            bool[,] matrix = { { false, true }, { true, false } };
            bool flagEquals = true;

            for (var i = 0; i < matrix.GetLength(0); ++i)
            {
                for (var j = 0; j < matrix.GetLength(1); j++)
                {
                    if (!matrix[i, j].Equals(matrixGraph[i, j]))
                    {
                        flagEquals = false;
                    }
                }
            }
            Assert.AreEqual(flagEquals, true);
        }