Esempio n. 1
0
        public Form1()
        {
            gViewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            graf    = new Microsoft.Msagl.Drawing.Graph("Graph");

            InitializeComponent();
        }
Esempio n. 2
0
        public static Bitmap Draw(IEnumerable <Node> nodes)
        {
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("MyGraph");

            foreach (var node in nodes)
            {
                graph.AddNode(node.Body);

                foreach (var edge in node.OutEdges)
                {
                    graph.AddEdge(node.Body, edge.Key, edge.To.Body);
                }
            }
            //graph.AddEdge("A", "B");
            //graph.AddEdge("A", "B");
            //graph.AddEdge("B", "C");
            //graph.AddNode("He");
            //graph.AddNode("He");


            //graph.FindNode("A").Attr.FillColor = Microsoft.Msagl.Drawing.Color.Red;
            //graph.FindNode("B").Attr.FillColor = Microsoft.Msagl.Drawing.Color.Blue;
            Microsoft.Msagl.GraphViewerGdi.GraphRenderer renderer = new Microsoft.Msagl.GraphViewerGdi.GraphRenderer(graph);
            renderer.CalculateLayout();
            int    k      = 150;
            int    width  = 50;
            Bitmap bitmap = new Bitmap(width * k, (int)(graph.Height * (width / graph.Width)) * k, PixelFormat.Format32bppPArgb);

            renderer.Render(bitmap);
            return(bitmap);
        }
Esempio n. 3
0
 public static void view(List <List <string> > graphdetails)
 {
     //create a form
     System.Windows.Forms.Form form = new System.Windows.Forms.Form();
     //create a viewer object
     Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
     //create a graph object
     Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
     //create the graph content
     foreach (List <string> L in graphdetails)
     {
         graph.AddNode(L[0]);
         for (int i = 1; i < L.Count; i++)
         {
             graph.AddEdge(L[i], L[0]);
         }
     }
     //bind the graph to the viewer
     viewer.Graph = graph;
     //associate the viewer with the form
     form.Width  = 300;
     form.Height = 300;
     form.Text   = "Graph";
     form.SuspendLayout();
     viewer.Dock = System.Windows.Forms.DockStyle.Fill;
     form.Controls.Add(viewer);
     form.ResumeLayout();
     //show the form
     form.Show();
 }
Esempio n. 4
0
 private static void AllocateDebugCurves(Microsoft.Msagl.Drawing.Graph g)
 {
     g.DebugBezierCurves = new List <Microsoft.Msagl.Splines.CubicBezierSegment>();
     g.DebugBoxes        = new List <Parallelogram>();
     g.DebugEllipses     = new List <Ellipse>();
     g.DebugLines        = new List <LineSegment>();
 }
Esempio n. 5
0
        private bool processFile(string fileloc)
        {
            try
            {
                this.graf = new Graf();
                Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
                Microsoft.Msagl.Drawing.Graph          graph  = new Microsoft.Msagl.Drawing.Graph("graph");
                string[] isitxt = File.ReadAllLines(fileloc);

                for (int i = 1; i < isitxt.Length; i++)
                {
                    string[] temp = isitxt[i].Split(' ');
                    graf.addNode(temp[0], temp[1]);
                    var Edge = graph.AddEdge(temp[0], temp[1]);
                    Edge.Attr.ArrowheadAtTarget = Microsoft.Msagl.Drawing.ArrowStyle.None;
                    Edge.Attr.ArrowheadAtSource = Microsoft.Msagl.Drawing.ArrowStyle.None;
                }

                viewer.Graph = graph;
                visualisasiGraf.SuspendLayout();
                viewer.Dock = DockStyle.Fill;
                visualisasiGraf.Controls.Add(viewer);
                visualisasiGraf.ResumeLayout();
                visualisasiGraf.Show();

                return(true);
            }
            catch (Exception ee)
            {
                MessageBox.Show("there was an error: " + ee);
                return(false);
            }
        }
        /// <summary>
        /// Визуализация графа
        /// </summary>
        private void CreateGraph()
        {
            if (vertex > 0)
            {
                System.Windows.Forms.Form form = new System.Windows.Forms.Form();
                Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
                Microsoft.Msagl.Drawing.Graph          graph  = new Microsoft.Msagl.Drawing.Graph("graph");


                for (int i = 0; i < vertex; i++)                                                                        //циклы для прохода по массиву
                {
                    for (int j = 0; j < vertex; j++)
                    {
                        if (matrix[i, j] > 0)
                        {
                            graph.AddEdge(Convert.ToString(i), Convert.ToString(j)).Attr.Color =                        //добавление ребра и смена цвета
                                                                                                 Microsoft.Msagl.Drawing.Color.ForestGreen;
                            graph.FindNode(Convert.ToString(i)).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Teal;    //смена цвета вершины
                        }
                    }
                }
                viewer.Graph = graph;                                   //отображение выбранного графа
                form.SuspendLayout();                                   //приостанавливаем логику макета для добавления панели управления
                viewer.Dock = System.Windows.Forms.DockStyle.Fill;      //возвращает границы элемента управления
                form.Controls.Add(viewer);                              //добавляем панель управления
                form.ResumeLayout();                                    //возобновляем логику макета
                form.ShowDialog();                                      //показать форму
            }
            else
            {
                MessageBox.Show("Задайте количество вершин");
            }
        }
