Exemple #1
0
        public void RouteEdges_Subgraphs()
        {
            //DisplayGeometryGraph.SetShowFunctions();

            Random random = new Random(1);
            int    ntest  = 20;

            for (int i = 0; i < ntest; i++)
            {
                int           numberOfSubgraphs        = 2 + random.Next(10);
                int           numberOfNodesInSubgraphs = 2 + random.Next(10);
                GeometryGraph graph = GraphGenerator.GenerateGraphWithSameSubgraphs(numberOfSubgraphs, numberOfNodesInSubgraphs);
                AddRootCluster(graph);
                SetRandomNodeShapes(graph, random);

                int additionalEdges = random.Next(10);
                for (int j = 0; j < additionalEdges; j++)
                {
                    Node source = graph.Nodes[random.Next(graph.Nodes.Count)];
                    Node target = graph.Nodes[random.Next(graph.Nodes.Count)];
                    Edge edge   = GraphGenerator.CreateEdge(source, target);
                    graph.Edges.Add(edge);
                }

                Layout(graph, random);
                //DisplayGeometryGraph.ShowGraph(graph);

                RouteEdges(graph, 5 * random.NextDouble());
                //DisplayGeometryGraph.ShowGraph(graph);
            }
        }
Exemple #2
0
        public void RouteEdges_SmallGrid()
        {
            //DisplayGeometryGraph.SetShowFunctions();

            Random random = new Random(1);
            int    ntest  = 20;

            for (int i = 0; i < ntest; i++)
            {
                GeometryGraph graph = GraphGenerator.GenerateSquareLattice(20 + random.Next(20));
                AddRootCluster(graph);
                SetRandomNodeShapes(graph, random);
                int additionalEdges = random.Next(20);

                for (int j = 0; j < additionalEdges; j++)
                {
                    Node source = graph.Nodes[random.Next(graph.Nodes.Count)];
                    Node target = graph.Nodes[random.Next(graph.Nodes.Count)];
                    Edge edge   = GraphGenerator.CreateEdge(source, target);
                    graph.Edges.Add(edge);
                }

                Layout(graph, random);
                //DisplayGeometryGraph.ShowGraph(graph);

                RouteEdges(graph, 5 * random.NextDouble());
                //DisplayGeometryGraph.ShowGraph(graph);
            }
        }
        public void CircleGraphDownwardConstraintTests()
        {
            GeometryGraph graph      = GraphGenerator.GenerateCircle(6);
            ISet <Node>   avoidNodes = new HashSet <Node>(graph.Nodes);

            Node firstNode = graph.Nodes.First();
            Node lastNode  = graph.Nodes.Last();

            //add some non-cyclic nodes
            Node node1 = GraphGenerator.CreateNode(graph.Nodes.Count);
            Node node2 = GraphGenerator.CreateNode(graph.Nodes.Count + 1);

            graph.Nodes.Add(node1);
            graph.Nodes.Add(node2);
            graph.Edges.Add(GraphGenerator.CreateEdge(firstNode, node1));
            graph.Edges.Add(GraphGenerator.CreateEdge(node2, lastNode));

            GraphGenerator.SetRandomNodeShapes(graph, random);
            LayoutAndValidate(graph, 2.5, avoidNodes);
        }