예제 #1
0
        public void should_get_sub_vertexes_for_one()
        {
            var       graph = new DAG <int>();
            const int from  = 0;
            const int to    = 1;

            graph.Add(from);
            graph.AddPath(from, to);

            var subOfTo = graph.GetSubOf(to);

            Assert.Equal(0, subOfTo.Length);

            var subOfFrom = graph.GetSubOf(from);

            Assert.Equal(1, subOfFrom.Length);
            Assert.Equal(to, subOfFrom[0]);
        }
예제 #2
0
        public void should_get_sub_vertexes_for_square()
        {
            var       graph = new DAG <int>();
            const int v0    = 0;
            const int v1    = 1;
            const int v2    = 2;
            const int v3    = 3;

            graph.AddPath(v0, v1);
            graph.AddPath(v0, v2);
            graph.AddPath(v1, v3);
            graph.AddPath(v2, v3);

            var subOf0 = graph.GetSubOf(v0);

            Assert.Equal(3, subOf0.Length);
        }