Esempio n. 7
0
        public void Draw(Graph G, List <string> mkTanpaPrereq)
        {
            Form form = new Form();

            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            Microsoft.Msagl.Drawing.Graph          graph  = new Microsoft.Msagl.Drawing.Graph("graph");

            for (int i = 0; i < mkTanpaPrereq.Count(); ++i)
            {
                graph.AddNode(mkTanpaPrereq[i]);
                graph.FindNode(mkTanpaPrereq[i]).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Gray;
            }
            for (int i = 0; i < G.GetNodesCount(); ++i)
            {
                for (int j = 0; j < G.GetNodes(i).GetPrereqCount(); ++j)
                {
                    graph.AddEdge(G.GetNodes(i).GetPrereq(j), G.GetNodes(i).GetVal());
                }
            }
            viewer.Graph = graph;
            form.SuspendLayout();
            viewer.Dock      = DockStyle.Fill;
            form.WindowState = FormWindowState.Maximized;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            form.ShowDialog();
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            var gviewer = new GViewer();
            var form    = TestFormForGViewer.FormStuff.CreateOrAttachForm(gviewer, null);

            gviewer.NeedToCalculateLayout = false;
            var drawingGraph = new Microsoft.Msagl.Drawing.Graph();
            var a            = drawingGraph.AddNode("a");
            var b            = drawingGraph.AddNode("b");

            drawingGraph.AddEdge("a", "b");
            var geometryGraph = drawingGraph.CreateGeometryGraph();

            SetNodeBoundary(a);
            SetNodeBoundary(b);

            // leave node "a" at (0, 0), but move "b" to a new spot
            b.GeometryNode.Center = new Point(50, 50);
            var router = new Microsoft.Msagl.Routing.SplineRouter(geometryGraph, new EdgeRoutingSettings());

            router.Run();
            geometryGraph.UpdateBoundingBox();
            gviewer.Graph = drawingGraph;
            Application.Run(form);
        }
        private void CbLayoutIndex_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var cb = sender as ComboBox;

            if (cb == null || theGraph == null || theViewer == null)
            {
                return;
            }

            try
            {
                // try to remember preferred setting
                if (this.theReferable != null && preferredPresetIndex != null && cb.SelectedIndex >= 0)
                {
                    this.preferredPresetIndex[this.theReferable] = cb.SelectedIndex;
                }

                // re-draw (brutally)
                _creatorOptions.LayoutIndex = cb.SelectedIndex;
                theGraph        = CreateGraph(_package, _submodel, _creatorOptions);
                theViewer.Graph = null;
                theViewer.Graph = theGraph;
            }
            catch (Exception ex)
            {
                AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// displays the database
        /// </summary>
        /// <param name="db"></param>
        /// <param name="curves"></param>
        static public void ShowDataBase(Database db, params Splines.ICurve[] curves)
        {
            Microsoft.Msagl.Drawing.Graph g = new Microsoft.Msagl.Drawing.Graph("");
            AllocateDebugCurves(g);

            Microsoft.Msagl.Splines.Rectangle graphBox = new Microsoft.Msagl.Splines.Rectangle(db.Anchors[0].LeftTop);

            List <ICurve> cl = new List <ICurve>(curves);

            foreach (Anchor a in db.Anchors)
            {
                graphBox.Add(a.LeftTop);
                graphBox.Add(a.RightBottom);
                cl.Add(a.PolygonalBoundary);
            }

            AddCurvesToGraph(cl, g);

            Microsoft.Msagl.Point del = (graphBox.LeftBottom - graphBox.RightTop) / 10;
            graphBox.Add(graphBox.LeftBottom + del);
            graphBox.Add(graphBox.RightTop - del);
            GeometryGraph gg = new GeometryGraph();

            gg.BoundingBox  = graphBox;
            g.DataBase      = db;
            g.GeometryGraph = gg;
            DisplayGraph(g);
            db.nodesToShow = null;
        }
Esempio n. 11
0
        private void btn_Add_Click(object sender, EventArgs e)
        {
            if (rtb_AccName.Text.Length == 0)
            {
                return;
            }
            if (this.OG == null || this.GDraw == null)
            {
                return;
            }
            var toAdd = rtb_AccName.Text;

            if (this.OG.findNode(toAdd) != null)
            {
                lbl_Content.Text = "Akun dengan nama " + toAdd + " sudah terdapat pada Graph."; return;
            }

            OG.addNode(new Node(toAdd));
            this.GDraw = new Microsoft.Msagl.Drawing.Graph("graph");
            DrawGraph(this.GDraw, OG.getDrawInfo());
            gViewer1.Graph            = this.GDraw;
            gViewer1.OutsideAreaBrush = Brushes.White;
            gViewer1.ToolBarIsVisible = false;

            // Re-initialize dropdown menu
            accList  = new List <ItemCombo>();
            findList = new List <ItemCombo>();
            fromList = new List <ItemCombo>();
            toList   = new List <ItemCombo>();
            InitializeComboItems(accList, findList, fromList, toList, OG);
            lbl_Content.Text = "Akun dengan nama " + toAdd + " berhasil ditambahkan.";
        }
Esempio n. 12
0
        private void colorGraph(string[] input, List <Node> path)
        {
            //create a viewer object
            GViewer viewer = new GViewer();

            Microsoft.Msagl.Drawing.Graph graph1 = new Microsoft.Msagl.Drawing.Graph();

            for (int i = 1; i < input.Length; i++)
            {
                //create the graph content
                string[] content = input[i].Split((string[])null, StringSplitOptions.RemoveEmptyEntries);
                var      edge    = graph1.AddEdge(content[0], content[1]);
                edge.Attr.ArrowheadAtSource = Microsoft.Msagl.Drawing.ArrowStyle.None;
                edge.Attr.ArrowheadAtTarget = Microsoft.Msagl.Drawing.ArrowStyle.None;
                //foreach (Node n in path)
                //{
                //    string tmp = n.Name;
                //    //MessageBox.Show(n.Name);
                //    graph1.FindNode(tmp).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Aqua;
                //}
                //graph1.FindNode(path.First().Name).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Aquamarine;
                //if (dest != "")
                //{
                //   graph1.FindNode(dest).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Blue;
                //}
                //graph1.FindNode(dest).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Blue;
            }

            viewer.Graph = graph1;
            viewer.Name  = "viewer";
            viewer.Dock  = DockStyle.Fill;

            panelGraph.Controls.Clear();
            panelGraph.Controls.Add(viewer);
        }
Esempio n. 13
0
        public static void Draw(Graph graph)
        {
            //create a form
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            //create a viewer object
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object
            Microsoft.Msagl.Drawing.Graph g = new Microsoft.Msagl.Drawing.Graph("graph");
            //create the graph content
            var edges = graph.Vertices.Values.SelectMany(v => v.Successors.Select(s => (v.Name, s.Name)));

            foreach (var edge in edges)
            {
                g.AddEdge(edge.Item1, edge.Item2);
            }
            //bind the graph to the viewer
            viewer.Graph = g;
            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            form.Width  = 750;
            form.Height = 750;
            //show the form
            form.ShowDialog();
        }
        public void DrawGraph(List <List <int> > order, System.Windows.Controls.Image Graph)
        {
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");

            for (int i = 0; i < ListMatKul.Count; i++)
            {
                for (int j = 0; j < ListMatKul[i].PreRequisite.Count; j++)
                {
                    graph.AddEdge(ListMatKul[i].PreRequisite[j], ListMatKul[i].NamaMataKuliah);
                }
            }

            //Bitmap creation
            Microsoft.Msagl.GraphViewerGdi.GraphRenderer renderer = new Microsoft.Msagl.GraphViewerGdi.GraphRenderer(graph);
            renderer.CalculateLayout();
            int    width  = 1500;
            Bitmap bitmap = new Bitmap(width, (int)(graph.Height * (width / graph.Width)), System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

            renderer.Render(bitmap);

            //Convert and show the image
            BitmapSource image = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

            Graph.Source = image;
            bitmap.Dispose();

            AnimateBFS(order, Graph, graph);
        }
        private void stage_1_Entities_Identification_Click(object sender, EventArgs e)
        {
            Form form = new System.Windows.Forms.Form();

            form.Text = "Stage-1 Reverse Engineer : Entities";
            //create a viewer object
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            //create the graph content


            foreach (Relation rel  in _masterListRelations)
            {
                Microsoft.Msagl.Drawing.Node newNode = new Microsoft.Msagl.Drawing.Node(rel.relationName);
                newNode.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box;

                graph.AddNode(newNode);
            }



            //bind the graph to the viewer
            viewer.Graph = graph;
            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.Size = new Size(500, 500);
            form.ResumeLayout();
            //show the form
            form.Show();
        }
Esempio n. 16
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!this.loaded)
            {
                return;
            }

            Microsoft.Msagl.Drawing.Graph graph = gViewer1.Graph;
            //this bottom 2 loops are basically a REEESEEETTTT for the colours of the graph
            //colouring the nodes that are not the default colour
            foreach (Microsoft.Msagl.Drawing.Node element in graph.Nodes)
            {
                if (element.Attr.Color.A != 255 || element.Attr.Color.B != 0 || element.Attr.Color.G != 0 || element.Attr.Color.R != 0)
                {
                    element.Attr.Color = new Microsoft.Msagl.Drawing.Color((byte)0, (byte)0, (byte)0);
                }
            }
            //colouring the edges that are not the default colour
            foreach (Microsoft.Msagl.Drawing.Edge element in graph.Edges)
            {
                if (element.Attr.Color.A != 255 || element.Attr.Color.B != 0 || element.Attr.Color.G != 0 || element.Attr.Color.R != 0)
                {
                    element.Attr.Color = new Microsoft.Msagl.Drawing.Color((byte)0, (byte)0, (byte)0);
                }
            }

            if (g.manhattan.ContainsKey((textBox1.Text, textBox2.Text)))
            {
                //do the A* (AllStar method is about to be invoked)
                List <String> start = new List <String>();
                start.Add(textBox1.Text);
                String end = textBox2.Text;
                (List <String>, int)result = g.AllStar((start, g.manhattan[(start.Last(), end)]), end, new List <(List <String>, int)>());
Esempio n. 17
0
        //public DFA dfa;
        public DrawDfaWindow(DFA dfa)
        {
            InitializeComponent();
            //this.dfa = dfa;

            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            foreach (var state in dfa.States)
            {
                foreach (var key in state.Transitions.Keys)
                {
                    //var label = new Microsoft.Msagl.Drawing.Label();
                    //label.IsVisible = true;
                    //label.Text = key.ToString();
                    //Microsoft.Msagl.Drawing.Edge edge = new Microsoft.Msagl.Drawing.Edge(state.Name, key.ToString(), dfa.States[state.Transitions[key]].Name);
                    //graph.AddEdge()
                    graph.AddEdge(state.Name, key.ToString(), dfa.States[state.Transitions[key]].Name);
                }
                foreach (var finalState in dfa.FinalStates)
                {
                    // var node =
                    // graph.FindNode(dfa.States[finalState].Name).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Red;
                    //node.Attr.FillColor = Microsoft.Msagl.Drawing.Color.DodgerBlue;
                }
            }
            //Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //graph.AddEdge("A", "B");
            //graph.AddEdge("B", "C");
            gViewer.Graph = graph;
        }
Esempio n. 18
0
        /**
         * Metode untuk mewarnai graf
         */
        private void ColoringGraph(List <String> SearchResult, Graph G, Color c1, Color c2, Color c3, Color c4)
        {
            ClearColor();

            // Mewarnai sisi
            for (int i = 0; i < SearchResult.Count - 1; i++)
            {
                foreach (Edge E1 in G.Edges)
                {
                    if (E1.Source == SearchResult[i] && E1.Target == SearchResult[i + 1] ||
                        E1.Target == SearchResult[i] && E1.Source == SearchResult[i + 1])
                    {
                        E1.Attr.Color = c1;
                    }
                }
            }

            // Mewarnai simpul
            for (int i = 1; i < SearchResult.Count - 1; i++)
            {
                foreach (MSAGLNode N1 in G.Nodes)
                {
                    if (N1.Id == SearchResult[i])
                    {
                        N1.Attr.Color     = c2;
                        N1.Attr.FillColor = c3;
                    }
                }
            }

            ColorNode(Src, c4);
            ColorNode(Dest, c4);
            this.gViewer.Graph = G;
        }
 private void Form1_Load(object sender, EventArgs e)
 {
     viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
     viewer.CurrentLayoutMethod = Microsoft.Msagl.GraphViewerGdi.LayoutMethod.UseSettingsOfTheGraph;
     Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
     graph.LayoutAlgorithmSettings = new Microsoft.Msagl.Layout.MDS.MdsLayoutSettings();
     foreach (Edge E in G.allEdge)
     {
         graph.AddEdge((E.getFrom() + 1).ToString(), (E.getTo() + 1).ToString());
     }
     viewer.Graph = graph;
     foreach (var E in viewer.Graph.Edges)
     {
         Tuple <int, int> key = new Tuple <int, int>(Int32.Parse(E.Source) - 1, Int32.Parse(E.Target) - 1);
         dictEdge.Add(key, E);
         E.Attr.ArrowheadAtTarget = Microsoft.Msagl.Drawing.ArrowStyle.None;
     }
     viewer.ToolBarIsVisible = false;
     viewer.PanButtonPressed = true;
     Microsoft.Msagl.Drawing.Node nodeRaja = viewer.Graph.FindNode("1");
     if (nodeRaja != null)
     {
         nodeRaja.Attr.Shape     = Microsoft.Msagl.Drawing.Shape.Circle;
         nodeRaja.Attr.FillColor = Microsoft.Msagl.Drawing.Color.Fuchsia;
     }
     viewer.Size     = new Size(780, 500);
     viewer.Location = new Point(0, 0);
     this.Controls.Add(viewer);
     foreach (Command C in LC)
     {
         this.query_file_list.Items.Add(C.getApproach().ToString() + " " + C.getX().ToString() + " " + C.getY().ToString());
     }
 }
Esempio n. 20
0
        public DomainRelGraph(Engine searchEngine)
        {
            InitializeComponent();

            var graph   = new Microsoft.Msagl.Drawing.Graph("Domains");
            var allDoms = new Dictionary <int, string>();

            foreach (var domain in searchEngine.AllDomains)
            {
                var domainId = searchEngine.GetDomainID(domain);
                var nde      = graph.AddNode(domain);
                nde.LabelText = string.Format("{0} ({1})", domain, domainId);

                nde.Attr.Color = searchEngine.IsDomainLeaf(domainId)?
                                 Microsoft.Msagl.Drawing.Color.DarkBlue:
                                 Microsoft.Msagl.Drawing.Color.DarkGray;

                allDoms.Add(domainId, domain);
            }

            foreach (var domain in allDoms)
            {
                foreach (var link in searchEngine.GetDomainLinks(domain.Key))
                {
                    var rel = graph.AddEdge(domain.Value, allDoms[link.TargetDomain]);
                    rel.LabelText = link.TargetKey;
                }
            }

            gViewer.Graph = graph;
        }
Esempio n. 21
0
        private void addColorFromMatrix(int[,] colorMatrix)
        {
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer     = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            Microsoft.Msagl.Drawing.Graph          graph_pic2 = new Microsoft.Msagl.Drawing.Graph("graph");
            int n = node.Count;

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (i != j && i < j && graph[i, j] == 1)
                    {
                        var edge = graph_pic2.AddEdge(node[i], node[j]);
                        edge.Attr.ArrowheadAtSource = Microsoft.Msagl.Drawing.ArrowStyle.None;
                        edge.Attr.ArrowheadAtTarget = Microsoft.Msagl.Drawing.ArrowStyle.None;
                        if (colorMatrix[i, j] == 1)
                        {
                            edge.Attr.Color = Microsoft.Msagl.Drawing.Color.Red;
                            graph_pic2.FindNode(node[i]).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Magenta;
                            graph_pic2.FindNode(node[j]).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Magenta;
                        }
                    }
                }
            }

            viewer.Graph = graph_pic2;
            viewer.Name  = "graphViewer";
            viewer.Dock  = System.Windows.Forms.DockStyle.Fill;

            this.SuspendLayout();
            this.panelViewer.Controls.Clear();
            this.panelViewer.Controls.Add(viewer);
            this.ResumeLayout();
        }
