Example #1
0
        public void SetUp()
        {
            //init graph with tree-like structure, so it will be easy to test operations on this graph.
            _graph = new AccessControlGraphRoot <TestNode>();
            //Adding to node subnodes from start to start+count;

            Action <int, int, int> add = (node, start, count) =>
            {
                var n = new TestNode(node);
                _graph.AddVerticesAndEdgeRange(
                    Enumerable.Range(start, count).ToList().ConvertAll(
                        i => new Edge <TestNode>(n, new TestNode(i))
                        )
                    );
            };

            add(1, 11, 4);
            add(11, 111, 4);
            add(12, 121, 4);
            add(13, 131, 4);
            add(14, 141, 4);

            //now we have 3-level tree with 4 subnodes on each node;
            //21 nodes, 20 edges
            Assert.True(_graph.Vertices.Count() == 21);
            Assert.True(_graph.Edges.Count() == 20);
        }
        public void SetUp()
        {
            Action act = () => {
                //init graph with tree-like structure, so it will be easy to test operations on this graph.
                _graph = new AccessControlGraphRoot <TestNode>();
                var edges = new List <Edge <TestNode> >();

                for (var i = 1; i < 10; i++)
                {
                    for (var j = 1; j < 10; j++)
                    {
                        edges.Add(new Edge <TestNode>(new TestNode(i), new TestNode(i * 10 + j)));
                        for (var k = 1; k < 10; k++)
                        {
                            edges.Add(new Edge <TestNode>(new TestNode(i * 10 + j), new TestNode(i * 100 + j * 10 + k)));
                            for (var q = 1; q < 10; q++)
                            {
                                edges.Add(new Edge <TestNode>(new TestNode(i * 100 + j * 10 + k), new TestNode(i * 1000 + j * 100 + k * 10 + q)));
                            }
                        }
                    }
                }
                _graph.AddVerticesAndEdgeRange(edges);
                Assert.That(_graph.Vertices.Count() == 9 + 9 * 9 + 9 * 9 * 9 + 9 * 9 * 9 * 9); //9 on each level of tree(4 levels)  =  7380 nodex
                Assert.That(_graph.Edges.Count() == 9 * 9 + 9 * 9 * 9 + 9 * 9 * 9 * 9);        //edges 7371
            };
            var creation = MeasureTimeSpan(act);                                               //00.00.00.06 - 00.00.00.08
        }
Example #3
0
 public void TearDown()
 {
     _graph = null;
 }