Esempio n. 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);
        }
Esempio n. 2
0
        public static void Visualize(PointProjectionSolver solver, Projection p = null, string name = "")
        {
            if (p == null)
            {
                p = solver.ProjectionScheme;
            }
            var gr  = GenerateOutGraph(p, true);
            var viz = new GraphVisualizer <PointProjectionSolver.ProjectedEdgeInfo, PointProjectionSolver.ProjectedNodeInfo>();

            viz.GetX = z => z.Data.Projection.X;
            viz.GetY = z => z.Data.Projection.Y;
            // viz.NodeCaption = z => z.Data.Original.Data.Location.ToString();
            viz.Window(500, gr, name);
        }
Esempio n. 3
0
        static void DrawProblem(int task)
        {
            var spec  = new ProblemsRepo().Get(task);
            var graph = Pathfinder.BuildGraph(spec);
            var viz   = new GraphVisualizer <EdgeInfo, NodeInfo>();

            viz.GetX = z => z.Data.Location.X;
            viz.GetY = z => z.Data.Location.Y;
            //viz.NodeCaption = z => z.Data.Location.ToString() + " ("+z.NodeNumber.ToString()+")";
            viz.NodeCaption = z => z.NodeNumber.ToString();

            //viz.EdgeCaption = z => z.Data.length.ToString();

            viz.Window(600, graph);
        }