Esempio n. 22
0
        public void DrawResult(Graph _graph)
        {
            timestamps.Reverse();
            List <string> distinct = timestamps.Distinct().ToList();

            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            Microsoft.Msagl.Drawing.Graph          graph  = new Microsoft.Msagl.Drawing.Graph("graph");
            for (int i = 0; i < distinct.Count; i++)
            {
                Console.WriteLine("\nSemester {0} :\n{1}", i + 1, distinct[i]);
            }
            for (int idx = 0; idx < distinct.Count - 1; idx++)
            {
                graph.AddEdge(distinct[idx], distinct[idx + 1]).Attr.Color = Microsoft.Msagl.Drawing.Color.Green;;
                int index = _graph.GetNodesIdx(distinct[idx]);
                for (int j = 0; j < _graph.GetNodes(index).GetPostreqCount(); j++)
                {
                    if (!(distinct[idx + 1].Equals(_graph.GetNodes(index).GetPostreq(j), StringComparison.Ordinal)))
                    {
                        graph.AddEdge(_graph.GetNodes(index).GetVal(), _graph.GetNodes(index).GetPostreq(j));
                    }
                }
            }

            viewer.Graph = graph;
            form.SuspendLayout();
            viewer.Dock      = System.Windows.Forms.DockStyle.Fill;
            form.WindowState = FormWindowState.Maximized;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            form.ShowDialog();
        }
Esempio n. 23
0
        private void btn_Browse_Click(object sender, EventArgs e) // Event btn_Browse di klik (Browse files) dan menggambarkan graph setelah berhasil di load file
        {
            var result = new System.Windows.Forms.OpenFileDialog();

            if (result.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string fileToOpen = result.FileName;
                Console.WriteLine(fileToOpen);
                this.GDraw = new Microsoft.Msagl.Drawing.Graph("graph");
                this.OG    = new Classes.Graph(fileToOpen);
                DrawGraph(this.GDraw, OG.getDrawInfo());
                gViewer1.Graph            = this.GDraw;
                gViewer1.OutsideAreaBrush = Brushes.White;
                gViewer1.ToolBarIsVisible = false;
                this.account      = null;
                this.findAccount  = null;
                this.mode         = -1;
                lbl_FileName.Text = "File Name: " + System.IO.Path.GetFileName(fileToOpen);

                // Initialize dropdown menu
                accList  = new List <ItemCombo>();
                findList = new List <ItemCombo>();
                fromList = new List <ItemCombo>();
                toList   = new List <ItemCombo>();
                InitializeComboItems(accList, findList, fromList, toList, OG);
            }
        }
Esempio n. 24
0
        public static void Visualisasi()
        {
            //create a form
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            //create a viewer object
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            //create the graph content

            //for (int i = 0; i < ReadFromFile.nEdge; i++) {
            //    graph.AddEdge(Char.ToString(ReadFromFile.EdgeData[i].Item1), Char.ToString(ReadFromFile.EdgeData[i].Item2));
            //}

            //for (int i = 0; i < ReadFromFile.nNode; i++) {
            //    if (BFS.Map.vertices[vertices.Keys.ElementAt(i)].neighbors.Keys.ElementAt(i)) {
            //        graph.FindNode(BFS.Map.vertices.Keys.ElementAt(i)).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Red;
            //    }
            //}

            //bind the graph to the viewer
            viewer.Graph = graph;
            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            //show the form
            form.ShowDialog();
        }
