Beispiel #1
0
        public void visualize(bool isLabeled = true, System.Windows.Forms.Panel panel = null)
        {
            Microsoft.Msagl.Drawing.Graph g = new Microsoft.Msagl.Drawing.Graph("PlanningProblem Transition Graph of variable " + variable);
            foreach (var item in vertices)
            {
                var node = g.AddNode(item.ToString());
                if (item == goalValue)
                {
                    node.Attr.FillColor = Microsoft.Msagl.Drawing.Color.Yellow;
                }
            }
            if (isLabeled)
            {
                foreach (var item in edges)
                {
                    var e = g.AddEdge(item.from.ToString(), "Cond:" + item.outsideCondition.GetConditions().ToString() + "Eff:" + item.outsideEffect.GetConditions().ToString(), item.to.ToString());
                    if (!isEdgeRSE_Invertible(item))
                    {
                        e.Attr.Color = Microsoft.Msagl.Drawing.Color.Red;
                    }
                }
            }
            else
            {
                bool[,] isEdge = new bool[vertices.Count, vertices.Count];
                foreach (var item in edges)
                {
                    if (isEdge[item.from, item.to])
                    {
                        continue;
                    }
                    var e = g.AddEdge(item.from.ToString(), item.to.ToString());
                    if (!isEdgeRSE_Invertible(item))
                    {
                        e.Attr.Color = Microsoft.Msagl.Drawing.Color.Red;
                    }
                    isEdge[item.from, item.to] = true;
                }
            }

            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            viewer.Graph = g;
            if (panel == null)
            {
                KnowledgeVisualizerForm form = new KnowledgeVisualizerForm();
                form.SuspendLayout();
                viewer.Dock = System.Windows.Forms.DockStyle.Fill;
                form.Controls.Add(viewer);
                form.ResumeLayout();
                System.Windows.Forms.Application.Run(form);
            }
            else
            {
                viewer.Dock = System.Windows.Forms.DockStyle.Fill;
                panel.Controls.Clear();
                panel.Controls.Add(viewer);
            }
        }
Beispiel #2
0
        public void visualize(System.Windows.Forms.Panel panel = null, HashSet <int> invertibleVariables = null)
        {
            Graph g = new Graph("Causual Graph");

            foreach (var item in vertices)
            {
                var node = g.AddNode(item.ToString());
                if (invertibleVariables != null && !invertibleVariables.Contains(item))
                {
                    node.Attr.Color = Microsoft.Msagl.Drawing.Color.Red;
                }
                if (isMentionedInGoal[item])
                {
                    node.Attr.FillColor = Microsoft.Msagl.Drawing.Color.Yellow;
                }
            }
            for (int i = 0; i < isEdge.GetLength(0); i++)
            {
                for (int j = 0; j < isEdge.GetLength(1); j++)
                {
                    if (isEdge[i, j])
                    {
                        g.AddEdge(i.ToString(), j.ToString());
                    }
                }
            }

            GViewer viewer = new GViewer();

            viewer.Graph = g;
            viewer.CurrentLayoutMethod = LayoutMethod.MDS;
            if (panel == null)
            {
                KnowledgeVisualizerForm form = new KnowledgeVisualizerForm();
                form.SuspendLayout();
                viewer.Dock = System.Windows.Forms.DockStyle.Fill;
                form.Controls.Add(viewer);
                form.ResumeLayout();
                System.Windows.Forms.Application.Run(form);
            }
            else
            {
                viewer.Dock = System.Windows.Forms.DockStyle.Fill;
                panel.Controls.Clear();
                panel.Controls.Add(viewer);
            }
        }