示例#1
0
        private void DrawPlanarGraph()
        {
            using (Graphics g = this.CreateGraphics())
            {
                g.Clear(Color.Cornsilk);
                GraphDrawer drawer       = new GraphDrawer(_myGraph);
                Rectangle   drawingPlace = new Rectangle(50, 50, ClientSize.Width - 100, panel1.Top - 100);

                drawer.SetGraph();
                drawer.Draw(g, drawingPlace, 10, 5, Color.Firebrick, Color.RoyalBlue);
                foreach (Label label in drawer.Labels)
                {
                    this.Controls.Add(label);
                    _labels.Add(label);
                }

                _transitiveClosure = drawer.GetTransitiveClosure();
                _spanningTree      = new Graph();
                foreach (INode node in _myGraph.Nodes)
                {
                    _spanningTree.Nodes.Add(node);
                }

                foreach (IEdge edge in _myGraph.SpanningTreeEdges)
                {
                    _spanningTree.Edges.Add(edge);
                }
            }
        }
示例#2
0
        private void transitButton_Click(object sender, EventArgs e)
        {
            using (Graphics g = this.CreateGraphics()) //toDo redo if time later
            {
                GraphDrawer drawer       = new GraphDrawer(_transitiveClosure);
                Rectangle   drawingPlace = new Rectangle(50, 50, ClientSize.Width - 100, panel1.Top - 100);

                drawer.Draw(g, drawingPlace, 10, 5, Color.ForestGreen, Color.RoyalBlue);
            }
        }
示例#3
0
        private void spanButton_Click(object sender, EventArgs e)
        {
            using (Graphics g = this.CreateGraphics())  //toDo redo better if time later
            {
                GraphDrawer drawer       = new GraphDrawer(_spanningTree);
                Rectangle   drawingPlace = new Rectangle(50, 50, ClientSize.Width - 100, panel1.Top - 100);

                drawer.Draw(g, drawingPlace, 10, 5, Color.Orchid, Color.RoyalBlue);
            }
        }