Esempio n. 25
0
        public static void ShowDependencies()
        {
            //create a form
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            form.Size = new System.Drawing.Size(1200, 800);
            //create a viewer object
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            //create the graph content

            foreach (var depender in _dependencies.Keys)
            {
                foreach (var dependentOn in _dependencies[depender])
                {
                    var edge = graph.AddEdge(depender, dependentOn.Key);
                    edge.LabelText = dependentOn.Value;
                    var md5  = System.Security.Cryptography.MD5.Create();
                    var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(dependentOn.Value.ToString()));
                    edge.Attr.Color      = new Microsoft.Msagl.Drawing.Color(hash[0], hash[1], hash[2]);
                    edge.Label.FontColor = new Microsoft.Msagl.Drawing.Color(hash[0], hash[1], hash[2]);
                }
            }

            //bind the graph to the viewer
            viewer.Graph = graph;
            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            //show the form
            form.ShowDialog();
        }
Esempio n. 26
0
        internal static void VisualizeGraph(Graph gr)
        {
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            Microsoft.Msagl.Drawing.Graph          graph  = new Microsoft.Msagl.Drawing.Graph("graph");

            foreach (Vertex v in gr.Vertices())
            {
                foreach (Edge e in v.edges)
                {
                    Microsoft.Msagl.Drawing.Edge msagle_edge = graph.AddEdge(
                        string.Format("{0} - {1} ", v.key, v.UserDefinedObjects[0])
                        , string.Format("{0} - {1} ", e.dest.key, e.dest.UserDefinedObjects[0])

                        );
                    if (e.cost > 0)
                    {
                        msagle_edge.LabelText = e.cost.ToString();
                    }
                }
            }

            viewer.Graph = graph;
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            form.ShowDialog();
        }
Esempio n. 27
0
        private Microsoft.Msagl.Drawing.Graph BFSHandler()
        {
            string[]      testspek  = File.ReadAllLines(textBox1.Text);
            List <string> filenodes = BacaFile.getNodes(testspek);

            bool[,] adjMatrix = BacaFile.getAdjMatrix(testspek, filenodes);
            List <string> BFSpath = BFS.FindPathBFS(filenodes, adjMatrix, comboBox1.Text, comboBox2.Text);

            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            graph = getPlainGraph(BFSpath);
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            for (int i = 0; i < BFSpath.Count - 1; i++)
            {
                Microsoft.Msagl.Drawing.Node source = graph.FindNode(BFSpath[i]);
                Microsoft.Msagl.Drawing.Node target = graph.FindNode(BFSpath[i + 1]);
                source.Attr.FillColor = Microsoft.Msagl.Drawing.Color.GreenYellow;
                var edge = graph.AddEdge(BFSpath[i], BFSpath[i + 1]);
                edge.Attr.Color             = Microsoft.Msagl.Drawing.Color.GreenYellow;
                edge.Attr.ArrowheadAtTarget = Microsoft.Msagl.Drawing.ArrowStyle.None;

                if (i == BFSpath.Count - 2)
                {
                    target.Attr.FillColor = Microsoft.Msagl.Drawing.Color.GreenYellow;
                }
            }
            return(graph);
        }
Esempio n. 28
0
        private Microsoft.Msagl.Drawing.Graph getPlainGraph(List <string> DFSpath)
        {
            string[]      testspek  = File.ReadAllLines(textBox1.Text);
            List <string> filenodes = BacaFile.getNodes(testspek);

            bool[,] adjMatrix = BacaFile.getAdjMatrix(testspek, filenodes);

            Microsoft.Msagl.Drawing.Graph graph2 = new Microsoft.Msagl.Drawing.Graph("graph");
            int totalNode = filenodes.Count;
            int totalAdj = adjMatrix.Length;
            int idx = 0;
            int i; int j;

            while (idx < totalAdj)
            {
                i = idx / totalNode;
                j = idx % totalNode;

                if (adjMatrix[i, j])
                {
                    if (!isValidDFSPath(filenodes[i], filenodes[j], DFSpath))
                    {
                        graph2.AddEdge(filenodes[i], filenodes[j]).Attr.ArrowheadAtTarget = Microsoft.Msagl.Drawing.ArrowStyle.None;
                    }
                    adjMatrix[j, i] = false;
                }
                idx++;
            }
            return(graph2);
        }
        public static void Main()
        {
            //create a form
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            //create a viewer object
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            //create the graph content
            graph.AddEdge("A", "B");
            graph.AddEdge("B", "C");
            graph.AddEdge("A", "C").Attr.Color = Microsoft.Msagl.Drawing.Color.Green;
            graph.FindNode("A").Attr.FillColor = Microsoft.Msagl.Drawing.Color.Magenta;
            graph.FindNode("B").Attr.FillColor = Microsoft.Msagl.Drawing.Color.MistyRose;
            Microsoft.Msagl.Drawing.Node c = graph.FindNode("C");
            c.Attr.FillColor = Microsoft.Msagl.Drawing.Color.PaleGreen;
            c.Attr.Shape     = Microsoft.Msagl.Drawing.Shape.Diamond;
            //bind the graph to the viewer
            viewer.Graph = graph;
            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();

            viewer.MouseUp += Viewer_MouseUp;

            //show the form
            form.ShowDialog();
        }
Esempio n. 30
0
 static public void dfagraph(List <DFAState> list)
 {
     System.Windows.Forms.Form form = new System.Windows.Forms.Form();
     Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
     Microsoft.Msagl.Drawing.Graph          graph  = new Microsoft.Msagl.Drawing.Graph("graph");
     for (int i = 0; i < list.Count; i++)
     {
         for (int j = 0; j < list[i].transitions.Count; j += 2)
         {
             if (list[i].transitions[j].input != "")
             {
                 graph.AddEdge(list[i].name, list[i].transitions[j].input, list[i].transitions[j].nextState.name);
             }
             if (list[i].isFinalState == true)
             {
                 Microsoft.Msagl.Drawing.Node c = graph.FindNode(list[i].name);
                 c.Attr.FillColor = Microsoft.Msagl.Drawing.Color.Red;
             }
         }
     }
     viewer.Graph = graph;
     form.SuspendLayout();
     viewer.Dock = System.Windows.Forms.DockStyle.Fill;
     form.Controls.Add(viewer);
     form.ResumeLayout();
     form.ShowDialog();
 }
        public FormForCellTypeRelationships(FormForSimuGenerator Parent)
        {
            InitializeComponent();
            this.Parent = Parent;

            GraphView = new GViewer();
            graph = new Microsoft.Msagl.Drawing.Graph("graph");
            GraphView.Size = new System.Drawing.Size(panel.Width, panel.Height);
            GraphView.Anchor = (AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);

            RefreshDisplay();
        }
Esempio n. 32
0
        public ArchitectureForm()
        {
            InitializeComponent();
            this.FormClosed += ArchitectureForm_FormClosed;

            this.simulator = SimulatorAccessor.simulator;
            if (simulator.IsSet)
            {
                layerSetupGroupBox.Enabled = true;
                connectionSetupGroupBox.Enabled = true;
            }

            this.architectureGraph = ArchitectureGraphAccessor.architectureGraph;

            Refresh();
        }
        private void DrawForeignKeys()
        {
            Form form = new Form();

            form.Text = "Stage-2 Reverse Engineer : Foreign_Keys";
            //create a viewer object 
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object 
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            //create the graph content 


            foreach (Tuple<string,string> tup in foreignKeyRelations)
            {
                Microsoft.Msagl.Drawing.Node newNode = new Microsoft.Msagl.Drawing.Node(tup.Item1);
                newNode.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box;

                graph.AddNode(newNode);

                Microsoft.Msagl.Drawing.Node newNode2 = new Microsoft.Msagl.Drawing.Node(tup.Item2);
                newNode.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box;

                graph.AddNode(newNode2);

                graph.AddEdge(tup.Item1, tup.Item2);
            }

            //bind the graph to the viewer 
            viewer.Graph = graph;
            //associate the viewer with the form 
            form.SuspendLayout();
            viewer.Dock = DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            //show the form 
            form.Show();
        }
