Beispiel #1
0
        public GcTypeHeap Render()
        {
            Console.WriteLine("rendering...");
            if (this.graph.VertexCount > 500)
            {
                Console.WriteLine("too many vertices ");
                return(this);
            }

            GleeGraphPopulator <GcType, GcTypeEdge> populator = GleeGraphUtility.Create(this.graph);

            try
            {
                populator.NodeAdded += new GleeVertexNodeEventHandler <GcType>(populator_NodeAdded);
                populator.EdgeAdded += new GleeEdgeEventHandler <GcType, GcTypeEdge>(populator_EdgeAdded);
                populator.Compute();

                if (viewer == null)
                {
                    viewerForm  = new Form();
                    viewer      = new GViewer();
                    viewer.Dock = DockStyle.Fill;
                    viewerForm.Controls.Add(viewer);
                }
                viewer.Graph = populator.GleeGraph;
                viewerForm.ShowDialog();
            }
            finally
            {
                populator.NodeAdded -= new GleeVertexNodeEventHandler <GcType>(populator_NodeAdded);
                populator.EdgeAdded -= new GleeEdgeEventHandler <GcType, GcTypeEdge>(populator_EdgeAdded);
            }

            return(this);
        }
Beispiel #2
0
        public void Draw()
        {
            UndirectedGraph <Vertex, QuickGraph.Edge <Vertex> > mG
                = new UndirectedGraph <Vertex, QuickGraph.Edge <Vertex> >();

            List <Vertex> .Enumerator etV = mGraph.mVertices.GetEnumerator();
            while (etV.MoveNext())
            {
                mG.AddVertex(etV.Current);
            }

            List <Edge> .Enumerator etE = mGraph.mEdges.GetEnumerator();
            while (etE.MoveNext())
            {
                QuickGraph.Edge <Vertex> e = new Edge <Vertex>(etE.Current.mVertexA, etE.Current.mVertexB);
                mG.AddEdge(e);
            }

            Console.WriteLine("QUICK GRAPH FORMAT:");
            Console.WriteLine(mG.VertexCount);
            Console.WriteLine(mG.EdgeCount);

            /*
             * var graphviz = new GraphvizAlgorithm<Vertex, Edge<Vertex>>(mG);
             * string output = graphviz.Generate(new FileDotEngine(), "graph");
             *
             * Console.WriteLine("OUTPUT");
             * Console.WriteLine(output);
             *
             * // Process drawProcess = new Process();
             * Process.Start("dot","-Tpng graph.dot > graph.png");
             */

            var populator = GleeGraphUtility.Create <Vertex, Edge <Vertex> >(mG);

            populator.Compute();
            Microsoft.Glee.Drawing.Graph gleeG = populator.GleeGraph;

            //create a viewer object
            Microsoft.Glee.GraphViewerGdi.GViewer viewer = new Microsoft.Glee.GraphViewerGdi.GViewer();
            //create a form
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();

            //bind the graph to the viewer
            viewer.Graph = gleeG;

            //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();
        }