Beispiel #1
0
        static void DrawPathGraph(int task)
        {
            var fname = string.Format("...\\..\\..\\problems\\{0:D3}.spec.txt", task);
            var spec  = ProblemSpec.Parse(File.ReadAllText(fname));
            var r     = Pathfinder.BuildGraph(spec);

            var lens = r.Edges.Select(z => z.Data.length).OrderBy(z => z).ToList();

            var matrix = new PathStat[r.NodesCount, r.NodesCount];

            foreach (var e in Pathfinder.FindAllPathes(r, 1, 0.7))
            {
                var i = e.FirstEdge.From.NodeNumber;
                var j = e.LastEdge.To.NodeNumber;
                if (matrix[i, j] == null)
                {
                    matrix[i, j] = new PathStat();
                }
                matrix[i, j].pathes.Add(e);
            }


            var gr = new Graph <PathStat, NodeInfo>(r.NodesCount);

            for (int i = 0; i < gr.NodesCount; i++)
            {
                gr[i].Data = r[i].Data;
            }

            for (int i = 0; i < gr.NodesCount; i++)
            {
                for (int j = 0; j < gr.NodesCount; j++)
                {
                    if (matrix[i, j] != null)
                    {
                        gr.NonDirectedConnect(i, j, matrix[i, j]);
                    }
                }
            }

            var viz = new GraphVisualizer <PathStat, NodeInfo>();

            viz.GetX = z => (double)z.Data.Location.X;
            viz.GetY = z => (double)z.Data.Location.Y;

            Func <PathStat, string> stat = z => z.pathes.Count().ToString();;

            viz.EdgeCaption = z => stat(z.Data);
            viz.NodeCaption = z => z.Data.Location.ToString();


            viz.Window(500, gr);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var problem = File.ReadAllText("../../../problems/049.spec.txt");
            var spec    = ProblemSpec.Parse(problem);

            var solver   = new ConstructorSolver(spec);
            var solution = solver.Work();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var form = new PolygonsAndSegmentsForm();

            form.SetData(solution.Polygons, new Segment[0]);
            Application.Run(form);
        }
Beispiel #3
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            var spec =
                @"1
10
-4267/58289,-11692/524601
469/1672,36437/52668
174/1001,1
0,1
0,23096929/23647932
-38493988/94603047,30998098/31534349
-96477/233156,156742/291445
-27719/58289,28517/58289
-751181/1806959,746582/1806959
-39957373/94603047,-532478/31534349
11
-4267/58289,-11692/524601 -27719/58289,28517/58289
-4267/58289,-11692/524601 -39957373/94603047,-532478/31534349
0,52/63 0,1
-39957373/94603047,-532478/31534349 -38493988/94603047,30998098/31534349
-4267/58289,-11692/524601 469/1672,36437/52668
469/1672,36437/52668 174/1001,1
0,52/63 9380/51293,286093/293769
-27719/58289,28517/58289 174/1001,1
469/1672,36437/52668 0,52/63
9380/51293,286093/293769 -38493988/94603047,30998098/31534349
0,1 174/1001,1
";

            var problem  = ProblemSpec.Parse(spec);
            var polygons = PolygonFinder.GetRealPolygons(problem);

            var painter = new Painter();

            problem.Segments = polygons[8].Segments;
            painter.Paint(e.Graphics, e.ClipRectangle.Height, problem);
            Update();
        }