Esempio n. 34
0
        private void button1_Click(object sender, EventArgs e)
        {
            graph = new Microsoft.Msagl.Drawing.Graph("graph");

            graph.AddEdge("A", "B");
            graph.AddEdge("A", "D");
            graph.AddEdge("B", "A");
            graph.AddEdge("A", "C").Attr.Color = Microsoft.Msagl.Drawing.Color.Green;
            graph.FindNode("A").Attr.FillColor = Microsoft.Msagl.Drawing.Color.Green;
            graph.FindNode("B").Attr.FillColor = Microsoft.Msagl.Drawing.Color.Green;
            graph.FindNode("D").Attr.FillColor = Microsoft.Msagl.Drawing.Color.Green;
            graph.AddNode("E, F");
            graph.AddEdge("E,F", "A");

            Microsoft.Msagl.Drawing.Node c = graph.FindNode("C");
            c.Attr.FillColor = Microsoft.Msagl.Drawing.Color.Green;
            c.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Diamond;

            viewer.Graph = graph;
        }
Esempio n. 35
0
        private void wczytaj_Click(object sender, EventArgs e)
        {
            int wiersze = 0;
            int kolumny = 0;

            Stream myStream = null;
            OpenFileDialog okno = new OpenFileDialog();
            okno.InitialDirectory = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath));
            okno.Filter = "Pliki tekstowy, macierz (txt)|*.txt";
            okno.ShowDialog();
            try
            {
                if ((myStream = okno.OpenFile()) != null)
                {
                    using (myStream)
                    {
                        System.IO.StreamReader sr = new System.IO.StreamReader(okno.FileName);
                        do
                        {
                            kolumny = sr.ReadLine().Length;
                            wiersze++;
                        } while (!sr.EndOfStream);

                        sr.DiscardBufferedData(); //czyszczenie bufora
                        sr.BaseStream.Seek(0, SeekOrigin.Begin); //powrót karetki odczytu pliku do początku
                        int wierszBledu = 1;
                        do
                        {
                            kolumny = sr.ReadLine().Length;
                            if (kolumny > 10)
                                throw new InvalidOptionException("Macierz nie może być większa niż 10x10", sr);
                            if (kolumny != wiersze)
                            {
                                throw new InvalidOptionException("Macierz nie jest kwadratowa\n" +
                                "Błąd w wierszu: " + wierszBledu, sr);
                            }
                            wierszBledu++;
                        } while (!sr.EndOfStream);

                        sr.DiscardBufferedData(); //czyszczenie bufora
                        sr.BaseStream.Seek(0, SeekOrigin.Begin); //powrót karetki odczytu pliku do początku

                        this.macierz = new Data(wiersze, kolumny);
                        int liczba = 0;
                        for (int i = 0; i < wiersze; i++)
                        {
                            string temp = sr.ReadLine();
                            for (int j = 0; j < kolumny; j++)
                            {
                                if (temp[j] == 48)
                                {
                                    liczba = 0;
                                    macierz.Write(i, j, liczba);
                                }
                                else if (temp[j] == 49)
                                {
                                    liczba = 1;
                                    macierz.Write(i, j, liczba);
                                }
                                else
                                    throw new InvalidOptionException("Macierz musi zawierać liczby 0 lub 1.\n", sr);
                            }
                        }
                        sr.Close();
                    }
                }
                MessageBox.Show("Liczba wierszy: " + wiersze.ToString() + "\n" + //do testow
                    "Liczba kolumn: " + kolumny);

                graph = new Microsoft.Msagl.Drawing.Graph("graph");

                //for (int i = 0; i < macierz.RowGet; i++)
                //{
                //    for (int j = 0; j < macierz.ColGet; j++)
                //    {
                //        if (macierz.Read(i, j) == 1)
                //        {
                //            graph.AddEdge((i + 1).ToString(), (j + 1).ToString());
                //        }
                //    }
                //} //prawidłowa macierz zaczytująca plik do grafu.
                lista = macierz.ToList();

                for (int i = 0; i < macierz.RowGet; i++)
                {
                    foreach (int element in lista[i])
                    {
                        graph.AddEdge((i + 1).ToString(), (element + 1).ToString());
                    }
                }

                viewer.Graph = graph;

            }
            catch (InvalidOptionException ex)
            {
                MessageBox.Show("" + ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
            }
        }
        private void stage_1_Entities_Identification_Click(object sender, EventArgs e)
        {
            Form form = new System.Windows.Forms.Form();

            form.Text = "Stage-1 Reverse Engineer : Entities";
            //create a viewer object 
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object 
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            //create the graph content 


            foreach(Relation rel  in _masterListRelations)
            {
                Microsoft.Msagl.Drawing.Node newNode = new Microsoft.Msagl.Drawing.Node(rel.relationName);
                newNode.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box;

                graph.AddNode(newNode);
            }



            //bind the graph to the viewer 
            viewer.Graph = graph;
            //associate the viewer with the form 
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.Size = new Size(500, 500);
            form.ResumeLayout();
            //show the form 
            form.Show();

        }
        private void DrawWeakEntities()
        {
            Form form = new Form();

            form.Text = "Stage-3 Reverse Engineer : Foreign_Keys";
            //create a viewer object 
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object 
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            //create the graph content 


            // Draw all the entitites
            foreach(Relation rel in _masterListRelations)
            {
                Microsoft.Msagl.Drawing.Node newNode = new Microsoft.Msagl.Drawing.Node(rel.relationName);
                newNode.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box;

                //Add it to the graph
                graph.AddNode(newNode);
            }

            //Draw all the weak Entities
            foreach(Tuple<string, string> weakEnt in weakEntities)
            {
                graph.AddNode(weakEnt.Item1).Attr.Shape = Microsoft.Msagl.Drawing.Shape.Ellipse;
                graph.AddEdge(weakEnt.Item1, weakEnt.Item2);
            }

            //Draw all the other relations
            foreach(Tuple<string, string> rel in foreignKeyRelations)
            {
                Tuple<string, string> find = weakEntities.Find(obj => (obj.Item1 == rel.Item1 && obj.Item2 == rel.Item2) || (obj.Item2 == rel.Item1 && obj.Item1 == rel.Item2));
                if(find == null)
                {
                    graph.AddEdge(rel.Item1, rel.Item2);
                }

            }

            //bind the graph to the viewer 
            viewer.Graph = graph;
            //associate the viewer with the form 
            form.SuspendLayout();
            viewer.Dock = DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            //show the form 
            form.Show();
        }
        private void DrawRelations()
        {
            Form form = new Form();

            form.Text = "Stage-4 Reverse Engineer : Relations";
            //create a viewer object 
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object 
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            //create the graph content 


            // Draw all the entitites
            foreach (Relation rel in _masterListRelations)
            {
                Microsoft.Msagl.Drawing.Node newNode = new Microsoft.Msagl.Drawing.Node(rel.relationName);
                newNode.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box;

                //Add it to the graph
                graph.AddNode(newNode);
            }

            //Draw all the weak Entities
            foreach (Tuple<string, string> weakEnt in weakEntities)
            {
                graph.AddNode(weakEnt.Item1).Attr.Shape = Microsoft.Msagl.Drawing.Shape.Ellipse;
                graph.AddEdge(weakEnt.Item1, weakEnt.Item2);
            }

            int relIndex = 1;
            //Draw all the other relations
            foreach (Tuple<string, string> rel in foreignKeyRelations)
            {

                Tuple<string, string> find = weakEntities.Find(obj => (obj.Item1 == rel.Item1 && obj.Item2 == rel.Item2) || (obj.Item2 == rel.Item1 && obj.Item1 == rel.Item2));
                if (find == null)
                {
                    string intermediateRel = "R" + relIndex;
                    graph.AddNode(intermediateRel);
                    graph.AddNode(intermediateRel).Attr.Shape = Microsoft.Msagl.Drawing.Shape.Diamond;
                    graph.AddEdge(rel.Item1, intermediateRel);
                    graph.AddEdge(intermediateRel, rel.Item2);
                    relIndex++;
                }
            }

            //Draw the relations as Diamonds
            foreach(Tuple<string, List<string>> tup in relations)
            {
                graph.AddNode(tup.Item1).Attr.Shape = Microsoft.Msagl.Drawing.Shape.Diamond;
            }

            foreach(string s in multiValuedAttr)
            {
                graph.AddNode(s).Attr.Shape = Microsoft.Msagl.Drawing.Shape.DoubleCircle;
            }

            //bind the graph to the viewer 
            viewer.Graph = graph;
            //associate the viewer with the form 
            form.SuspendLayout();
            viewer.Dock = DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            //show the form 
            form.Show();
        }
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="drGraph"></param>
 public GraphRenderer(Microsoft.Msagl.Drawing.Graph drGraph) {
     this.graph = drGraph;
 }
Esempio n. 40
0
        Microsoft.Msagl.Drawing.Graph ComputeAndDisplayGraph(string DotString, bool IsCellular)
        {
            int CurrentPos = 0;
            int NextReturnPos = CurrentPos;
            List<int> ListNodeId = new List<int>();
            string TmpDotString = DotString;

            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");

            while (NextReturnPos != -1)
            {
                int NextBracket = DotString.IndexOf("[");
                string StringToProcess = DotString.Remove(NextBracket - 1);
                string StringToProcess1 = StringToProcess.Remove(0, 1);

                if (StringToProcess1.Contains("N") == false)
                {
                    int Id = Convert.ToInt32(StringToProcess1);
                    Microsoft.Msagl.Drawing.Node Currentnode = new Microsoft.Msagl.Drawing.Node(Id.ToString());
                    Currentnode.Label.FontColor = Microsoft.Msagl.Drawing.Color.Red;
                    int LabelPos = DotString.IndexOf("label=\"");
                    string LabelString = DotString.Remove(0, LabelPos + 7);
                    LabelPos = LabelString.IndexOf("\"");
                    string FinalLabel = LabelString.Remove(LabelPos);
                    Currentnode.LabelText = FinalLabel;

                    if (IsCellular && (FinalLabel[FinalLabel.Length - 1] == ')') && (FinalLabel.Contains('(')))   // that's a leaf
                    {
                        int LastBracket = FinalLabel.LastIndexOf('(');
                        string LeafName = FinalLabel.Remove(LastBracket - 1);

                        cCellularPhenotype CP = cGlobalInfo.ListCellularPhenotypes.FindFromName(LeafName);
                        if (CP != null)
                        {
                            Currentnode.Attr.FillColor = new Microsoft.Msagl.Drawing.Color(CP.ColourForDisplay.R, CP.ColourForDisplay.G, CP.ColourForDisplay.B);
                        }
                    }
                    graph.AddNode(Currentnode);
                }

                NextReturnPos = DotString.IndexOf("\n");
                if (NextReturnPos != -1)
                {
                    string TmpString = DotString.Remove(0, NextReturnPos + 1);
                    DotString = TmpString;
                }
            }

            DotString = TmpDotString;
            NextReturnPos = 0;
            while (NextReturnPos != -1)
            {
                int NextBracket = DotString.IndexOf("[");
                string StringToProcess = DotString.Remove(NextBracket - 1);
                string StringToProcess1 = StringToProcess.Remove(0, 1);

                if (StringToProcess1.Contains("N"))
                {
                    string stringNodeIdxStart = StringToProcess1.Remove(StringToProcess1.IndexOf("-"));
                    int NodeIdxStart = Convert.ToInt32(stringNodeIdxStart);

                    string stringNodeIdxEnd = StringToProcess1.Remove(0, StringToProcess1.IndexOf("N") + 1);
                    int NodeIdxSEnd = Convert.ToInt32(stringNodeIdxEnd);

                    int LabelPos = DotString.IndexOf("label=");
                    LabelPos += 7;

                    string CurrLabelString = DotString.Remove(0, LabelPos);

                    Microsoft.Msagl.Drawing.Edge Currentedge = new Microsoft.Msagl.Drawing.Edge(stringNodeIdxStart, ""/*NodeIdx.ToString()*/, stringNodeIdxEnd);
                    Currentedge.LabelText = CurrLabelString.Remove(CurrLabelString.IndexOf("]") - 1);
                    graph.Edges.Add(Currentedge);
                }

                NextReturnPos = DotString.IndexOf("\n");

                if (NextReturnPos != -1)
                {
                    string TmpString = DotString.Remove(0, NextReturnPos + 1);
                    DotString = TmpString;
                }
            }
            return graph;
        }
Esempio n. 41
0
        private Microsoft.Msagl.Drawing.Graph ComputeAndDisplayGraph(string DotString)
        {
            int CurrentPos = 0;
            int NextReturnPos = CurrentPos;
            List<int> ListNodeId = new List<int>();
            string TmpDotString = DotString;

            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");

            while (NextReturnPos != -1)
            {
                int NextBracket = DotString.IndexOf("[");
                string StringToProcess = DotString.Remove(NextBracket - 1);
                string StringToProcess1 = StringToProcess.Remove(0, 1);

                if (StringToProcess1.Contains("N") == false)
                {
                    int Id = Convert.ToInt32(StringToProcess1);
                    Microsoft.Msagl.Drawing.Node Currentnode = new Microsoft.Msagl.Drawing.Node(Id.ToString());
                    Currentnode.Label.FontColor = Microsoft.Msagl.Drawing.Color.Red;
                    int LabelPos = DotString.IndexOf("label=\"");
                    string LabelString = DotString.Remove(0, LabelPos + 7);
                    LabelPos = LabelString.IndexOf("\"");
                    string FinalLabel = LabelString.Remove(LabelPos);
                    Currentnode.LabelText = FinalLabel;
                    graph.AddNode(Currentnode);
                }

                NextReturnPos = DotString.IndexOf("\n");
                if (NextReturnPos != -1)
                {
                    string TmpString = DotString.Remove(0, NextReturnPos + 1);
                    DotString = TmpString;
                }
            }

            DotString = TmpDotString;
            NextReturnPos = 0;
            while (NextReturnPos != -1)
            {
                int NextBracket = DotString.IndexOf("[");
                string StringToProcess = DotString.Remove(NextBracket - 1);
                string StringToProcess1 = StringToProcess.Remove(0, 1);

                if (StringToProcess1.Contains("N"))
                {
                    string stringNodeIdxStart = StringToProcess1.Remove(StringToProcess1.IndexOf("-"));
                    int NodeIdxStart = Convert.ToInt32(stringNodeIdxStart);

                    string stringNodeIdxEnd = StringToProcess1.Remove(0, StringToProcess1.IndexOf("N") + 1);
                    int NodeIdxSEnd = Convert.ToInt32(stringNodeIdxEnd);

                    int LabelPos = DotString.IndexOf("label=");
                    LabelPos += 7;

                    string CurrLabelString = DotString.Remove(0, LabelPos);

                    Microsoft.Msagl.Drawing.Edge Currentedge = new Microsoft.Msagl.Drawing.Edge(stringNodeIdxStart, ""/*NodeIdx.ToString()*/, stringNodeIdxEnd);
                    Currentedge.LabelText = CurrLabelString.Remove(CurrLabelString.IndexOf("]") - 1);
                    graph.Edges.Add(Currentedge);
                }

                NextReturnPos = DotString.IndexOf("\n");

                if (NextReturnPos != -1)
                {
                    string TmpString = DotString.Remove(0, NextReturnPos + 1);
                    DotString = TmpString;
                }
            }
            return graph;
        }
Esempio n. 42
0
        private void graphWorker_DoWork(object/*?*/ sender, DoWorkEventArgs/*?*/ e)
        {
            BackgroundWorker worker = (BackgroundWorker)sender;

            // Combine the inputs and outputs if desired.
            // FiniteStateMachine fsm = combineActions ? machine.CombineInputsAndOutputs() : machine;

            // Clear the node and transition tables.
            nodes.Clear();
            transitions.Clear();
            dashedEdges.Clear();

            // Create a new Agl graph.
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("Finite Automaton");

            // Set the layout direction.
            graph.Attr.LayerDirection = LayerDirection();

            // Report the total number of states and transitions.
            int progress = 0;
            worker.ReportProgress(progress, finiteAutomatonContext.fa.States.Count + Math.Min(maxTransitions, finiteAutomatonContext.fa.Transitions.Count));

            //for quick lookup create maps from nodes to all exiting transitions and entering transitions
            Dictionary<Node, List<Transition>> exitingTransitions = new Dictionary<Node, List<Transition>>();
            Dictionary<Node, List<Transition>> enteringTransitions = new Dictionary<Node, List<Transition>>();
            foreach (Node n in finiteAutomatonContext.fa.States)
            {
                exitingTransitions[n] = new List<Transition>();
                enteringTransitions[n] = new List<Transition>();
            }
            foreach (Transition t in finiteAutomatonContext.fa.Transitions)
            {
                exitingTransitions[t.First].Add(t);
                enteringTransitions[t.Third].Add(t);
            }
            //foreach (Transition t in finiteAutomatonContext.dashedTransitions)
            //{
            //    exitingTransitions[t.First].Add(t);
            //    enteringTransitions[t.Third].Add(t);
            //}
            //In Mealy view hidden nodes have one incoming Start action and at
            //least one outgoing Finish action
            //with the same action symbol name
            hiddenMealyNodes = Set<Node>.EmptySet;
            if (combineActions)
            {
                foreach (Node n in finiteAutomatonContext.fa.States)
                {
                    if (enteringTransitions[n].Count == 1 && IsStartAction(enteringTransitions[n][0].Second))
                    {
                        string actionname = ((CompoundTerm)enteringTransitions[n][0].Second).Symbol.Name.Replace("_Start","");
                        if (exitingTransitions[n].Count >= 1
                            && AllTransitionsAreFinish(actionname, exitingTransitions[n]))
                        {
                            hiddenMealyNodes = hiddenMealyNodes.Add(n);
                        }
                    }
                }
            }

            #region Add the initial state first.
            GraphLayout.Drawing.Node initialNode = graph.AddNode(finiteAutomatonContext.fa.InitialState.ToString());
            if (this.nodeLabelsVisible)
            {
                if (this.finiteAutomatonContext.stateProvider != null && this.customStateLabelProvider != null)
                {
                    initialNode.LabelText= this.customStateLabelProvider(this.finiteAutomatonContext.stateProvider(this.finiteAutomatonContext.fa.InitialState));
                }
            }
            else
            {
                initialNode.LabelText = "";
            }
            //initial progress, one node is handled
            worker.ReportProgress(++progress);
            initialNode.Attr.FillColor = new GraphLayout.Drawing.Color(initialStateColor.R, initialStateColor.G, initialStateColor.B);
            initialNode.Attr.Shape = MapToAglShape(this.stateShape);
            #endregion

            #region Add the transitions by walking the graph depth first

            Stack<Node> stack = new Stack<Node>();
            Set<Node> visited = Set<Node>.EmptySet;
            //Notice the invariant: nodes on the stack can not be hidden nodes
            //base case: initial state cannot be hidden because
            //it must have at least one exiting start action or atomic action
            stack.Push(finiteAutomatonContext.fa.InitialState);
            visited = visited.Add(finiteAutomatonContext.fa.InitialState);
            while (stack.Count > 0 && graph.EdgeCount < maxTransitions)
            {
                //invariant: nodes on the stack are not hidden nodes
                Node current = stack.Pop();
                GraphLayout.Drawing.Node fromNode = graph.AddNode(current.ToString());

                nodes[fromNode] = current;

                //record the transitions to be added as
                //dictionary of MultiLabeledTransitions from current
                //state indexed by end state
                Dictionary<Node, MultiLabeledTransition> transitionsToBeAdded =
                    new Dictionary<Node, MultiLabeledTransition>();

                #region collect transitions to be added into transitionsToBeAdded
                foreach (Transition t in exitingTransitions[current])
                {
                    //do not add dead states if requested
                    if (this.livenessCheckIsOn &&
                        !this.deadstatesVisible &&
                        this.finiteAutomatonContext.deadNodes.Contains(t.Third))
                        continue;

                    worker.ReportProgress(++progress); //one transition is handled
                    if (hiddenMealyNodes.Contains(t.Third))
                    {
                        //construct Mealy view of all the exiting transitions from t.Third
                        foreach (Transition tf in exitingTransitions[t.Third])
                        {
                            worker.ReportProgress(++progress);
                            //string mealyLabel = (this.actionLabelsVisible ? ConstructMealyLabel(t.Second, tf.Second) : "");
                            //add target node to the stack, if not visited already
                            if (!visited.Contains(tf.Third))
                            {
                                visited = visited.Add(tf.Third);
                                if (exitingTransitions[tf.Third].Count > 0)
                                {
                                    stack.Push(tf.Third); //notice that invariant is preserved
                                }
                                //one more node is handled
                                worker.ReportProgress(++progress);
                            }
                            // add edge
                            GraphLayout.Drawing.Node toNode = graph.AddNode(tf.Third.ToString());
                            toNode.Attr.Shape = MapToAglShape(this.stateShape);
                            if (this.nodeLabelsVisible)
                            {
                                if (this.finiteAutomatonContext.stateProvider != null && this.customStateLabelProvider != null)
                                {
                                    toNode.LabelText= this.customStateLabelProvider(this.finiteAutomatonContext.stateProvider(tf.Third));
                                }
                            }
                            else
                                toNode.LabelText = "";
                            nodes[toNode] = tf.Third;
                            if (loopsVisible || fromNode.Attr.Id != toNode.Attr.Id)
                            {
                                MultiLabeledTransition trans;
                                if (transitionsToBeAdded.TryGetValue(tf.Third, out trans))
                                {
                                    trans.AddMealyLabel(t.Second, tf.Second);
                                }
                                else
                                {
                                    trans = MultiLabeledTransition.Create(t.First, t.Second, tf.Second, tf.Third);
                                    transitionsToBeAdded[tf.Third] = trans;
                                }
                                //GraphLayout.Drawing.Edge edge = graph.AddEdge(fromNode.Attr.Id, mealyLabel, toNode.Attr.Id);
                                //transitions[edge] = CombinedTransition.Create(t, tf);
                            }
                        }
                    }
                    else
                    {
                        //string edgeLabel = (this.actionLabelsVisible ? ConstructEdgeLabel(t.Second) : "");
                        //add target node to the stack, if not visited already
                        if (!visited.Contains(t.Third))
                        {
                            visited = visited.Add(t.Third);
                            if (exitingTransitions[t.Third].Count > 0)
                            {
                                stack.Push(t.Third); //notice that invariant is trivially preserved
                            }
                            //one more node is handled
                            worker.ReportProgress(++progress);
                        }
                        // add edge
                        GraphLayout.Drawing.Node toNode = graph.AddNode(t.Third.ToString());
                        toNode.Attr.Shape = MapToAglShape(this.stateShape);
                        if (this.nodeLabelsVisible)
                        {
                            if (this.finiteAutomatonContext.stateProvider != null && this.customStateLabelProvider != null)
                            {
                                toNode.LabelText = this.customStateLabelProvider(this.finiteAutomatonContext.stateProvider(t.Third));
                            }
                        }
                        else
                            toNode.LabelText = "";
                        nodes[toNode] = t.Third;
                        if (loopsVisible || !fromNode.Attr.Id.Equals(toNode.Attr.Id))
                        {
                            MultiLabeledTransition trans;
                            if (transitionsToBeAdded.TryGetValue(t.Third, out trans))
                            {
                                trans.AddLabel(t.Second);
                            }
                            else
                            {
                                trans = MultiLabeledTransition.Create(t.First, t.Second, t.Third);
                                transitionsToBeAdded[t.Third] = trans;
                            }
                            //GraphLayout.Drawing.Edge edge = graph.AddEdge(fromNode.Attr.Id, edgeLabel, toNode.Attr.Id);
                            //transitions[edge] = CombinedTransition.Create(t);
                        }
                        //one more edge is added
                        worker.ReportProgress(++progress);
                    }
                }
                #endregion

                //add all transitions from the current state to glee
                foreach (MultiLabeledTransition trans in transitionsToBeAdded.Values)
                {
                    //don't add transitions that lead to dead states if dead state are turned off
                    //if (this.livenessCheckIsOn &&
                    //    !this.deadstatesVisible &&
                    //    this.finiteAutomatonContext.deadNodes.Contains(trans.endState))
                    //    continue;

                    GraphLayout.Drawing.Node toNode = graph.AddNode(trans.endState.ToString());
                    if (mergeLabels)
                    {
                        string lab = (this.transitionLabels != TransitionLabel.None ? trans.CombinedLabel(this.transitionLabels == TransitionLabel.ActionSymbol) : "");
                        GraphLayout.Drawing.Edge edge = graph.AddEdge(fromNode.Attr.Id, lab, toNode.Attr.Id);
                        transitions[edge] = trans;
                    }
                    else
                    {
                        foreach (MultiLabeledTransition tr in trans.CreateOnePerLabel())
                        {
                            string lab = (this.transitionLabels != TransitionLabel.None ? tr.CombinedLabel(this.transitionLabels == TransitionLabel.ActionSymbol) : "");
                            GraphLayout.Drawing.Edge edge = graph.AddEdge(fromNode.Attr.Id, lab, toNode.Attr.Id);
                            transitions[edge] = tr;
                        }
                    }
                }

            }

            #region Draw dashed arrows specified in the set finiteAutomatonContext.dashedTransitions

            Dictionary<Transition, MultiLabeledTransition> mlDashedTransitions = new Dictionary<Transition, MultiLabeledTransition>();
            foreach (Transition trans in finiteAutomatonContext.groupingTransitions)
                mlDashedTransitions.Add(trans, MultiLabeledTransition.Create(trans.First, trans.Second, trans.Third));
            //add all dashed transitions from the current facontext to GLEE
            foreach (MultiLabeledTransition trans in mlDashedTransitions.Values)
            {
                //don't add transitions that lead to dead states if dead state are turned off
                //if (this.livenessCheckIsOn &&
                //    !this.deadstatesVisible &&
                //    this.finiteAutomatonContext.deadNodes.Contains(trans.endState))
                //    continue;

                GraphLayout.Drawing.Node toNd = graph.AddNode(trans.endState.ToString());
                GraphLayout.Drawing.Node fromNd = graph.AddNode(trans.startState.ToString());
                //if (mergeLabels)
                //{
                //    string lab = (this.transitionLabels != TransitionLabel.None ? trans.CombinedLabel(this.transitionLabels == TransitionLabel.ActionSymbol) : "");
                //    GraphLayout.Drawing.IEdge edge = graph.AddEdge(fromNode.NodeAttribute.Id, lab, toNode.NodeAttribute.Id);
                //    transitions[edge] = trans;
                //}
                //else
                //{
                //    foreach (MultiLabeledTransition tr in trans.CreateOnePerLabel())
                //    {
                string lab = (this.transitionLabels != TransitionLabel.None ? trans.CombinedLabel(this.transitionLabels == TransitionLabel.ActionSymbol) : "");
                GraphLayout.Drawing.Edge edge = graph.AddEdge(fromNd.Attr.Id, lab, toNd.Attr.Id);
                GraphLayout.Drawing.AttributeBase eattr = edge.Attr as GraphLayout.Drawing.AttributeBase;
                eattr.AddStyle(GraphLayout.Drawing.Style.Dashed);
                transitions[edge] = trans;
                dashedEdges.Add(trans,0);
                //    }
                //}
            }

            # endregion

            if (stack.Count == 0)
            {
                //add unreachable edges and nodes up to the given max count
                if (visited.Count + hiddenMealyNodes.Count < finiteAutomatonContext.fa.States.Count)
                {
                    foreach (Term n in finiteAutomatonContext.fa.States.Difference(visited.Union(hiddenMealyNodes)))
                    {
                        //do not consider dead state if they are not visible
                        if (this.livenessCheckIsOn &&
                            !this.deadstatesVisible &&
                            this.finiteAutomatonContext.deadNodes.Contains(n))
                            continue;

                        //record the transitions to be added as
                        //dictionary of MultiLabeledTransitions from current
                        //state indexed by end state
                        Dictionary<Node, MultiLabeledTransition> transitionsToBeAdded =
                             new Dictionary<Node, MultiLabeledTransition>();

                        GraphLayout.Drawing.Node n1 = graph.AddNode(n.ToString());
                        n1.Attr.Color = ToAglColor(Color.Gray);
                        n1.Label.FontColor = ToAglColor(Color.Gray);
                        n1.Attr.Shape = MapToAglShape(this.StateShape);
                        nodes[n1] = n;
                        if (!this.nodeLabelsVisible)
                        {
                            n1.LabelText = "";
                        }

                        foreach (Triple<Term, CompoundTerm, Term> t in exitingTransitions[n])
                        {
                            MultiLabeledTransition t1;
                            if (transitionsToBeAdded.TryGetValue(t.Third, out t1))
                            {
                                t1.AddLabel(t.Second);
                            }
                            else
                            {
                                t1 = MultiLabeledTransition.Create(n, t.Second, t.Third);
                                transitionsToBeAdded[t.Third] = t1;
                            }
                        }

                        //add all transitions from the current state to glee
                        foreach (MultiLabeledTransition t1 in transitionsToBeAdded.Values)
                        {
                            GraphLayout.Drawing.Node n2 = graph.AddNode(t1.endState.ToString());
                            nodes[n2] = t1.endState;
                            if (mergeLabels)
                            {
                                string lab = (this.transitionLabels != TransitionLabel.None ? t1.CombinedLabel(this.transitionLabels == TransitionLabel.ActionSymbol) : "");
                                GraphLayout.Drawing.Edge e1 = graph.AddEdge(n1.Attr.Id, lab, n2.Attr.Id);
                                e1.Label.FontColor = ToAglColor(Color.Gray);
                                e1.Attr.Color = ToAglColor(Color.Gray);
                                transitions[e1] = t1;
                            }
                            else
                            {
                                foreach (MultiLabeledTransition t2 in t1.CreateOnePerLabel())
                                {
                                    string lab = (this.transitionLabels != TransitionLabel.None ? t2.CombinedLabel(this.transitionLabels == TransitionLabel.ActionSymbol) : "");
                                    GraphLayout.Drawing.Edge e1 = graph.AddEdge(n1.Attr.Id, lab, n2.Attr.Id);
                                    e1.Label.FontColor = ToAglColor(Color.Gray);
                                    e1.Attr.Color = ToAglColor(Color.Gray);
                                    transitions[e1] = t2;
                                }
                            }
                        }
                        if (graph.EdgeCount >= maxTransitions)
                            break;
                    }
                }
            }
            #endregion

            #region Format the nodes.
            // Mark dead states
            if (this.livenessCheckIsOn)
            {
                Set<Node> deadNodes = finiteAutomatonContext.deadNodes.Intersect(visited);
                foreach (Node deadNode in deadNodes)
                {
                    GraphLayout.Drawing.Node deadAglNode = graph.AddNode(deadNode.ToString());
                    deadAglNode.Attr.FillColor =
                       new GraphLayout.Drawing.Color(deadStateColor.R, deadStateColor.G, deadStateColor.B);
                }
            }

            //while (stack.Count > 0)
            //{
            //    Node truncatedNode = stack.Pop();
            //    GraphLayout.Drawing.Node truncatedAglNode = graph.AddNode(truncatedNode.ToString());
            //    truncatedAglNode.Attr.Fillcolor =
            //        new GraphLayout.Drawing.Color(truncatedStateColor.R, truncatedStateColor.G, truncatedStateColor.B);
            //}

            // Mark accepting states with a thicker line
            // TBD: waiting for Lev to provide double-line feature
            if (this.acceptingStatesMarked)
            {
                foreach (Node accNode in finiteAutomatonContext.fa.AcceptingStates.Intersect(visited))
                {
                    GraphLayout.Drawing.Node acceptingAglNode = graph.AddNode(accNode.ToString());
                    acceptingAglNode.Attr.Shape = MapToAglShape(stateShape);
                    acceptingAglNode.Attr.LineWidth = 4;
                }
            }

            // Mark error states
            if (this.safetyCheckIsOn)
            {
                if (finiteAutomatonContext.stateProvider != null && finiteAutomatonContext.mp != null)
                {
                    this.finiteAutomatonContext.unsafeNodes = Set<Term>.EmptySet;
                    foreach (Node visitedNode in finiteAutomatonContext.fa.States.Intersect(visited))
                    {
                        IState istate = finiteAutomatonContext.stateProvider(visitedNode);
                        if (!finiteAutomatonContext.mp.SatisfiesStateInvariant(istate))
                        {
                            this.finiteAutomatonContext.unsafeNodes =
                                this.finiteAutomatonContext.unsafeNodes.Add(visitedNode);
                            GraphLayout.Drawing.Node visitedAglNode = graph.AddNode(visitedNode.ToString());
                            visitedAglNode.Attr.Shape = MapToAglShape(stateShape);
                            visitedAglNode.Attr.FillColor = ToAglColor(this.unsafeStateColor);
                        }
                    }
                }
            }
            #endregion

            // Start the marquee mode of the progress bar.
            worker.ReportProgress(-1);

            //insert a delay to avoid a crash in this version of GLEE
            System.Threading.Thread.Sleep(200);

            // Return the calculated layout as the result.
            e.Result = viewer.CalculateLayout(graph);
        }